diff --git a/docs/reference/gtk/tmpl/gtkuimanager.sgml b/docs/reference/gtk/tmpl/gtkuimanager.sgml index b25eaf91c7..22f5d8b848 100644 --- a/docs/reference/gtk/tmpl/gtkuimanager.sgml +++ b/docs/reference/gtk/tmpl/gtkuimanager.sgml @@ -49,7 +49,8 @@ Definitions. position (top|bot) #IMPLIED > + position (top|bot) #IMPLIED + always-show-image (true|false) #IMPLIED > diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c index 24267a6bfa..771252d53c 100644 --- a/gtk/gtkuimanager.c +++ b/gtk/gtkuimanager.c @@ -33,6 +33,7 @@ #include #include "gtkactivatable.h" #include "gtkbuildable.h" +#include "gtkimagemenuitem.h" #include "gtkintl.h" #include "gtkmarshalers.h" #include "gtkmenu.h" @@ -82,6 +83,8 @@ struct _Node { guint dirty : 1; guint expand : 1; /* used for separators */ guint popup_accels : 1; + guint always_show_image_set : 1; /* used for menu items */ + guint always_show_image : 1; /* used for menu items */ }; #define GTK_UI_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_UI_MANAGER, GtkUIManagerPrivate)) @@ -1211,6 +1214,7 @@ start_element_handler (GMarkupParseContext *context, gboolean top; gboolean expand = FALSE; gboolean accelerators = FALSE; + gboolean always_show_image_set = FALSE, always_show_image = FALSE; gboolean raise_error = TRUE; @@ -1242,6 +1246,11 @@ start_element_handler (GMarkupParseContext *context, { accelerators = !strcmp (attribute_values[i], "true"); } + else if (!strcmp (attribute_names[i], "always-show-image")) + { + always_show_image_set = TRUE; + always_show_image = !strcmp (attribute_values[i], "true"); + } /* else silently skip unknown attributes to be compatible with * future additional attributes. */ @@ -1340,7 +1349,10 @@ start_element_handler (GMarkupParseContext *context, TRUE, top); if (NODE_INFO (node)->action_name == 0) NODE_INFO (node)->action_name = action_quark; - + + NODE_INFO (node)->always_show_image_set = always_show_image_set; + NODE_INFO (node)->always_show_image = always_show_image; + node_prepend_ui_reference (node, ctx->merge_id, action_quark); raise_error = FALSE; @@ -2577,7 +2589,12 @@ update_node (GtkUIManager *self, info->proxy = gtk_action_create_menu_item (action); g_object_ref_sink (info->proxy); gtk_widget_set_name (info->proxy, info->name); - + + if (info->always_show_image_set && + GTK_IS_IMAGE_MENU_ITEM (info->proxy)) + gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (info->proxy), + info->always_show_image); + gtk_menu_shell_insert (GTK_MENU_SHELL (menushell), info->proxy, pos); } diff --git a/tests/merge-2.ui b/tests/merge-2.ui index 05a641fe96..599a3cb221 100644 --- a/tests/merge-2.ui +++ b/tests/merge-2.ui @@ -5,7 +5,7 @@ - +