Re: g_signal_connect_swapped



Richard,

I'm also, as you are, a rather inexperienced GTK programmer, but I hope to still help you by the following, without immediately digging into all kinds of technical details : whereever the _swapped variant is used, that is done to call a callback from within a widget, to a procedure that's applicable on another widget (or even, in most cases another widget class).

So e.g., a button press that should be calling some callback procedure on the window it is in, will use the _swapped variant (passing the window pointer as user_data argument). Doing so will make GTK's internal mechanics to "convert/abuse" that user_data argument's value, by putting it into the callback's call as it's *first* argument), so that the window's callback doesn't even realize it used to be the original widget's call's user_data argument).

Hope this helps you more than it eventually further confuses you,

Kind regards,

PhB

Richard Riley wrote:

"Matt Hoosier" <matt hoosier gmail com> writes:

On 11/25/06, Richard <rileyrg googlemail com> wrote:
Could someone explain the reason for this function

"g_signal_connect_swapped"

I have read the manual here:

http://www.gtk.org/tutorial/x159.html

where it says:

,----
| g_signal_connect_swapped() is the same as g_signal_connect() except that
| the instance on which the signal is emitted and data will be swapped
| when calling the handler. So when using this function to connect
| signals, the callback should be of the form
|
|
| void callback_func( gpointer   callback_data,
|                     ... /* other signal arguments */
|                     GtkWidget *widget);
|
| where the object is usually a widget.
`----

Could anyone express this a little clearer? I (as a gtk beginner) can
see no reason for it.
This just means that the "widget" and "callback_data" pointers will be
pushed onto the call stack in the opposite order from their ordering
if hooked up with g_signal_connect(). If you're designing your own
callback function, this probably isn't useful; just use
g_signal_connnect() with a callback that has GObject* and gpointer
parameters [in that order].

I can see the order has changed - it was the reason I was looking for. I
don't currently see the point. Maybe it will become clearer as I learn
more.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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