![]() |
| | #1 |
| Registered User Join Date: Jul 2003
Posts: 450
| gtk callback problem in C++ Code: class ChatWindow
{
struct connectEntryStruct
{
GtkEntry *ipEntry;
GtkEntry *portEntry;
};
public:
.
.
void connect(GtkWidget *widget, gpointer connectEntry);
static void staticWrapperConnect(void *ptfncHello, GtkWidget *widget, gpointer connectEntry);
.
.
}
Code: GtkWidget * ChatWindow::connectLayOut(GtkWidget * window)
{
.
.
.
GtkWidget *ipEntry = gtk_entry_new();
GtkWidget *portEntry = gtk_entry_new();
.
.
connectEntryStruct * connectEntry = new connectEntryStruct;
connectEntry->ipEntry = GTK_ENTRY(ipEntry);
connectEntry->portEntry = GTK_ENTRY(portEntry);
.
g_signal_connect (G_OBJECT (connectButton), "clicked",
G_CALLBACK (staticWrapperConnect), connectEntry);
}
Code:
void ChatWindow::connect( GtkWidget *widget, gpointer connectData)
{
connectEntryStruct * connectEntry = reinterpret_cast<connectEntryStruct*>(connectData);
const gchar * ipAdress = gtk_entry_get_text(connectEntry->ipEntry);
const gchar * portNumber = gtk_entry_get_text(connectEntry->portEntry);
g_print ("ipAdress\n");
g_print ("portAdress\n");
}
void ChatWindow::staticWrapperConnect(void *ptfncHello, GtkWidget *widget, gpointer connectEntry)
{
ChatWindow *chatHello = (ChatWindow*) ptfncHello; //cast to member function
chatHello->connect(widget, connectEntry);
}
(gtkwindow:13584): Gtk-CRITICAL **: file gtkentry.c: line 3871 (gtk_entry_get_text): assertion `GTK_IS_ENTRY (entry)' failed /bin/sh: line 1: 13584 Segmentation fault ./gtkwindow Press Enter to continue! Is it possible to do this somehow so that I can pass my Entries without making them global. |
| curlious is offline | |
| | #2 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,676
| No idea, but try http://www.spinics.net/lists/gtk/msg03864.html The mailing list which this site refers to looks like its worth joining (or at least reading) |
| Salem is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| WS_POPUP, continuation of old problem | blurrymadness | Windows Programming | 1 | 04-20-2007 06:54 PM |
| Laptop Problem | Boomba | Tech Board | 1 | 03-07-2006 06:24 PM |
| Sorting problem.. well actually more of a string problem | fatdunky | C Programming | 5 | 11-07-2005 11:34 PM |
| searching problem | DaMenge | C Programming | 9 | 09-12-2005 01:04 AM |
| half ADT (nested struct) problem... | CyC|OpS | C Programming | 1 | 10-26-2002 08:37 AM |