Re: data in g_signal_connect

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

 



olafandjasper@xxxxxxxxxxxx wrote:

=========================================================
mySupport.c:
void selectActionBin(GtkWidget      *button,
                    struct MY_DATA *data)
{
 /* This is the code that does not work */
 printf("In call back, data = <%s>\n",data->bin);
 printf("In call back, data = <%s>\n",data->doc);
 printf("In call back, data is at %p\n", data);
 printf("In call back, &data is at %p\n", &data);
}

This is completely broken, prototype should be:
gboolean selectActionBin(GtkWidget *button, GdkEventButton *event, struct MY_DATA *data);
(marking this as ''static" is not a bad idea too).
1. Return value of this callback should be gboolean (TRUE means that this event is handled and no other callbacks will be executed).
2. You will get a pointer to GdkEventButton structure instead of pointer to MY_DATA.
Look at:
http://developer.gnome.org/doc/API/2.0/gtk/GtkWidget.html#GtkWidget-button-press-event


g_signal_connect(G_OBJECT (butWidget),
"button_press_event",
G_CALLBACK (selectActionBin),
&mydata);




_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux