mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 10:50:10 +00:00
Add support for pango markup in menu items
Before c4a2234a28
menu models could use markup for items and the markup would
be parsed, but this was not intended behavior.
This commit adds official support for using markup
for menu items via the `use-markup` property.
Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/4306
This commit is contained in:
parent
db37452787
commit
0775e21131
@ -427,6 +427,7 @@ gtk_menu_section_box_insert_func (GtkMenuTrackerItem *item,
|
||||
else
|
||||
g_object_bind_property (item, "icon", widget, "icon", G_BINDING_SYNC_CREATE);
|
||||
|
||||
g_object_bind_property (item, "use-markup", widget, "use-markup", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "sensitive", widget, "sensitive", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "role", widget, "role", G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (item, "toggled", widget, "active", G_BINDING_SYNC_CREATE);
|
||||
|
@ -106,6 +106,7 @@ enum {
|
||||
PROP_0,
|
||||
PROP_IS_SEPARATOR,
|
||||
PROP_LABEL,
|
||||
PROP_USE_MARKUP,
|
||||
PROP_ICON,
|
||||
PROP_VERB_ICON,
|
||||
PROP_SENSITIVE,
|
||||
@ -162,6 +163,9 @@ gtk_menu_tracker_item_get_property (GObject *object,
|
||||
case PROP_LABEL:
|
||||
g_value_set_string (value, gtk_menu_tracker_item_get_label (self));
|
||||
break;
|
||||
case PROP_USE_MARKUP:
|
||||
g_value_set_boolean (value, gtk_menu_tracker_item_get_use_markup (self));
|
||||
break;
|
||||
case PROP_ICON:
|
||||
g_value_take_object (value, gtk_menu_tracker_item_get_icon (self));
|
||||
break;
|
||||
@ -223,6 +227,8 @@ gtk_menu_tracker_item_class_init (GtkMenuTrackerItemClass *class)
|
||||
g_param_spec_boolean ("is-separator", "", "", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
||||
gtk_menu_tracker_item_pspecs[PROP_LABEL] =
|
||||
g_param_spec_string ("label", "", "", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
||||
gtk_menu_tracker_item_pspecs[PROP_USE_MARKUP] =
|
||||
g_param_spec_boolean ("use-markup", "", "", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
||||
gtk_menu_tracker_item_pspecs[PROP_ICON] =
|
||||
g_param_spec_object ("icon", "", "", G_TYPE_ICON, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
||||
gtk_menu_tracker_item_pspecs[PROP_VERB_ICON] =
|
||||
@ -628,6 +634,12 @@ gtk_menu_tracker_item_get_label (GtkMenuTrackerItem *self)
|
||||
return label;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_menu_tracker_item_get_use_markup (GtkMenuTrackerItem *self)
|
||||
{
|
||||
return g_menu_item_get_attribute (self->item, "use-markup", "&s", NULL);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* gtk_menu_tracker_item_get_icon:
|
||||
*
|
||||
|
@ -66,6 +66,8 @@ gboolean gtk_menu_tracker_item_get_has_link (GtkMenu
|
||||
|
||||
const char * gtk_menu_tracker_item_get_label (GtkMenuTrackerItem *self);
|
||||
|
||||
gboolean gtk_menu_tracker_item_get_use_markup (GtkMenuTrackerItem *self);
|
||||
|
||||
GIcon * gtk_menu_tracker_item_get_icon (GtkMenuTrackerItem *self);
|
||||
|
||||
GIcon * gtk_menu_tracker_item_get_verb_icon (GtkMenuTrackerItem *self);
|
||||
|
@ -98,6 +98,7 @@
|
||||
* The following attributes are used when constructing menu items:
|
||||
*
|
||||
* - "label": a user-visible string to display
|
||||
* - "use-markup": whether the text in the menu item includes [Pango markup](https://docs.gtk.org/Pango/pango_markup.html)
|
||||
* - "action": the prefixed name of the action to trigger
|
||||
* - "target": the parameter to use when activating the action
|
||||
* - "icon" and "verb-icon": names of icons that may be displayed
|
||||
|
Loading…
Reference in New Issue
Block a user