Should the code below work, to get a menu item from a GtkBuilder using
the <menu> markup? It doesn't seem to. I'm guessing at the XML syntax
based on this:
https://developer.gnome.org/gtk3/unstable/GtkBuilder.html#BUILDER-UI
I would use Glade to show me the correct syntax, but it doesn't use this
<menu>/<section>/<item> syntax yet.
#include <gtk/gtk.h>
const char* ui =
"<interface>"
" <menu id='somemenu'>"
" <section>"
" <item>"
" <attribute name='label' translatable='yes'>Some
Thing</attribute>"
" <attribute name='id'>something</attribute>"
" </item>"
" <item>"
" <attribute name='label' translatable='yes'>Other
Thing</attribute>"
" <attribute name='id'>otherthing</attribute>"
" </item>"
" </section>"
" </menu>"
"</interface>";
int
main (int argc, char *argv[])
{
GtkBuilder* builder = gtk_builder_new();
GError* error = NULL;
gtk_builder_add_from_string (builder, ui, -1, &error);
g_assert_no_error (error);
GMenu* menu = G_MENU (gtk_builder_get_object (builder, "somemenu"));
g_assert (menu);
GMenuItem* menu_item = G_MENU_ITEM (gtk_builder_get_object (builder,
"something"));
g_assert (menu_item);
gtk_main ();
g_object_unref (G_OBJECT (builder));
return 0;
}
--
[email protected]
www.murrayc.com
www.openismus.com
_______________________________________________
gtk-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtk-list