From f0d9afd3005206dfe0962965a2fa21baf9e1fa97 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 22 Feb 2016 22:00:57 -0800 Subject: [PATCH] scrollbar: deprecate min-slider-length style property In favor of min-height/min-width, like we did for other similar properties. --- gtk/gtkscrollbar.c | 18 ++++++++++++++++-- gtk/theme/Adwaita/_common.scss | 5 ++--- gtk/theme/Adwaita/gtk-contained-dark.css | 7 ++++--- gtk/theme/Adwaita/gtk-contained.css | 7 ++++--- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c index 06ddc506bf..1656415d83 100644 --- a/gtk/gtkscrollbar.c +++ b/gtk/gtkscrollbar.c @@ -30,6 +30,7 @@ #include "gtkadjustment.h" #include "gtkintl.h" +#include "gtkorientable.h" #include "gtkprivate.h" @@ -92,6 +93,14 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class) widget_class->style_updated = gtk_scrollbar_style_updated; + /** + * GtkScrollbar:min-slider-length: + * + * Minimum length of scrollbar 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 ("min-slider-length", P_("Minimum Slider Length"), @@ -99,7 +108,7 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class) 0, G_MAXINT, 21, - GTK_PARAM_READABLE)); + GTK_PARAM_READABLE|G_PARAM_DEPRECATED)); gtk_widget_class_install_style_property (widget_class, g_param_spec_boolean ("fixed-slider-length", @@ -148,9 +157,14 @@ gtk_scrollbar_update_style (GtkScrollbar *scrollbar) gboolean has_a, has_b, has_c, has_d; GtkRange *range = GTK_RANGE (scrollbar); GtkWidget *widget = GTK_WIDGET (scrollbar); + GtkCssGadget *slider_gadget = gtk_range_get_slider_gadget (range); + + gtk_css_gadget_get_preferred_size (slider_gadget, + gtk_orientable_get_orientation (GTK_ORIENTABLE (scrollbar)), -1, + &slider_length, NULL, + NULL, NULL); gtk_widget_style_get (widget, - "min-slider-length", &slider_length, "fixed-slider-length", &fixed_size, "has-backward-stepper", &has_a, "has-secondary-forward-stepper", &has_b, diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss index 2b3123465c..9c6586f0ac 100644 --- a/gtk/theme/Adwaita/_common.scss +++ b/gtk/theme/Adwaita/_common.scss @@ -2008,9 +2008,6 @@ scrollbar { @at-root * { -GtkScrollbar-has-backward-stepper: false; -GtkScrollbar-has-forward-stepper: false; - -GtkScrollbar-min-slider-length: 42; // minimum size for the slider. - // sadly can't be in '.slider' - // where it belongs } $_slider_margin: 3px; @@ -2106,6 +2103,7 @@ scrollbar { &.vertical { slider { margin-left: 1px + $_slider_margin; + min-height: 42px; min-width: 6px; &:dir(rtl) { @@ -2137,6 +2135,7 @@ scrollbar { slider { margin-top: 1px + $_slider_margin; min-height: 6px; + min-width: 42px; } &.fine-tune slider { margin-top: 1px + $_slider_fine_tune_margin; } diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css index 2f9cf21fac..9cec40783f 100644 --- a/gtk/theme/Adwaita/gtk-contained-dark.css +++ b/gtk/theme/Adwaita/gtk-contained-dark.css @@ -2220,8 +2220,7 @@ notebook > stack:not(:only-child) { **************/ * { -GtkScrollbar-has-backward-stepper: false; - -GtkScrollbar-has-forward-stepper: false; - -GtkScrollbar-min-slider-length: 42; } + -GtkScrollbar-has-forward-stepper: false; } scrollbar button { border: none; } scrollbar.vertical button.down { @@ -2275,6 +2274,7 @@ scrollbar.fine-tune slider { margin: 4px; } scrollbar.vertical slider { margin-left: 4px; + min-height: 42px; min-width: 6px; } scrollbar.vertical slider:dir(rtl) { margin-left: 3px; @@ -2291,7 +2291,8 @@ scrollbar.vertical trough { border-right-style: solid; } scrollbar.horizontal slider { margin-top: 4px; - min-height: 6px; } + min-height: 6px; + min-width: 42px; } scrollbar.horizontal.fine-tune slider { margin-top: 5px; } scrollbar.horizontal trough { diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css index 7f9c287df4..41313f9456 100644 --- a/gtk/theme/Adwaita/gtk-contained.css +++ b/gtk/theme/Adwaita/gtk-contained.css @@ -2230,8 +2230,7 @@ notebook > stack:not(:only-child) { **************/ * { -GtkScrollbar-has-backward-stepper: false; - -GtkScrollbar-has-forward-stepper: false; - -GtkScrollbar-min-slider-length: 42; } + -GtkScrollbar-has-forward-stepper: false; } scrollbar button { border: none; } scrollbar.vertical button.down { @@ -2285,6 +2284,7 @@ scrollbar.fine-tune slider { margin: 4px; } scrollbar.vertical slider { margin-left: 4px; + min-height: 42px; min-width: 6px; } scrollbar.vertical slider:dir(rtl) { margin-left: 3px; @@ -2301,7 +2301,8 @@ scrollbar.vertical trough { border-right-style: solid; } scrollbar.horizontal slider { margin-top: 4px; - min-height: 6px; } + min-height: 6px; + min-width: 42px; } scrollbar.horizontal.fine-tune slider { margin-top: 5px; } scrollbar.horizontal trough {