Glade Gotchas

18 05 2008

Glade is awesome, no denying that. It’s clean, unlike any other ‘GUI building tool’ I’ve seen. It generates an XML description of the GUI, which is parsed at runtime. It’s simple, and hence easy to use (by virtue of the previous two attributes). At the same time, it does have it’s idiosyncrasies (and limitations) as well, only I’ve never really used the signal callback connector it provides to discover it for myself. It took a bit of googling before I could figure it out.

1) The argument (userdata) provided to the callback handler sends an object containing a GtkWidget registered with the same name in the Glade file (so it would be the returned value of glade_xml_get_widget (“name”);
2) Most irritatingly, the arguments sent to the callback are *swapped*, so instead of
callback_fn (GtkWidget *widget, GtkWidget *glade_widget);
it is
callback_fn (GtkWidget *glade_widget, GtkWidget *widget);
even if glade_value is null.

It’s easy to understand why you can’t specify the userdata; how do you specify the scope of the argument? Perhaps just the code block in which you make the glade_xml_auto_connect call, but that wouldn’t work out either because glade files are processed at runtime; you won’t have the variable names to work with. I’m thinking maybe this could be implemented by using a GObject’s property (say a special “name” property that is unique). Does that even sound possible / a good way to do it?




4 responses

18 05 2008
Pranesh S

Yay! I knew that feature.

And I know why this post appeared too 😛

I am ruling _slinky’s_ world with sublimal messages. 🙂

18 05 2008
Murray Cumming

Glade is not a “UI generation tool”.

18 05 2008

@Murray: I’ll change it to agree with Wikipedia definitions then, a “UI builder”, though it’s hard to properly classify it as it doesn’t generate any code, only a description.

20 06 2008

Somehow i missed the point. Probably lost in translation 🙂 Anyway … nice blog to visit.

cheers, Affront!!!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: