gtk_signal_connect() and passing parameters



Hello,

I'm having trouble passing any kind of parameters to
my call back functions.  For example:

int i = 1456;
...
gtk_signal_connect(GTK_OBJECT(button1),
"button_press_event",
GTK_SIGNAL_FUNC(button1_callback), (gpointer) &i);
...
void button1_callback(GtkWidget *widget, gpointer
data)
{
  g_print("i: %d\n", *((int *)data));
}

Quite simply, I expect to see g_print() print 1456 as
the value of i.  It does not.  Instead, it prints 4. 
Even more strange, if I double click on the button
(which is a checkbox button), it prints 5 instead.

This leads me to believe that what I'm getting via the
data parameter is something other than the address of
my i variable.  I tried passing the value of i instead
(removing the &), and changing to g_print("i: %d\n",
data); but this gave me another bizzare value instead.

I've had two experienced programmers (although not
experienced in GTK) look at this and both are stuck
for a solution.

Anyone have ideas?  I'm starting to think there's some
bug in my version of GTK.

shem_mazur yahoo com au


_____________________________________________________________________________
http://messenger.yahoo.com.au - Yahoo! Messenger
- Voice chat, mail alerts, stock quotes and favourite news and lots more!




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]