Deprecate and ignore gtk-button-images setting

Button images can still be enabled selectively by the app author
using the always-use-image property on the button.
This commit is contained in:
William Jon McCann
2013-06-26 08:24:44 -04:00
parent 5fa0da4200
commit 65c31629c3
5 changed files with 16 additions and 77 deletions

View File

@ -482,7 +482,6 @@ static TranslationEntry translations[] = {
{ "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", "menus-have-icons", "gtk-menu-images", G_TYPE_BOOLEAN, { .b = FALSE } },
{ "org.gnome.desktop.interface", "buttons-have-icons", "gtk-button-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/ButtonImages\0" "gtk-button-images\0"
"Gtk/MenuImages\0" "gtk-menu-images\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"

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/ButtonImages", "gtk-button-images"},
{"Gtk/MenuImages", "gtk-menu-images"}, {"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"},

View File

@ -362,8 +362,8 @@ gtk_button_class_init (GtkButtonClass *klass)
/** /**
* GtkButton:always-show-image: * GtkButton:always-show-image:
* *
* If %TRUE, the button will ignore the #GtkSettings:gtk-button-images * If %TRUE, the button will show the image in addition to the
* setting and always show the image, if available. * label, if available.
* *
* Use this property if the button would be useless or hard to use * Use this property if the button would be useless or hard to use
* without the image. * without the image.
@ -1110,15 +1110,10 @@ show_image (GtkButton *button)
GtkButtonPrivate *priv = button->priv; GtkButtonPrivate *priv = button->priv;
gboolean show; gboolean show;
if (priv->label_text && !priv->always_show_image) if (priv->label_text == NULL || priv->always_show_image)
{
GtkSettings *settings;
settings = gtk_widget_get_settings (GTK_WIDGET (button));
g_object_get (settings, "gtk-button-images", &show, NULL);
}
else
show = TRUE; show = TRUE;
else
show = FALSE;
return show; return show;
} }
@ -2554,53 +2549,12 @@ gtk_button_update_state (GtkButton *button)
gtk_widget_set_state_flags (GTK_WIDGET (button), new_state, TRUE); gtk_widget_set_state_flags (GTK_WIDGET (button), new_state, TRUE);
} }
static void
show_image_change_notify (GtkButton *button)
{
GtkButtonPrivate *priv = button->priv;
if (priv->image)
{
if (show_image (button))
gtk_widget_show (priv->image);
else
gtk_widget_hide (priv->image);
}
}
static void
traverse_container (GtkWidget *widget,
gpointer data)
{
if (GTK_IS_BUTTON (widget))
show_image_change_notify (GTK_BUTTON (widget));
else if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), traverse_container, NULL);
}
static void
gtk_button_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 static void
gtk_button_screen_changed (GtkWidget *widget, gtk_button_screen_changed (GtkWidget *widget,
GdkScreen *previous_screen) GdkScreen *previous_screen)
{ {
GtkButton *button; GtkButton *button;
GtkButtonPrivate *priv; GtkButtonPrivate *priv;
GtkSettings *settings;
gulong show_image_connection;
if (!gtk_widget_has_screen (widget)) if (!gtk_widget_has_screen (widget))
return; return;
@ -2615,20 +2569,6 @@ gtk_button_screen_changed (GtkWidget *widget,
priv->button_down = FALSE; priv->button_down = FALSE;
gtk_button_update_state (button); gtk_button_update_state (button);
} }
settings = gtk_widget_get_settings (widget);
show_image_connection =
g_signal_handler_find (settings, G_SIGNAL_MATCH_FUNC, 0, 0,
NULL, gtk_button_setting_changed, NULL);
if (show_image_connection)
return;
g_signal_connect (settings, "notify::gtk-button-images",
G_CALLBACK (gtk_button_setting_changed), NULL);
show_image_change_notify (button);
} }
static void static void
@ -2676,13 +2616,13 @@ gtk_button_grab_notify (GtkWidget *widget,
* @button: a #GtkButton * @button: a #GtkButton
* @image: a widget to set as the image for the button * @image: a widget to set as the image for the button
* *
* Set the image of @button to the given widget. Note that * Set the image of @button to the given widget. The image will be
* it depends on the #GtkSettings:gtk-button-images setting whether the * displayed if the label text is %NULL or if
* image will be displayed or not, you don't have to call * #GtkButton:always-show-image is %TRUE. You don't have to call
* gtk_widget_show() on @image yourself. * gtk_widget_show() on @image yourself.
* *
* Since: 2.6 * Since: 2.6
*/ */
void void
gtk_button_set_image (GtkButton *button, gtk_button_set_image (GtkButton *button,
GtkWidget *image) GtkWidget *image)
@ -2785,8 +2725,8 @@ gtk_button_get_image_position (GtkButton *button)
* @button: a #GtkButton * @button: a #GtkButton
* @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 button will ignore the #GtkSettings:gtk-button-images * If %TRUE, the button will always show the image in addition to the
* setting and always show the image, if available. * label, if available.
* *
* Use this property if the button would be useless or hard to use * Use this property if the button would be useless or hard to use
* without the image. * without the image.
@ -2823,8 +2763,8 @@ gtk_button_set_always_show_image (GtkButton *button,
* gtk_button_get_always_show_image: * gtk_button_get_always_show_image:
* @button: a #GtkButton * @button: a #GtkButton
* *
* Returns whether the button will ignore the #GtkSettings:gtk-button-images * Returns whether the button will always show the image in addition
* setting and always show the image, if available. * to the label, if available.
* *
* Returns: %TRUE if the button will always show the image * Returns: %TRUE if the button will always show the image
* *

View File

@ -1206,12 +1206,14 @@ gtk_settings_class_init (GtkSettingsClass *class)
* Whether images should be shown on buttons * Whether images should be shown on buttons
* *
* Since: 2.4 * Since: 2.4
*
* Deprecated: 3.10: This setting is ignored
*/ */
result = settings_install_property_parser (class, result = settings_install_property_parser (class,
g_param_spec_boolean ("gtk-button-images", g_param_spec_boolean ("gtk-button-images",
P_("Show button images"), P_("Show button images"),
P_("Whether images should be shown on buttons"), P_("Whether images should be shown on buttons"),
TRUE, FALSE,
GTK_PARAM_READWRITE), GTK_PARAM_READWRITE),
NULL); NULL);
g_assert (result == PROP_BUTTON_IMAGES); g_assert (result == PROP_BUTTON_IMAGES);