RE: gtk_signal_connect() and passing parameters



  For saving the int inside the gpointer, you may want to use...

GINT_TO_POINTER(p);

GPOINTER_TO_INT(p);

GUINT_TO_POINTER(p);

GPOINTER_TO_UINT(p);

  Read Havoc's notes on the subject:
http://www.andamooka.org/reader.pl?pgid=ggadcha_glib

  Take care,
    Lion =^_^=



-----Original Message-----

What you do is: you pass the pointer to a local variable to the callback
function. Thats not a good idea.
instead you have to pass the _value_ itself:
  GTK_SIGNAL_FUNC(button1_callback), (gpointer) i);
and access it with:
  g_print("i: %d\n", (int)data);

Note: if you cast an int to a pointer you should be sure, that 
  sizeof(gpointer) >= sizeof(int)
Btw. i dont know any architecture where this is false, but that doesnt mean,
that there isnt any.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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