Re: [gtk-list] Re: Notebook and listbox problems.

Otto Hammersmith <> writes:

> [snipage]
> >   /* This doesn't seem to work either..... must have typed wrong  */
> >   gtk_signal_connect(GTK_OBJECT(button), "clicked", (GtkSignalFunc)
> >	               gtk_widget_destroy, GTK_OBJECT(window)); 
> Replace that bit with,
> gtk_signal_connect(GTK_OBJECT(button), "clicked", 
> 	           (GtkSignalFunc) gtk_exit, NULL);

Another way to do this is:

  gtk_signal_connect_object(GTK_OBJECT, "clicked",
	                    (GtkSignalFunc) gtk_widget_destroy,

If you look carefully at the examples, I think you'll find that this
is what is done. To explain: a signal function has the form in
general of

   foo(GtkWidget *widget, [ some more args ] , gpointer data)

And can return either int or void. In the case of "clicked",
widget and data are the only two arguments and it returns void.

If you call gtk_signal_connect, then on a callback, widget is
set to the object to which you are connecting the object, and
data is whatever you specify as the fourth argument.
(That's why the first try with gtk_signal_connect destroyed
the button.)

If you call gtk_signal_connect_object, then regardless of the
object you are connecting to, the widget argument to the callback
is set to the _fourth_ argument of gtk_signal_connect_object.


> I do know that GtkSignalFunc is typedefed to void, so the return value
> is right. :)

Actually, GtkSignalFunc is just a placeholder (sort of a void* for
functions) - depending on the signal, the signal handler may be
expected to return non-void (for instance, event
functions must return int, though I'm still a bit uncertain about
what that return value means...)



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