Saturday, April 16, 2011

thinking more

Ok, I thought about it more.

g_signal_connect_swapped(instance, detailed_signal, c_handler, data)
The instance on which the signal is emitted and data will be swapped when calling the handler.


g_signal_connect_swapped (G_OBJECT (button), "clicked", G_CALLBACK (gtk_widget_destroy), (gpointer) button);

In the case of a button, G_OBJECT(button) is the instance, and the data is the (gpointer)button.

So this is... swapped when calling the handler?

The handler prototype is:

void gtk_widget_destroy (GtkWidget *widget);

So... typically (I think) the first argument passed to the callback function would be the instance, and what this is saying is that instead of the instance the data is passed which conveniently sort of matches what the function wants (a pointer).

EDIT: ok if you just use the normal g_signal_connect the function prototype for handling "clicked" is:

void user_function (GtkButton *button, gpointer user_data)

so I think that g_signal_connect_swapped is just a way to get around the function prototype for "clicked" and pass things the way you want them passed to a function. You can just as easily do a normal g_signal_connect with a user_function called and THEN call gtk_widget_destroy.

No comments:

Post a Comment