[Glade-users] Re: data in g_signal_connect
- From: olexiy irtech cn ua (Olexiy Avramchenko)
- Subject: [Glade-users] Re: data in g_signal_connect
- Date: Thu, 13 Nov 2003 18:32:59 +0200
olafandjasper hushmail com 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]