From f49a5bf116376ec9b2522b5fc4e720b8b1aca151 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Thu, 17 Dec 2015 19:24:24 -0800 Subject: [PATCH] menuitem: deprecate width-chars style property Instead, we can just set min-width. --- gtk/gtkmenuitem.c | 30 ++++-------------------- gtk/theme/Adwaita/_common.scss | 1 + gtk/theme/Adwaita/gtk-contained-dark.css | 3 ++- gtk/theme/Adwaita/gtk-contained.css | 3 ++- gtk/theme/HighContrast/_common.scss | 6 +++-- gtk/theme/HighContrast/gtk.css | 3 +++ 6 files changed, 16 insertions(+), 30 deletions(-) diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c index 1c33b2ec78..2308eac519 100644 --- a/gtk/gtkmenuitem.c +++ b/gtk/gtkmenuitem.c @@ -506,29 +506,6 @@ gtk_menu_item_accel_width_foreach (GtkWidget *widget, data); } -static gint -get_minimum_width (GtkWidget *widget) -{ - PangoContext *context; - PangoFontMetrics *metrics; - gint width; - gint width_chars; - - context = gtk_widget_get_pango_context (widget); - - metrics = pango_context_get_metrics (context, - pango_context_get_font_description (context), - pango_context_get_language (context)); - - width = pango_font_metrics_get_approximate_char_width (metrics); - - pango_font_metrics_unref (metrics); - - gtk_widget_style_get (widget, "width-chars", &width_chars, NULL); - - return PANGO_PIXELS (width_chars * width); -} - static void gtk_menu_item_real_get_width (GtkWidget *widget, gint *minimum_size, @@ -560,8 +537,6 @@ gtk_menu_item_real_get_width (GtkWidget *widget, min_width += arrow_size; min_width += arrow_spacing; - - min_width = MAX (min_width, get_minimum_width (widget)); nat_width = min_width; } @@ -982,13 +957,16 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass) * The minimum desired width of the menu item in characters. * * Since: 2.14 + * + * Deprecated: 3.20: Use the standard CSS property min-width; the value of + * this style property is ignored. */ gtk_widget_class_install_style_property (widget_class, g_param_spec_int ("width-chars", P_("Width in Characters"), P_("The minimum desired width of the menu item in characters"), 0, G_MAXINT, 12, - GTK_PARAM_READABLE)); + GTK_PARAM_READABLE|G_PARAM_DEPRECATED)); gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_ITEM_ACCESSIBLE); gtk_widget_class_set_css_name (widget_class, "menuitem"); diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss index 5e8c791e0b..9be926939a 100644 --- a/gtk/theme/Adwaita/_common.scss +++ b/gtk/theme/Adwaita/_common.scss @@ -1500,6 +1500,7 @@ menu, & menuitem { text-shadow: none; padding: 4px; + min-width: 40px; &:hover { color: $selected_fg_color; background-color: $selected_bg_color; diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css index 06d2cd13c7..5431ae093b 100644 --- a/gtk/theme/Adwaita/gtk-contained-dark.css +++ b/gtk/theme/Adwaita/gtk-contained-dark.css @@ -2106,7 +2106,8 @@ menu, menu menuitem, .menu menuitem { text-shadow: none; - padding: 4px; } + padding: 4px; + min-width: 40px; } menu menuitem:hover, .menu menuitem:hover { color: #ffffff; diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css index d72301ee9e..d419d5b5bc 100644 --- a/gtk/theme/Adwaita/gtk-contained.css +++ b/gtk/theme/Adwaita/gtk-contained.css @@ -2112,7 +2112,8 @@ menu, menu menuitem, .menu menuitem { text-shadow: none; - padding: 4px; } + padding: 4px; + min-width: 40px; } menu menuitem:hover, .menu menuitem:hover { color: #ffffff; diff --git a/gtk/theme/HighContrast/_common.scss b/gtk/theme/HighContrast/_common.scss index 28f9e7abaa..9e243cb31a 100644 --- a/gtk/theme/HighContrast/_common.scss +++ b/gtk/theme/HighContrast/_common.scss @@ -1173,10 +1173,12 @@ menu, &.arrow { -gtk-icon-source: -gtk-icontheme('pan-end-symbolic'); } &.arrow:dir(rtl) { -gtk-icon-source: -gtk-icontheme('pan-end-symbolic-rtl'); } } + + menuitem { + min-width: 40px; + } } - - /*************** * Popovers * ***************/ diff --git a/gtk/theme/HighContrast/gtk.css b/gtk/theme/HighContrast/gtk.css index fe5145edef..7744f91500 100644 --- a/gtk/theme/HighContrast/gtk.css +++ b/gtk/theme/HighContrast/gtk.css @@ -1301,6 +1301,9 @@ menu, menu .menuitem.arrow:dir(rtl), .menu .menuitem.arrow:dir(rtl) { -gtk-icon-source: -gtk-icontheme("pan-end-symbolic-rtl"); } + menu menuitem, + .menu menuitem { + min-width: 40px; } /*************** * Popovers *