Re: Gtk::Builder and item id
- From: Christian Schoenebeck <schoenebeck linuxsampler org>
- To: gtkmm-list gnome org
- Subject: Re: Gtk::Builder and item id
- Date: Tue, 07 Nov 2017 00:07:35 +0100
On Montag, 6. November 2017 15:38:32 CET Christian Schoenebeck wrote:
uiBuilder = Gtk::Builder::create();
Glib::ustring ui_info =
"<interface>"
" <menu id='menu-PopupMenuInsideDimRegion'>"
" <section>"
" <item id='item-split'>"
[snip]
" </item>"
" </section>"
" </menu>"
"</interface>";
uiBuilder->add_from_string(ui_info);
[snip]
Now the problem is, that add_from_string() throws the following exception:
Attribute "id" invalid for element "item"
Is that a bug?
Ok, after reviewing the relevant Gtk+ code, the current Gtk Builder XML parser
clearly does not accept an "id" attribute for "item" elements:
https://github.com/GNOME/gtk/blob/master/gtk/gtkbuilder-menus.c
(Line 107) :
if (COLLECT (G_MARKUP_COLLECT_INVALID, NULL))
which contradicts to both, what the Gtk+ docs say, quote:
"Objects may be given a name with the “id” attribute, which allows the
application to retrieve them from the builder with
gtk_builder_get_object()."
( https://developer.gnome.org/gtk3/stable/GtkBuilder.html )
as well as contradicts to the format's schema file:
https://github.com/GNOME/gtk/blob/master/gtk/gtkbuilder.rnc
(Line 58) :
item = element item {
attribute id { xsd:ID } ?,
(attribute_ | link) *
}
But I guess I have to move this issue over to the Gtk+ list.
However I wonder if I am really the first one encountering this issue. I mean
it should be quite common to retrieve menu items at runtime. Or does that mean
other people are using a different approach by assembling menus with
<object class="GtkMenuItem" id="foo">
format instead?
CU
Christian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]