Re: connecting callbacks to signals
- From: Thierry BRICHLER <thierry brichler noos fr>
- To: gtk-list gnome org
- Subject: Re: connecting callbacks to signals
- Date: Sat, 22 Jun 2002 22:28:58 GMT
Hello,
As requested, I will try to « illuminate » this callback connection topic
:
1/ Generally (but pending on considered signal), callback functions
prototype is fnct_callback (GtkObject *object, gpointer data)
2/ gtk_signal_connect (GtkObject *object, const gchar *signal_name,
GtkSignalFunc fnct_callback, gpointer data) allows you to run a callback
function as described above, once the specified signal is emitted (eg. a
mouse click) :
- the GtkObject address transmitted to the callback function is the
widget which emits the signal (eg. the button to click)
- the gpointer data allows data transmission to the callback function
(eg. an array to be displayed, ...)
3/ gtk_signal_connect_object (GtkObject *object, const gchar
*signal_name, GtkSignalFunc fnct_callback, GtkObject *target) allows you
to run a callback function once the specified signal is emitted (eg. a
mouse click). In that case, the GtkObject address transmitted to the
callback function is the object you've specified as target
Example :
-------
Imagine you wish to destroy a window (called « dialog ») once the button
« button_destroy » is clicked, using the « gtk_widget_destroy » standard
gtk function as callback function :
- gtk_signal_connect (GTK_OBJECT(button_destroy), « clicked »,
(GtkSignalFunc)gtk_widget_destroy, NULL) will result in the «
button_destroy » widget destruction instead of the window, because the
pointer to « button_destroy » is transmitted to « gtk_widget_destroy »
function
- gtk_signal_connect_object (GTK_OBJECT(button_destroy), « clicked »,
(GtkSignalFunc) gtk_widget_destroy, GTK_OBJECT(dialog)) is the correct
way to act : destruction of the « dialog » window, because the pointer to
« dialog » is transmitted to « gtk_widget_destroy » function
Am I clear ?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]