forked from AuroraMiddleware/gtk
Respect deprecated menu images setting
I have been convinced that it is a bad idea to change the behaviour at the same time as deprecating it, so go back to respecting the Gtk/MenuImages xsetting in GtkImageMenuItem when it is set. The setting as well as the widget are still deprecated, and the default value of the setting will remain FALSE.
This commit is contained in:
parent
e735da37f6
commit
627a03683f
@ -36,6 +36,7 @@ static const struct {
|
||||
{"Gtk/FontName", "gtk-font-name"},
|
||||
{"Gtk/KeyThemeName", "gtk-key-theme-name"},
|
||||
{"Gtk/Modules", "gtk-modules"},
|
||||
{"Gtk/MenuImages", "gtk-menu-images"},
|
||||
{"Gtk/CursorThemeName", "gtk-cursor-theme-name"},
|
||||
{"Gtk/CursorThemeSize", "gtk-cursor-theme-size"},
|
||||
{"Gtk/ColorScheme", "gtk-color-scheme"},
|
||||
|
@ -497,7 +497,8 @@ gtk_action_class_init (GtkActionClass *klass)
|
||||
/**
|
||||
* GtkAction:always-show-image:
|
||||
*
|
||||
* If %TRUE, the action's menu item proxies will always show their image, if available.
|
||||
* 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.
|
||||
@ -1352,8 +1353,8 @@ gtk_action_get_is_important (GtkAction *action)
|
||||
* @action: a #GtkAction
|
||||
* @always_show: %TRUE if menuitem proxies should always show their image
|
||||
*
|
||||
* Sets whether @action<!-- -->'s menu item proxies will always show
|
||||
* their image, if available.
|
||||
* 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.
|
||||
|
@ -109,6 +109,8 @@ static void gtk_image_menu_item_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
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);
|
||||
|
||||
@ -135,6 +137,7 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
|
||||
GtkContainerClass *container_class = (GtkContainerClass*) klass;
|
||||
|
||||
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_height = gtk_image_menu_item_get_preferred_height;
|
||||
widget_class->get_preferred_height_for_width = gtk_image_menu_item_get_preferred_height_for_width;
|
||||
@ -306,6 +309,21 @@ 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
|
||||
gtk_image_menu_item_map (GtkWidget *widget)
|
||||
{
|
||||
@ -316,7 +334,7 @@ gtk_image_menu_item_map (GtkWidget *widget)
|
||||
|
||||
if (priv->image)
|
||||
g_object_set (priv->image,
|
||||
"visible", priv->always_show_image,
|
||||
"visible", show_image (image_menu_item),
|
||||
NULL);
|
||||
}
|
||||
|
||||
@ -932,7 +950,8 @@ gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item)
|
||||
* @image_menu_item: a #GtkImageMenuItem
|
||||
* @always_show: %TRUE if the menuitem should always show the image
|
||||
*
|
||||
* If %TRUE, the menu item will always show the image, if available.
|
||||
* If %TRUE, the menu item will ignore the #GtkSettings:gtk-menu-images
|
||||
* setting and always show the image, if available.
|
||||
*
|
||||
* Use this property if the menuitem would be useless or hard to use
|
||||
* without the image.
|
||||
@ -957,7 +976,7 @@ gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
|
||||
|
||||
if (priv->image)
|
||||
{
|
||||
if (priv->always_show_image)
|
||||
if (show_image (image_menu_item))
|
||||
gtk_widget_show (priv->image);
|
||||
else
|
||||
gtk_widget_hide (priv->image);
|
||||
@ -971,7 +990,8 @@ gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
|
||||
* gtk_image_menu_item_get_always_show_image:
|
||||
* @image_menu_item: a #GtkImageMenuItem
|
||||
*
|
||||
* Returns whether the menu item will always show the image, if available.
|
||||
* Returns whether the menu item will ignore the #GtkSettings:gtk-menu-images
|
||||
* setting and always show the image, if available.
|
||||
*
|
||||
* Returns: %TRUE if the menu item will always show the image
|
||||
*
|
||||
@ -1075,7 +1095,7 @@ gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
|
||||
|
||||
gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
|
||||
g_object_set (image,
|
||||
"visible", priv->always_show_image,
|
||||
"visible", show_image (image_menu_item),
|
||||
"no-show-all", TRUE,
|
||||
NULL);
|
||||
|
||||
@ -1128,3 +1148,66 @@ gtk_image_menu_item_remove (GtkContainer *container,
|
||||
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));
|
||||
}
|
||||
|
@ -1348,7 +1348,7 @@ gtk_settings_class_init (GtkSettingsClass *class)
|
||||
*
|
||||
* Whether images should be shown in menu items
|
||||
*
|
||||
* Deprecated: 3.10: This setting is ignored
|
||||
* Deprecated: 3.10: This setting is deprecated
|
||||
*/
|
||||
result = settings_install_property_parser (class,
|
||||
g_param_spec_boolean ("gtk-menu-images",
|
||||
|
Loading…
Reference in New Issue
Block a user