mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
Add UI manager attribute to always show image in menu items
Add always-show-image="true|false" attribute to <menuitem> element in UI manager markup. If present, it overrides the always-show-image property on image menu items. Bug #589842.
This commit is contained in:
parent
e571273d81
commit
65485cbc7c
@ -49,7 +49,8 @@ Definitions</link>.
|
||||
position (top|bot) #IMPLIED >
|
||||
<!ATTLIST menuitem name #IMPLIED
|
||||
action #REQUIRED
|
||||
position (top|bot) #IMPLIED >
|
||||
position (top|bot) #IMPLIED
|
||||
always-show-image (true|false) #IMPLIED >
|
||||
<!ATTLIST toolitem name #IMPLIED
|
||||
action #REQUIRED
|
||||
position (top|bot) #IMPLIED >
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <string.h>
|
||||
#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);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<menuitem name="New" action="NewAction" position="top" />
|
||||
<separator name="Sep1" />
|
||||
<separator name="Sep2" />
|
||||
<menuitem name="Quit" action="QuitAction" />
|
||||
<menuitem name="Quit" action="QuitAction" always-show-image="true" />
|
||||
<separator name="Sep3" />
|
||||
</menu>
|
||||
<menu name="EditMenu" action="EditMenuAction">
|
||||
|
Loading…
Reference in New Issue
Block a user