Glade Gotchas May 18, 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.
- 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 ofglade_xml_get_widget("name")
; - Most irritatingly, the arguments sent to the callback are swapped, so instead of
callback_fn (GtkWidget *widget, GtkWidget *glade_widget);
it iscallback_fn (GtkWidget *glade_widget, GtkWidget *widget);
even ifglade_value
isNULL
.
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?