diff options
-rw-r--r-- | docs/reference/gtk/gtk-sections.txt | 2 | ||||
-rw-r--r-- | gtk/gtk.symbols | 2 | ||||
-rw-r--r-- | gtk/gtkaction.c | 84 | ||||
-rw-r--r-- | gtk/gtkaction.h | 3 | ||||
-rw-r--r-- | gtk/gtkimagemenuitem.c | 2 |
5 files changed, 90 insertions, 3 deletions
diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index cee86debb9..55236cf1f2 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -192,6 +192,8 @@ gtk_action_block_activate gtk_action_unblock_activate gtk_action_block_activate_from gtk_action_unblock_activate_from +gtk_action_get_always_show_image +gtk_action_set_always_show_image gtk_action_get_accel_path gtk_action_set_accel_path gtk_action_get_accel_closure diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 161231962b..687c9ec13b 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -160,6 +160,7 @@ gtk_action_disconnect_accelerator #ifndef GTK_DISABLE_DEPRECATED gtk_action_disconnect_proxy #endif +gtk_action_get_always_show_image gtk_action_get_accel_closure gtk_action_get_accel_path gtk_action_get_gicon @@ -184,6 +185,7 @@ gtk_action_is_visible gtk_action_new gtk_action_set_accel_group gtk_action_set_accel_path +gtk_action_set_always_show_image gtk_action_set_gicon gtk_action_set_icon_name gtk_action_set_is_important diff --git a/gtk/gtkaction.c b/gtk/gtkaction.c index 708e0c2e01..a8438ca0a8 100644 --- a/gtk/gtkaction.c +++ b/gtk/gtkaction.c @@ -72,6 +72,7 @@ struct _GtkActionPrivate guint is_important : 1; guint hide_if_empty : 1; guint visible_overflown : 1; + guint always_show_image : 1; guint recursion_guard : 1; guint activate_blocked : 1; @@ -110,7 +111,8 @@ enum PROP_HIDE_IF_EMPTY, PROP_SENSITIVE, PROP_VISIBLE, - PROP_ACTION_GROUP + PROP_ACTION_GROUP, + PROP_ALWAYS_SHOW_IMAGE }; /* GtkBuildable */ @@ -355,6 +357,25 @@ gtk_action_class_init (GtkActionClass *klass) GTK_PARAM_READWRITE)); /** + * GtkAction:always-show-image: + * + * If %TRUE, the action's menu item proxies will ignore the #GtkSettings:gtk-menu-images + * setting and always show their image, if available. + * + * Use this property if the menu item would be useless or hard to use + * without their image. + * + * Since: 2.20 + **/ + g_object_class_install_property (gobject_class, + PROP_ALWAYS_SHOW_IMAGE, + g_param_spec_boolean ("always-show-image", + P_("Always show image"), + P_("Whether the image will always be shown"), + FALSE, + GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + /** * GtkAction::activate: * @action: the #GtkAction * @@ -390,6 +411,7 @@ gtk_action_init (GtkAction *action) action->private_data->visible_overflown = TRUE; action->private_data->is_important = FALSE; action->private_data->hide_if_empty = TRUE; + action->private_data->always_show_image = FALSE; action->private_data->activate_blocked = FALSE; action->private_data->sensitive = TRUE; @@ -551,6 +573,9 @@ gtk_action_set_property (GObject *object, case PROP_ACTION_GROUP: gtk_action_set_action_group (action, g_value_get_object (value)); break; + case PROP_ALWAYS_SHOW_IMAGE: + gtk_action_set_always_show_image (action, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -614,6 +639,9 @@ gtk_action_get_property (GObject *object, case PROP_ACTION_GROUP: g_value_set_object (value, action->private_data->action_group); break; + case PROP_ALWAYS_SHOW_IMAGE: + g_value_set_boolean (value, action->private_data->always_show_image); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1167,8 +1195,6 @@ gtk_action_set_is_important (GtkAction *action, { g_return_if_fail (GTK_IS_ACTION (action)); - g_return_if_fail (GTK_IS_ACTION (action)); - is_important = is_important != FALSE; if (action->private_data->is_important != is_important) @@ -1198,6 +1224,58 @@ gtk_action_get_is_important (GtkAction *action) } /** + * gtk_action_set_always_show_image: + * @action: the action object + * @always_show: %TRUE if menuitem proxies should always show their image + * + * Sets whether @action<!-- -->'s menu item proxies will ignore the + * #GtkSettings:gtk-menu-images setting and always show their image, if available. + * + * Use this if the menu item would be useless or hard to use + * without their image. + * + * Since: 2.20 + */ +void +gtk_action_set_always_show_image (GtkAction *action, + gboolean always_show) +{ + GtkActionPrivate *priv; + + g_return_if_fail (GTK_IS_ACTION (action)); + + priv = action->private_data; + + always_show = always_show != FALSE; + + if (priv->always_show_image != always_show) + { + priv->always_show_image = always_show; + + g_object_notify (G_OBJECT (action), "always-show-image"); + } +} + +/** + * gtk_action_get_always_show_image: + * @action: + * + * Returns whether @action<!-- -->'s menu item proxies will ignore the + * #GtkSettings:gtk-menu-images setting and always show their image, if available. + * + * Returns: %TRUE if the menu item proxies will always show their image + * + * Since: 2.20 + */ +gboolean +gtk_action_get_always_show_image (GtkAction *action) +{ + g_return_val_if_fail (GTK_IS_ACTION (action), FALSE); + + return action->private_data->always_show_image; +} + +/** * gtk_action_set_label: * @action: a #GtkAction * @label: the label text to set diff --git a/gtk/gtkaction.h b/gtk/gtkaction.h index a3636b478a..08e051af93 100644 --- a/gtk/gtkaction.h +++ b/gtk/gtkaction.h @@ -170,6 +170,9 @@ gboolean gtk_action_get_visible_vertical (GtkAction *action); void gtk_action_set_is_important (GtkAction *action, gboolean is_important); gboolean gtk_action_get_is_important (GtkAction *action); +void gtk_action_set_always_show_image (GtkAction *action, + gboolean always_show); +gboolean gtk_action_get_always_show_image (GtkAction *action); G_END_DECLS diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c index 5a7fbc255d..9116a4840e 100644 --- a/gtk/gtkimagemenuitem.c +++ b/gtk/gtkimagemenuitem.c @@ -671,6 +671,8 @@ gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable, !activatable_update_gicon (image_menu_item, action)) activatable_update_icon_name (image_menu_item, action); + gtk_image_menu_item_set_always_show_image (image_menu_item, + gtk_action_get_always_show_image (action)); } |