[gtk+/wip/cosimoc/menuitem-gadget: 20/21] menuitem: deprecate toggle-spacing style property



commit e9348740832367210b1f4abc3cf66b50d6b1b812
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri Dec 18 17:52:16 2015 -0800

    menuitem: deprecate toggle-spacing style property
    
    We can move this to just use the actual GtkCssGadget of the menu item.

 gtk/Makefile.am                          |    1 +
 gtk/gtkcheckmenuitem.c                   |    6 ++++
 gtk/gtkcheckmenuitem.h                   |    6 ----
 gtk/gtkmenu.c                            |   41 +++++++++++++----------------
 gtk/gtkmenuitem.c                        |    8 ++++++
 gtk/gtkradiomenuitem.c                   |    1 +
 gtk/theme/Adwaita/_common.scss           |   12 ++++++---
 gtk/theme/Adwaita/gtk-contained-dark.css |   12 +++------
 gtk/theme/Adwaita/gtk-contained.css      |   12 +++------
 9 files changed, 50 insertions(+), 49 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index f0a9099..77f645d 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -371,6 +371,7 @@ gtk_private_h_sources =             \
        gtkcairoblurprivate.h   \
        gtkcellareaboxcontextprivate.h  \
        gtkcheckbuttonprivate.h \
+       gtkcheckmenuitemprivate.h       \
        gtkclipboardprivate.h           \
        gtkcolorswatchprivate.h \
        gtkcoloreditorprivate.h \
diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index 653b263..2435016 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -832,3 +832,9 @@ _gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
   priv->active = is_active;
   update_node_state (check_menu_item);
 }
+
+GtkCssGadget *
+_gtk_check_menu_item_get_indicator_gadget (GtkCheckMenuItem *check_menu_item)
+{
+  return check_menu_item->priv->indicator_gadget;
+}
diff --git a/gtk/gtkcheckmenuitem.h b/gtk/gtkcheckmenuitem.h
index f791038..be1af00 100644
--- a/gtk/gtkcheckmenuitem.h
+++ b/gtk/gtkcheckmenuitem.h
@@ -108,12 +108,6 @@ void       gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_i
 GDK_AVAILABLE_IN_ALL
 gboolean   gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item);
 
-
-/* private */
-void       _gtk_check_menu_item_set_active       (GtkCheckMenuItem *check_menu_item,
-                                                  gboolean          is_active);
-
-
 G_END_DECLS
 
 #endif /* __GTK_CHECK_MENU_ITEM_H__ */
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 16d5193..05d6975 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -110,6 +110,7 @@
 #include "gtkadjustment.h"
 #include "gtkbindings.h"
 #include "gtkcheckmenuitem.h"
+#include "gtkcheckmenuitemprivate.h"
 #include "gtkmain.h"
 #include "gtkmarshalers.h"
 #include "gtkmenuprivate.h"
@@ -3227,29 +3228,23 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
       gtk_menu_get_n_columns (menu) == 1 &&
       !priv->no_toggle_size)
     {
-      GtkStyleContext *context;
-      GtkWidgetPath *check_path;
-      guint toggle_spacing;
-      guint indicator_size;
-
-      context = gtk_style_context_new ();
-
-      /* Create a GtkCheckMenuItem path, only to query indicator spacing */
-      check_path = _gtk_widget_create_path (widget);
-      gtk_widget_path_append_type (check_path, GTK_TYPE_CHECK_MENU_ITEM);
-
-      gtk_style_context_set_path (context, check_path);
-      gtk_widget_path_free (check_path);
-      gtk_style_context_set_screen (context, gtk_widget_get_screen (widget));
-
-      gtk_style_context_get_style (context,
-                                   "toggle-spacing", &toggle_spacing,
-                                   "indicator-size", &indicator_size,
-                                   NULL);
-
-      max_toggle_size = indicator_size + toggle_spacing;
-
-      g_object_unref (context);
+      GtkWidget *menu_item;
+      GtkCssGadget *indicator_gadget;
+      gint indicator_width;
+
+      /* Create a GtkCheckMenuItem, to query indicator size */
+      menu_item = gtk_check_menu_item_new ();
+      indicator_gadget = _gtk_check_menu_item_get_indicator_gadget
+        (GTK_CHECK_MENU_ITEM (menu_item));
+
+      gtk_css_gadget_get_preferred_size (indicator_gadget,
+                                         GTK_ORIENTATION_HORIZONTAL,
+                                         -1,
+                                         &indicator_width, NULL,
+                                         NULL, NULL);
+      max_toggle_size = indicator_width;
+
+      gtk_widget_destroy (menu_item);
     }
 
   min_width += 2 * max_toggle_size + max_accel_width;
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index d5f2a07..a4c4c1b 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -934,6 +934,14 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
                                                              GTK_PARAM_READABLE |
                                                              G_PARAM_DEPRECATED));
 
+  /**
+   * GtkMenuItem:toggle-spacing:
+   *
+   * Spacing between menu icon and label.
+   *
+   * Deprecated: 3.20: use the standard margin CSS property on the check or
+   *   radio nodes; the value of this style property is ignored.
+   */
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_int ("toggle-spacing",
                                                              "Icon Spacing",
diff --git a/gtk/gtkradiomenuitem.c b/gtk/gtkradiomenuitem.c
index ee70dd7..b8bd75d 100644
--- a/gtk/gtkradiomenuitem.c
+++ b/gtk/gtkradiomenuitem.c
@@ -24,6 +24,7 @@
 
 #include "config.h"
 #include "gtkaccellabel.h"
+#include "gtkcheckmenuitemprivate.h"
 #include "gtkmarshalers.h"
 #include "gtkradiomenuitem.h"
 #include "deprecated/gtkactivatable.h"
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index 8d19c6b..89342b0 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -1540,8 +1540,14 @@ menu,
   }
 }
 
-menuitem accelerator { color: gtkalpha(currentColor,0.55); }
-
+menuitem {
+  & accelerator { color: gtkalpha(currentColor,0.55); }
+  & check,
+  & radio {
+    &:dir(ltr) { margin-right: 7px; }
+    &:dir(rtl) { margin-left: 7px; }
+  }
+}
 
 /***************
  * Popovers   *
@@ -2101,8 +2107,6 @@ switch {
     color: mix($fg_color, $bg_color, 70%);
     -gtk-icon-source: -gtk-icontheme('#{$a}-symbolic');
     -gtk-icon-shadow: none;
-    &:dir(ltr) { margin-right: 7px; }
-    &:dir(rtl) { margin-left: 7px; }
     &:hover, &:insensitive {
       -gtk-icon-source: -gtk-icontheme('#{$a}-symbolic');
       -gtk-icon-shadow: none;
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 8146ddc..fe8a9e1 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -2148,6 +2148,10 @@ menu,
 
 menuitem accelerator {
   color: alpha(currentColor,0.55); }
+menuitem check:dir(ltr), menuitem radio:dir(ltr) {
+  margin-right: 7px; }
+menuitem check:dir(rtl), menuitem radio:dir(rtl) {
+  margin-left: 7px; }
 
 /***************
  * Popovers   *
@@ -2766,10 +2770,6 @@ menu menuitem check {
   color: #b8bab8;
   -gtk-icon-source: -gtk-icontheme("checkbox-symbolic");
   -gtk-icon-shadow: none; }
-  menu menuitem check:dir(ltr) {
-    margin-right: 7px; }
-  menu menuitem check:dir(rtl) {
-    margin-left: 7px; }
   menu menuitem check:hover, menu menuitem check:insensitive {
     -gtk-icon-source: -gtk-icontheme("checkbox-symbolic");
     -gtk-icon-shadow: none; }
@@ -2932,10 +2932,6 @@ menu menuitem radio {
   color: #b8bab8;
   -gtk-icon-source: -gtk-icontheme("radio-symbolic");
   -gtk-icon-shadow: none; }
-  menu menuitem radio:dir(ltr) {
-    margin-right: 7px; }
-  menu menuitem radio:dir(rtl) {
-    margin-left: 7px; }
   menu menuitem radio:hover, menu menuitem radio:insensitive {
     -gtk-icon-source: -gtk-icontheme("radio-symbolic");
     -gtk-icon-shadow: none; }
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 28c08f5..7ba0b2e 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -2154,6 +2154,10 @@ menu,
 
 menuitem accelerator {
   color: alpha(currentColor,0.55); }
+menuitem check:dir(ltr), menuitem radio:dir(ltr) {
+  margin-right: 7px; }
+menuitem check:dir(rtl), menuitem radio:dir(rtl) {
+  margin-left: 7px; }
 
 /***************
  * Popovers   *
@@ -2856,10 +2860,6 @@ menu menuitem check {
   color: #666a6b;
   -gtk-icon-source: -gtk-icontheme("checkbox-symbolic");
   -gtk-icon-shadow: none; }
-  menu menuitem check:dir(ltr) {
-    margin-right: 7px; }
-  menu menuitem check:dir(rtl) {
-    margin-left: 7px; }
   menu menuitem check:hover, menu menuitem check:insensitive {
     -gtk-icon-source: -gtk-icontheme("checkbox-symbolic");
     -gtk-icon-shadow: none; }
@@ -3094,10 +3094,6 @@ menu menuitem radio {
   color: #666a6b;
   -gtk-icon-source: -gtk-icontheme("radio-symbolic");
   -gtk-icon-shadow: none; }
-  menu menuitem radio:dir(ltr) {
-    margin-right: 7px; }
-  menu menuitem radio:dir(rtl) {
-    margin-left: 7px; }
   menu menuitem radio:hover, menu menuitem radio:insensitive {
     -gtk-icon-source: -gtk-icontheme("radio-symbolic");
     -gtk-icon-shadow: none; }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]