Re: g_signal_connect



On 5/3/05, Tomaz Canabrava <tumaix gmail com> wrote:
Little trouble here =)

the g_signal_connect works like what?
g_signal_connect(GTK_WIDGET(widget), signal("clicked"),
G_CALLBACK(Function), (gpointer) "Data");

but the callbacks functions have the GtkWidget *Widget as a 1st
parameter, and...
well, i simply don't get it. =)

Does anyone cares to explain to this little noob the arts and secrets
of the g_signal_connect?

Your callback function should have the following declaration:
void my_callback (GtkWidget *widget, gpointer my_data);

the 'widget' argument is set to the button on which the user clicked,
and 'my_data' is the pointer to your "Data" string. You don't need to
use the 'widget' argument in you callback function, though.

Callback functions always have their first argument as the object
which emitted the signal, and the last one as the data pointer you
pass when you call g_signal_connect().
The arguments in between the two depend on the actual signal being
emitted, and relate to the signal itself; they are set by the GObject
framework by the code actually emitting the signal.

Hope this helps,

Vivien



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