[gtk+/wip/cosimoc/range-gadget: 3/3] scale: deprecate slider-length style property



commit 132f3fe1b2d7e25f27e5cec951769270049abcf8
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Sun Feb 21 15:01:04 2016 -0800

    scale: deprecate slider-length style property
    
    This can be achieved using min-height/min-width CSS properties now.

 gtk/gtkrange.c                           |    6 ++++
 gtk/gtkrangeprivate.h                    |    2 +
 gtk/gtkscale.c                           |   42 ++++++++++++++++++++++--------
 gtk/theme/Adwaita/_common.scss           |    4 +-
 gtk/theme/Adwaita/gtk-contained-dark.css |    5 ++-
 gtk/theme/Adwaita/gtk-contained.css      |    5 ++-
 6 files changed, 47 insertions(+), 17 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index e4efdb4..b5df342 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -3893,3 +3893,9 @@ gtk_range_get_trough_node (GtkRange *range)
 {
   return gtk_css_gadget_get_node (range->priv->trough_gadget);
 }
+
+GtkCssGadget *
+gtk_range_get_slider_gadget (GtkRange *range)
+{
+  return range->priv->slider_gadget;
+}
diff --git a/gtk/gtkrangeprivate.h b/gtk/gtkrangeprivate.h
index 1ce5219..0b0a875 100644
--- a/gtk/gtkrangeprivate.h
+++ b/gtk/gtkrangeprivate.h
@@ -27,6 +27,7 @@
 
 
 #include <gtk/gtkrange.h>
+#include <gtk/gtkcssgadgetprivate.h>
 #include <gtk/gtkcssnodeprivate.h>
 
 
@@ -49,6 +50,7 @@ void               _gtk_range_set_steppers                 (GtkRange      *range
                                                             gboolean       has_d);
 
 GtkCssNode        *gtk_range_get_trough_node (GtkRange *range);
+GtkCssGadget      *gtk_range_get_slider_gadget (GtkRange *range);
 
 G_END_DECLS
 
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index 364b27f..970f2b2 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -268,12 +268,14 @@ gtk_scale_update_style (GtkScale *scale)
 {
   gint slider_length;
   GtkRange *range;
+  GtkCssGadget *slider_gadget;
 
   range = GTK_RANGE (scale);
-
-  gtk_widget_style_get (GTK_WIDGET (scale),
-                        "slider-length", &slider_length,
-                        NULL);
+  slider_gadget = gtk_range_get_slider_gadget (range);
+  gtk_css_gadget_get_preferred_size (slider_gadget,
+                                     gtk_orientable_get_orientation (GTK_ORIENTABLE (scale)), -1,
+                                     &slider_length, NULL,
+                                     NULL, NULL);
 
   gtk_range_set_min_slider_size (range, slider_length);
   gtk_scale_clear_layout (scale);
@@ -376,12 +378,20 @@ gtk_scale_class_init (GtkScaleClass *class)
 
   g_object_class_install_properties (gobject_class, LAST_PROP, properties);
 
+  /**
+   * GtkScale:slider-length:
+   *
+   * Length of scale's slider.
+   *
+   * Deprecated: 3.20: Use min-height/min-width CSS properties on the slider
+   *   element instead. The value of this style property is ignored.
+   */
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_int ("slider-length",
                                                              P_("Slider Length"),
                                                              P_("Length of scale's slider"),
                                                              0, G_MAXINT, 31,
-                                                             GTK_PARAM_READABLE));
+                                                             GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
 
   gtk_widget_class_install_style_property (widget_class,
                                           g_param_spec_int ("value-spacing",
@@ -1086,7 +1096,7 @@ gtk_scale_get_preferred_width (GtkWidget *widget,
       gint slider_length;
       gint w;
 
-      gtk_widget_style_get (widget, "slider-length", &slider_length, NULL);
+      slider_length = gtk_range_get_min_slider_size (GTK_RANGE (widget));
 
       gtk_scale_get_mark_label_size (GTK_SCALE (widget), GTK_POS_TOP, &n1, &w1, &h1, &n2, &w2, &h2);
 
@@ -1113,7 +1123,7 @@ gtk_scale_get_preferred_height (GtkWidget *widget,
       gint slider_length;
       gint h;
 
-      gtk_widget_style_get (widget, "slider-length", &slider_length, NULL);
+      slider_length = gtk_range_get_min_slider_size (GTK_RANGE (widget));
 
       gtk_scale_get_mark_label_size (GTK_SCALE (widget), GTK_POS_TOP, &n1, &w1, &h1, &n2, &w2, &h2);
       h1 = (n1 - 1) * h1 + MAX (h1, slider_length);
@@ -1159,13 +1169,23 @@ gtk_scale_draw (GtkWidget *widget,
   GtkRange *range = GTK_RANGE (scale);
   GtkStyleContext *context;
   gint *marks;
-  gint slider_width;
   gint value_spacing;
   gint min_sep = 4;
+  GtkCssGadget *slider_gadget;
+  int slider_width, slider_height;
 
   context = gtk_widget_get_style_context (widget);
+  slider_gadget = gtk_range_get_slider_gadget (range);
+  gtk_css_gadget_get_preferred_size (slider_gadget,
+                                     GTK_ORIENTATION_HORIZONTAL, -1,
+                                     &slider_width, NULL,
+                                     NULL, NULL);
+  gtk_css_gadget_get_preferred_size (slider_gadget,
+                                     GTK_ORIENTATION_VERTICAL, -1,
+                                     &slider_height, NULL,
+                                     NULL, NULL);
+
   gtk_widget_style_get (widget,
-                        "slider-width", &slider_width,
                         "value-spacing", &value_spacing,
                         NULL);
 
@@ -1200,14 +1220,14 @@ gtk_scale_draw (GtkWidget *widget,
               x1 = marks[i];
               if (mark->position == GTK_POS_TOP)
                 {
-                  y1 = range_rect.y + slider_width / 4;
+                  y1 = range_rect.y + slider_height / 4;
                   y2 = range_rect.y;
                   min_pos = min_pos_before;
                   max_pos = find_next_pos (widget, m, marks + i, GTK_POS_TOP) - min_sep;
                 }
               else
                 {
-                  y1 = range_rect.y + range_rect.height - slider_width / 4;
+                  y1 = range_rect.y + range_rect.height - slider_height / 4;
                   y2 = range_rect.y + range_rect.height;
                   min_pos = min_pos_after;
                   max_pos = find_next_pos (widget, m, marks + i, GTK_POS_BOTTOM) - min_sep;
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index a055a71..59d93d5 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -2490,8 +2490,6 @@ treeview.view radio {
 }
 
 scale {
-  -GtkScale-slider-length: 22;
-
   outline-offset: -10px;
   -gtk-outline-radius: 7px;
 
@@ -2500,6 +2498,7 @@ scale {
     slider {
       margin: 5px 1px;
       min-height: 22px;
+      min-width: 22px;
     }
   }
 
@@ -2507,6 +2506,7 @@ scale {
     trough { margin: 12px 15px; }
     slider {
       margin: 1px 5px;
+      min-height: 22px;
       min-width: 22px;
     }
   }
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 4f03af0..9ccdec4 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -2651,18 +2651,19 @@ scale highlight, progressbar progress {
       border-color: transparent; }
 
 scale {
-  -GtkScale-slider-length: 22;
   outline-offset: -10px;
   -gtk-outline-radius: 7px; }
   scale.horizontal trough {
     margin: 15px 12px; }
   scale.horizontal slider {
     margin: 5px 1px;
-    min-height: 22px; }
+    min-height: 22px;
+    min-width: 22px; }
   scale.vertical trough {
     margin: 12px 15px; }
   scale.vertical slider {
     margin: 1px 5px;
+    min-height: 22px;
     min-width: 22px; }
   scale.fine-tune {
     outline-offset: -8px;
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 1cc65d1..6c0b1db 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -2682,18 +2682,19 @@ scale highlight, progressbar progress {
       border-color: transparent; }
 
 scale {
-  -GtkScale-slider-length: 22;
   outline-offset: -10px;
   -gtk-outline-radius: 7px; }
   scale.horizontal trough {
     margin: 15px 12px; }
   scale.horizontal slider {
     margin: 5px 1px;
-    min-height: 22px; }
+    min-height: 22px;
+    min-width: 22px; }
   scale.vertical trough {
     margin: 12px 15px; }
   scale.vertical slider {
     margin: 1px 5px;
+    min-height: 22px;
     min-width: 22px; }
   scale.fine-tune {
     outline-offset: -8px;


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