Deprecate and ignore gtk-menu-images setting

GtkImageMenuItem images can still be enabled selectively by the app author
using the always-show-image property on the item.
This commit is contained in:
William Jon McCann
2013-06-26 10:36:56 -04:00
parent 77831bf6fd
commit e8147d15f7
6 changed files with 21 additions and 103 deletions

View File

@ -481,7 +481,6 @@ static TranslationEntry translations[] = {
{ "org.gnome.desktop.interface", "cursor-blink", "gtk-cursor-blink", G_TYPE_BOOLEAN, { .b = TRUE } }, { "org.gnome.desktop.interface", "cursor-blink", "gtk-cursor-blink", G_TYPE_BOOLEAN, { .b = TRUE } },
{ "org.gnome.desktop.interface", "cursor-blink-time", "gtk-cursor-blink-time", G_TYPE_INT, { .i = 1200 } }, { "org.gnome.desktop.interface", "cursor-blink-time", "gtk-cursor-blink-time", G_TYPE_INT, { .i = 1200 } },
{ "org.gnome.desktop.interface", "cursor-blink-timeout", "gtk-cursor-blink-timeout", G_TYPE_INT, { .i = 3600 } }, { "org.gnome.desktop.interface", "cursor-blink-timeout", "gtk-cursor-blink-timeout", G_TYPE_INT, { .i = 3600 } },
{ "org.gnome.desktop.interface", "menus-have-icons", "gtk-menu-images", G_TYPE_BOOLEAN, { .b = FALSE } },
{ "org.gnome.desktop.interface", "gtk-im-module", "gtk-im-module", G_TYPE_STRING, { .s = "simple" } }, { "org.gnome.desktop.interface", "gtk-im-module", "gtk-im-module", G_TYPE_STRING, { .s = "simple" } },
{ "org.gnome.desktop.interface", "enable-animations", "gtk-enable-animations", G_TYPE_BOOLEAN, { .b = TRUE } }, { "org.gnome.desktop.interface", "enable-animations", "gtk-enable-animations", G_TYPE_BOOLEAN, { .b = TRUE } },
{ "org.gnome.desktop.interface", "automatic-mnemonics", "gtk-auto-mnemonics", G_TYPE_BOOLEAN, { .b = TRUE } }, { "org.gnome.desktop.interface", "automatic-mnemonics", "gtk-auto-mnemonics", G_TYPE_BOOLEAN, { .b = TRUE } },

View File

@ -318,7 +318,6 @@ _gdk_win32_window_delete_property (GdkWindow *window,
"Gtk/IMStatusStyle\0" "gtk-im-status-style\0" "Gtk/IMStatusStyle\0" "gtk-im-status-style\0"
"Gtk/Modules\0" "gtk-modules\0" "Gtk/Modules\0" "gtk-modules\0"
"Gtk/FileChooserBackend\0" "gtk-file-chooser-backend\0" "Gtk/FileChooserBackend\0" "gtk-file-chooser-backend\0"
"Gtk/MenuImages\0" "gtk-menu-images\0"
"Gtk/MenuBarAccel\0" "gtk-menu-bar-accel\0" "Gtk/MenuBarAccel\0" "gtk-menu-bar-accel\0"
"Gtk/CursorBlinkTimeout\0" "gtk-cursor-blink-timeout\0" "Gtk/CursorBlinkTimeout\0" "gtk-cursor-blink-timeout\0"
"Gtk/CursorThemeName\0" "gtk-cursor-theme-name\0" "Gtk/CursorThemeName\0" "gtk-cursor-theme-name\0"

View File

@ -43,7 +43,6 @@ static const struct {
{"Gtk/IMStatusStyle", "gtk-im-status-style"}, {"Gtk/IMStatusStyle", "gtk-im-status-style"},
{"Gtk/Modules", "gtk-modules"}, {"Gtk/Modules", "gtk-modules"},
{"Gtk/FileChooserBackend", "gtk-file-chooser-backend"}, {"Gtk/FileChooserBackend", "gtk-file-chooser-backend"},
{"Gtk/MenuImages", "gtk-menu-images"},
{"Gtk/MenuBarAccel", "gtk-menu-bar-accel"}, {"Gtk/MenuBarAccel", "gtk-menu-bar-accel"},
{"Gtk/CursorThemeName", "gtk-cursor-theme-name"}, {"Gtk/CursorThemeName", "gtk-cursor-theme-name"},
{"Gtk/CursorThemeSize", "gtk-cursor-theme-size"}, {"Gtk/CursorThemeSize", "gtk-cursor-theme-size"},

View File

@ -398,8 +398,7 @@ gtk_action_class_init (GtkActionClass *klass)
/** /**
* GtkAction:always-show-image: * GtkAction:always-show-image:
* *
* If %TRUE, the action's menu item proxies will ignore the #GtkSettings:gtk-menu-images * If %TRUE, the action's menu item proxies will always show their image, if available.
* setting and always show their image, if available.
* *
* Use this property if the menu item would be useless or hard to use * Use this property if the menu item would be useless or hard to use
* without their image. * without their image.
@ -1203,8 +1202,8 @@ gtk_action_get_is_important (GtkAction *action)
* @action: a #GtkAction * @action: a #GtkAction
* @always_show: %TRUE if menuitem proxies should always show their image * @always_show: %TRUE if menuitem proxies should always show their image
* *
* Sets whether @action<!-- -->'s menu item proxies will ignore the * Sets whether @action<!-- -->'s menu item proxies will always show
* #GtkSettings:gtk-menu-images setting and always show their image, if available. * their image, if available.
* *
* Use this if the menu item would be useless or hard to use * Use this if the menu item would be useless or hard to use
* without their image. * without their image.
@ -1235,9 +1234,8 @@ gtk_action_set_always_show_image (GtkAction *action,
* gtk_action_get_always_show_image: * gtk_action_get_always_show_image:
* @action: a #GtkAction * @action: a #GtkAction
* *
* Returns whether @action<!-- -->'s menu item proxies will ignore the * Returns whether @action<!-- -->'s menu item proxies will always
* #GtkSettings:gtk-menu-images setting and always show their image, * show their image, if available.
* if available.
* *
* Returns: %TRUE if the menu item proxies will always show their image * Returns: %TRUE if the menu item proxies will always show their image
* *

View File

@ -107,8 +107,6 @@ static void gtk_image_menu_item_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_image_menu_item_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen);
static void gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item); static void gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item);
@ -134,7 +132,6 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
GtkContainerClass *container_class = (GtkContainerClass*) klass; GtkContainerClass *container_class = (GtkContainerClass*) klass;
widget_class->destroy = gtk_image_menu_item_destroy; widget_class->destroy = gtk_image_menu_item_destroy;
widget_class->screen_changed = gtk_image_menu_item_screen_changed;
widget_class->get_preferred_width = gtk_image_menu_item_get_preferred_width; widget_class->get_preferred_width = gtk_image_menu_item_get_preferred_width;
widget_class->get_preferred_height = gtk_image_menu_item_get_preferred_height; widget_class->get_preferred_height = gtk_image_menu_item_get_preferred_height;
widget_class->get_preferred_height_for_width = gtk_image_menu_item_get_preferred_height_for_width; widget_class->get_preferred_height_for_width = gtk_image_menu_item_get_preferred_height_for_width;
@ -180,10 +177,9 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
/** /**
* GtkImageMenuItem:always-show-image: * GtkImageMenuItem:always-show-image:
* *
* If %TRUE, the menu item will ignore the #GtkSettings:gtk-menu-images * If %TRUE, the menu item will always show the image, if available.
* setting and always show the image, if available.
* *
* Use this property if the menuitem would be useless or hard to use * Use this property only if the menuitem would be useless or hard to use
* without the image. * without the image.
* *
* Since: 2.16 * Since: 2.16
@ -301,21 +297,6 @@ gtk_image_menu_item_get_property (GObject *object,
} }
} }
static gboolean
show_image (GtkImageMenuItem *image_menu_item)
{
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (image_menu_item));
gboolean show;
if (priv->always_show_image)
show = TRUE;
else
g_object_get (settings, "gtk-menu-images", &show, NULL);
return show;
}
static void static void
gtk_image_menu_item_map (GtkWidget *widget) gtk_image_menu_item_map (GtkWidget *widget)
{ {
@ -326,7 +307,7 @@ gtk_image_menu_item_map (GtkWidget *widget)
if (priv->image) if (priv->image)
g_object_set (priv->image, g_object_set (priv->image,
"visible", show_image (image_menu_item), "visible", priv->always_show_image,
NULL); NULL);
} }
@ -925,8 +906,7 @@ gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item)
* @image_menu_item: a #GtkImageMenuItem * @image_menu_item: a #GtkImageMenuItem
* @always_show: %TRUE if the menuitem should always show the image * @always_show: %TRUE if the menuitem should always show the image
* *
* If %TRUE, the menu item will ignore the #GtkSettings:gtk-menu-images * If %TRUE, the menu item will always show the image, if available.
* setting and always show the image, if available.
* *
* Use this property if the menuitem would be useless or hard to use * Use this property if the menuitem would be useless or hard to use
* without the image. * without the image.
@ -949,7 +929,7 @@ gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
if (priv->image) if (priv->image)
{ {
if (show_image (image_menu_item)) if (priv->always_show_image)
gtk_widget_show (priv->image); gtk_widget_show (priv->image);
else else
gtk_widget_hide (priv->image); gtk_widget_hide (priv->image);
@ -963,8 +943,7 @@ gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
* gtk_image_menu_item_get_always_show_image: * gtk_image_menu_item_get_always_show_image:
* @image_menu_item: a #GtkImageMenuItem * @image_menu_item: a #GtkImageMenuItem
* *
* Returns whether the menu item will ignore the #GtkSettings:gtk-menu-images * Returns whether the menu item will always show the image, if available.
* setting and always show the image, if available.
* *
* Returns: %TRUE if the menu item will always show the image * Returns: %TRUE if the menu item will always show the image
* *
@ -1059,7 +1038,7 @@ gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item)); gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
g_object_set (image, g_object_set (image,
"visible", show_image (image_menu_item), "visible", priv->always_show_image,
"no-show-all", TRUE, "no-show-all", TRUE,
NULL); NULL);
@ -1110,66 +1089,3 @@ gtk_image_menu_item_remove (GtkContainer *container,
GTK_CONTAINER_CLASS (gtk_image_menu_item_parent_class)->remove (container, child); GTK_CONTAINER_CLASS (gtk_image_menu_item_parent_class)->remove (container, child);
} }
} }
static void
show_image_change_notify (GtkImageMenuItem *image_menu_item)
{
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
if (priv->image)
{
if (show_image (image_menu_item))
gtk_widget_show (priv->image);
else
gtk_widget_hide (priv->image);
}
}
static void
traverse_container (GtkWidget *widget,
gpointer data)
{
if (GTK_IS_IMAGE_MENU_ITEM (widget))
show_image_change_notify (GTK_IMAGE_MENU_ITEM (widget));
else if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), traverse_container, NULL);
}
static void
gtk_image_menu_item_setting_changed (GtkSettings *settings)
{
GList *list, *l;
list = gtk_window_list_toplevels ();
for (l = list; l; l = l->next)
gtk_container_forall (GTK_CONTAINER (l->data),
traverse_container, NULL);
g_list_free (list);
}
static void
gtk_image_menu_item_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen)
{
GtkSettings *settings;
gulong show_image_connection;
if (!gtk_widget_has_screen (widget))
return;
settings = gtk_widget_get_settings (widget);
show_image_connection =
g_signal_handler_find (settings, G_SIGNAL_MATCH_FUNC, 0, 0,
NULL, gtk_image_menu_item_setting_changed, NULL);
if (show_image_connection)
return;
g_signal_connect (settings, "notify::gtk-menu-images",
G_CALLBACK (gtk_image_menu_item_setting_changed), NULL);
show_image_change_notify (GTK_IMAGE_MENU_ITEM (widget));
}

View File

@ -88,7 +88,7 @@
* /&ast; make sure the type is realized &ast;/ * /&ast; make sure the type is realized &ast;/
* g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM)); * g_type_class_unref (g_type_class_ref (GTK_TYPE_IMAGE_MENU_ITEM));
* *
* g_object_set (gtk_settings_get_default (), "gtk-menu-images", FALSE, NULL); * g_object_set (gtk_settings_get_default (), "gtk-enable-animations", FALSE, NULL);
* </programlisting></informalexample> * </programlisting></informalexample>
* *
* There is one GtkSettings instance per screen. It can be obtained with * There is one GtkSettings instance per screen. It can be obtained with
@ -1276,11 +1276,18 @@ gtk_settings_class_init (GtkSettingsClass *class)
NULL); NULL);
g_assert (result == PROP_ENTRY_PASSWORD_HINT_TIMEOUT); g_assert (result == PROP_ENTRY_PASSWORD_HINT_TIMEOUT);
/**
* GtkSettings::gtk-menu-images:
*
* Whether images should be shown in menu items
*
* Deprecated: 3.10: This setting is ignored
*/
result = settings_install_property_parser (class, result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-menu-images", g_param_spec_boolean ("gtk-menu-images",
P_("Show menu images"), P_("Show menu images"),
P_("Whether images should be shown in menus"), P_("Whether images should be shown in menus"),
TRUE, FALSE,
GTK_PARAM_READWRITE), GTK_PARAM_READWRITE),
NULL); NULL);
g_assert (result == PROP_MENU_IMAGES); g_assert (result == PROP_MENU_IMAGES);