GNOME Bugzilla – Bug 69639
libglade should handle non GtkWidgets
Last modified: 2011-07-19 23:23:12 UTC
(this is based on a suggestion by jrb and andersca) libglade should be able to work with things other than gtk widgets. With the development version, most of the code is simply working with GObject APIs rather than GtkWidget specific APIs. Being able to handle things other than GtkWidgets should be quite easy, although it will most likely involve API additions (which is why it is probably too late for 2.0). Here is the basic steps: 1) remove assertions and assumptions that glade_xml_standard_build_widget(), etc are working with GtkWidgets, where appropriate, so that they can work with arbitrary GObjects. 2) Maybe rename functions with widget in their name to indicate that they don't just work with widgets. This would be acompanied with compatibility defines, so that programs compiled with the new lib use the new functions, and with compatibility functions in the lib so that old programs continue to work. 3) add an <object> tag to the glade file format, that would be treated exactly like <widget>. This would mainly be cosmetic, but it feels a bit weird defining non widgets with the <widget> tag. Handling of the new tag would be identical. Possible uses for this would include: - GtkSizeGroups: <object class="GtkSizeGroup" id="sizegroup1"> ... </object> ... <widget id="blah"> <property name="size-group">sizegroup1</property> ... </widget> - Specifying GnomeCanvasItem objects in a GnomeCanvas widget <widget class="GnomeCanvas" id="canvas1"> <child internal-child="canvas-root"> <object class="GnomeCanvasGroup" id="group1"> <child> <object class="GnomeCanvasRect" id="rect1"> ... - GtkTreeViewColumn objects in a GtkTreeView widget - GtkCellRenderer objects in a GtkTreeViewColumn object Probably other uses that I haven't thought of yet. This is almost definitely not 2.0 material though.
Yet another use for this would be working with adjustments. It would be one way of hooking a scrollbar up to a text widget, etc. This is definitely a 2.2 bug now.
Created attachment 6950 [details] [review] proposed patch
oops, that was a mistake, sorry
It would also allow Kiwi to specify its own widgets for libglade to build, though not exactly as the proposal above states.
I'm looking into doing this. The main problem I see is keeping binary compat. If we want to do that, we need to either duplicate many functions with a object variant, or simply keep the names what they were and modify them to take/return a GObject. This could cause some compilation issues, so a gpointer might make more sense. James, which would you prefer? I think I'd rather add object variants for the functions in glade-xml.h, while just converting GtkWidget to gpointer/GObject in glade-build.h. Make sense?
Comment on attachment 6950 [details] [review] proposed patch Given that the next comment is 'mistake, sorry' seems it it is safe to mark this needs-work :)
Created attachment 57339 [details] [review] patch Allows GObjects to be registered. Uses weak refs to clean up objects instead of GtkObject::destroy. GladeXML's name_hash is now considered being an internal resource and will only be properly free'd when the xml object is finalized. With this patch it's trivial to support GtkSizeGroups.
The GNOME Release team has officially deprecated libglade in favor of GtkBuilder[1]. So it's unlikely to get further development. I am closing bugs as WONTFIX. Please feel free to reopen the bugs in future if anyone takes the responsibility for active development. [1] http://permalink.gmane.org/gmane.comp.gnome.devel.announce/28