GNOME Bugzilla – Bug 667970
glade needs support for gmenu construction
Last modified: 2018-03-26 15:23:01 UTC
(not sure if gmenu bugs should be filed against gtk or glib) The new menu xml has some properties that make its use from gtkbuilder weird. 1) First (and most important) when you build objects with gtkbuilder you normally get specific instances of the object itself, menu is different since once you get the app_menu/menu_bar from the builder you set them on the app and then instances are created for each window of the app. This also translates to the fact that menus cannot have an "id" attribute, which is sometime a problem by itself (e.g. if I want to apply css by id to a specificic menu entry) 2) all other objects in builder file use the <object> tag, using a <menu> tag is pretty much ad hoc, and using get_object() to get it is strange. When I asked to desrt he said good practice is to put the menu definition in a separate file to be loaded with a different builder instance at a different time, so the question is: if we are using a completely different xml, we put in a separate file and we parse it at a different time, why do we abuse GtkBuilder?
I don't know; the uimanager xml is also just embedded inside gtkbuilder xml. Is this so different ?
The first synctactic difference is that the uimanager xml is <object class="GtkUIManager" id="uiman"> ... </object> so the use of get_object() is correct, what is inside each object tag itself is object specific. Treemodel has custom xml inside. And even widgets have "custom" xml, since e.g. the <packing> part is something that is only valid for widgets not all gobjects. I think it would be cleaner if all objects accessed by a builder correspond to an <object> tag in the xml representation. But apart from the syntactic part, the thing that concerns me the most is that I fear everyone will get it wrong: fire up glade, create a window, a menu a toolbar etc then in the code for every app window instanciate the GtkBuilder, get the appmenu, set it in the application, get the menubar, set it, get the toolbar etc. Which is what even you did in the demo application. As far as I understand it from Ryan's explanation that is wrong since menu should only be set once per app. At least the uimanager builder xml made somewhat more clear that the object you obtained was a "template" for the actual menu, since you then had the real object later on in the .ui file: <object class="GtkMenuBar" id="menubar1" constructor="uiman"/>
essentially this bug is: glade needs support for gmenu construction.
^ any chance of changing the bug title to this, I'm trying to port some old gtk3 style menus, and thought glade might be helpful, but it isn't due to lack of support for gmenu.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glade/issues/100.