I have the following XML code that I use to generate a GtkMenuBar by means of GtkBuilder:
<?xml version="1.0"?>
<interface>
<menu id="menubar">
<submenu id="submenu">
<attribute name="label">test</attribute>
<section>
<item>
<attribute name="label">random item</attribute>
</item>
</section>
</submenu>
</menu>
</interface>
Both the menu as well as the submenu allow for an id
attribute with which I can use in a call to gtk_builder_get_object
, when I ever need to refer to them in my program, and this works just fine.
However, for the item
, such an id
attribute is impossible, i.e. changing <item>
to <item id="myitem">
will result in the error
Gtk-ERROR **: failed to add UI: attribute 'id' invalid for element 'item'
However, I need to change this menu item's label at runtime and had hoped to do this in the way I described above. How can I accomplish this instead?