Isn't this exactly what the "Name: " field in glade is doing?
Apparently not. Glade is using the string in the "Name" field to name its variables in the generated C code (interface.c) but it does not call gtk_widget_set_name() on the widget with it. Paul mentioned that one can get Glade to do this, but I still cannot find the switch to do this. I definitely do not want to manually modify the generated interface.c file for obvious reasons. Any help on this would be appreciated.
Note that naming by itself is not enough to get access to the widget by the name, but you also need to store a hash_table that maps the name to the widgets. Since all widgets are GObjects that contain such a hash table (through g_object_set_data(), g_object_get_data()) you may e.g. create the hash table in the top widget. Add another pointer from all widgets to the top widget and you may traverse the whole hierarchy without adding additional variables. On the other hand if you use libglade, I think you can get the mapping from name to widget directly through one of its methods.
That's certainly an interesting mechanism. There are a couple of issues to think about, though. The first would be figuring out the good methods for widget access. There's the hash array you mentioned stored on the topmost widget. Of course, the "topmost" widget could change at any time. There's also the need to have a namespace-like mechanism for differentiating two similarly named widget (which might not even happen in a Glade-created window if Glade prohibits same names for different widgets). Ie. "window1.vbox1.table1.left_button".
I don't mind having DOM-like or more familiar tree-access mechanisms.
The second issue that comes to mind is standardizing. It would be nice if there was a community-sanctioned mechanism and that goes into Glade. Personally, I would be glad for a system where given any widget (not necessarily the topmost), I could ask it for widget "table1.button1.alignment1.hbox1.label2" contained in it.
--
Richi Plana
_______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list