Gtk::Builder and item id
- From: Christian Schoenebeck <schoenebeck linuxsampler org>
- To: gtkmm-list gnome org
- Subject: Gtk::Builder and item id
- Date: Mon, 06 Nov 2017 15:38:32 +0100
Hi
in the course of porting our app to latest GTKMM 3.91.2 API(s), I encountered
some issues where I wonder whether those are GTK(MM) bugs or rather
intentional.
First of all, I replaced Gtk::UIManager code occurrences by Gtk::Builder code.
And for instance a popup menu which was previously constructed with UIManager
like this:
uiManager = Gtk::UIManager::create();
uiManager->insert_action_group(actionGroup);
Glib::ustring ui_info =
"<ui>"
" <popup name='PopupMenuInsideDimRegion'>"
" <menuitem action='SplitDimZone'/>"
" <menuitem action='DeleteDimZone'/>"
" </popup>"
"</ui>";
uiManager->add_ui_from_string(ui_info);
popup_menu_inside_dimregion = dynamic_cast<Gtk::Menu*>(
uiManager->get_widget("/PopupMenuInsideDimRegion")
);
with Builder it now looks like this:
uiBuilder = Gtk::Builder::create();
Glib::ustring ui_info =
"<interface>"
" <menu id='menu-PopupMenuInsideDimRegion'>"
" <section>"
" <item id='item-split'>"
" <attribute name='label' translatable='yes'>Split Dimension
Zone</attribute>"
" <attribute
name='action'>PopupMenuInsideDimRegion.SplitDimZone</attribute>"
" </item>"
" <item id='item-delete'>"
" <attribute name='label' translatable='yes'>Delete Dimension
Zone</attribute>"
" <attribute
name='action'>PopupMenuInsideDimRegion.DeleteDimZone</attribute>"
" </item>"
" </section>"
" </menu>"
"</interface>";
uiBuilder->add_from_string(ui_info);
popup_menu_inside_dimregion = new Gtk::Menu(
Glib::RefPtr<Gio::Menu>::cast_dynamic(
uiBuilder->get_object("menu-PopupMenuInsideDimRegion")
)
);
Now the problem is, that add_from_string() throws the following exception:
Attribute "id" invalid for element "item"
Is that a bug? If that is intentional, how should it be possible to query an
item object instead? Because we need to query menu items to change their label
at runtime like this:
auto menuItemSplit = Glib::RefPtr<Gio::MenuItem>::cast_dynamic(
uiBuilder->get_object("item-split")
);
menuItemSplit->set_label(
(bSomeCondition) ? _("Some text") : _("An alternative text")
);
Thanks!
CU
Christian
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]