After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 667970 - glade needs support for gmenu construction
glade needs support for gmenu construction
Status: RESOLVED OBSOLETE
Product: glade
Classification: Applications
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Glade 3 Maintainers
Glade 3 Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-01-15 22:17 UTC by Paolo Borelli
Modified: 2018-03-26 15:23 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Paolo Borelli 2012-01-15 22:17:46 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?
Comment 1 Matthias Clasen 2012-01-16 20:50:46 UTC
I don't know; the uimanager xml is also just embedded inside gtkbuilder xml.
Is this so different ?
Comment 2 Paolo Borelli 2012-01-16 22:16:48 UTC
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"/>
Comment 3 Matthias Clasen 2014-12-08 12:18:07 UTC
essentially this bug is: glade needs support for gmenu construction.
Comment 4 Stuart Axon 2015-11-27 07:58:18 UTC
^ 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.
Comment 5 GNOME Infrastructure Team 2018-03-26 15:23:01 UTC
-- 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.