Web lists-archives.com

Gtk Builder and item id




Hi,

I noticed that the current Gtk Builder XML parser does not accept an id for 
"item" elements. Please consider the attached patch to address this.

Background: it should be possible to query menu items at runtime to change 
their labels (text) at any time.

CU
Christian
--- gtk+-3.91.2/gtk/gtkbuilder-menus.c.orig	2017-10-25 01:01:04.000000000 +0200
+++ gtk+-3.91.2/gtk/gtkbuilder-menus.c	2017-11-07 21:00:56.000000000 +0100
@@ -103,11 +103,15 @@
       if (g_str_equal (element_name, "item"))
         {
           GMenuItem *item;
+          const gchar *id;
 
-          if (COLLECT (G_MARKUP_COLLECT_INVALID, NULL))
+          if (COLLECT (STRING | OPTIONAL, "id", &id))
             {
               item = g_menu_item_new (NULL, NULL);
               gtk_builder_menu_push_frame (state, NULL, item);
+
+              if (id != NULL)
+                _gtk_builder_add_object (state->parser_data->builder, id, G_OBJECT (item));
             }
 
           return;
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list