Basic Q. on callbacks and signal handling



Hi,
	I am going through the gtk tutorials (at gtk.org). I can't
explain this to myself. when we setup a callback for an event, we also
pass the pointer to the widget that emitted the signal to that callback.
	In tutorial 8 (range buttons), in the first call back
cb_pos_menu_select , the widget that emits the signal is passed as an
argument to this function. However this function does not use this
widget pointer anywhere. I once asked a Q about pointers and signals
earlier and I got the following response for it.

>In this example he doesn't need the pointer to the button anymore,
>because this is stored by gtk, using gtk_signal_connect(). So he just
>reuses the variabel. The memory reserved for the button still remains
>reserverd until it's freed (this is done by gtk_widget_destroy() or at
>the end of the program).

	going by this, it would seem that once we set up the signal
handler, all the connections between the widget and the call back
function are maintained internally by GTK. so now my real question...
why do I need to pass the widget as an argument in this particular call
back function (it does not serve any purpose). I tried to run it without 
passing the widget as an argument and it wouldn't run as expected. 
	I'd appreciate it if someone would explain this to me. 
Thank you
Aravind



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