diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c index fbce536846..a2b10e16fb 100644 --- a/gtk/gtkswitch.c +++ b/gtk/gtkswitch.c @@ -56,6 +56,7 @@ #include "fallback-c89.c" #define DEFAULT_SLIDER_WIDTH (36) +#define DEFAULT_SLIDER_HEIGHT (22) struct _GtkSwitchPrivate { @@ -403,7 +404,7 @@ gtk_switch_get_preferred_height (GtkWidget *widget, GtkStyleContext *context; GtkStateFlags state; GtkBorder padding; - gint height, slider_width, min_height; + gint height, slider_height; PangoLayout *layout; PangoRectangle logical_rect; gchar *str; @@ -422,11 +423,9 @@ gtk_switch_get_preferred_height (GtkWidget *widget, gtk_style_context_restore (context); gtk_widget_style_get (widget, - "slider-width", &slider_width, + "slider-height", &slider_height, NULL); - min_height = slider_width * 0.6; - str = g_strdup_printf ("%s%s", C_("switch", "ON"), C_("switch", "OFF")); @@ -434,7 +433,7 @@ gtk_switch_get_preferred_height (GtkWidget *widget, layout = gtk_widget_create_pango_layout (widget, str); pango_layout_get_extents (layout, NULL, &logical_rect); pango_extents_to_pixels (&logical_rect, NULL); - height += MAX (min_height, logical_rect.height); + height += MAX (slider_height, logical_rect.height); g_object_unref (layout); g_free (str); @@ -929,6 +928,21 @@ gtk_switch_class_init (GtkSwitchClass *klass) DEFAULT_SLIDER_WIDTH, GTK_PARAM_READABLE)); + /** + * GtkSwitch:slider-height: + * + * The minimum height of the #GtkSwitch handle, in pixels. + * + * Since: 3.18 + */ + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("slider-height", + P_("Slider Height"), + P_("The minimum height of the handle"), + DEFAULT_SLIDER_HEIGHT, G_MAXINT, + DEFAULT_SLIDER_HEIGHT, + GTK_PARAM_READABLE)); + /** * GtkSwitch::activate: * @widget: the object which received the signal. diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss index 097f1cd2f1..e367672c41 100644 --- a/gtk/theme/Adwaita/_common.scss +++ b/gtk/theme/Adwaita/_common.scss @@ -1988,6 +1988,8 @@ column-header.button.dnd { // for treeview-like derive widgets GtkSwitch { -GtkSwitch-slider-width: 45px; // 55px is the right value to make it as tall // as buttons, not doing that for now + -GtkSwitch-slider-height: 27px; + font-weight: bold; font-size: smaller; outline-offset: -4px; diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css index 43a114e7e3..4e338bb2f0 100644 --- a/gtk/theme/Adwaita/gtk-contained-dark.css +++ b/gtk/theme/Adwaita/gtk-contained-dark.css @@ -2463,6 +2463,7 @@ column-header .titlebar .button.titlebutton, **********/ GtkSwitch { -GtkSwitch-slider-width: 45px; + -GtkSwitch-slider-height: 27px; font-weight: bold; font-size: smaller; outline-offset: -4px; diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css index 03311afb73..1d1a1076c5 100644 --- a/gtk/theme/Adwaita/gtk-contained.css +++ b/gtk/theme/Adwaita/gtk-contained.css @@ -2469,6 +2469,7 @@ column-header .titlebar .button.titlebutton, **********/ GtkSwitch { -GtkSwitch-slider-width: 45px; + -GtkSwitch-slider-height: 27px; font-weight: bold; font-size: smaller; outline-offset: -4px; diff --git a/gtk/theme/HighContrast/_common.scss b/gtk/theme/HighContrast/_common.scss index a5e86d0a6f..c7eef9d6be 100644 --- a/gtk/theme/HighContrast/_common.scss +++ b/gtk/theme/HighContrast/_common.scss @@ -1442,6 +1442,7 @@ GtkTreeView.view.progressbar { //Progressbar in treeview cells GtkSwitch { -GtkSwitch-slider-width: 47px; + -GtkSwitch-slider-height: 28px; font: bold condensed 9; outline-offset: -4px; &.trough { diff --git a/gtk/theme/HighContrast/gtk.css b/gtk/theme/HighContrast/gtk.css index e5093fd15a..534a2186dd 100644 --- a/gtk/theme/HighContrast/gtk.css +++ b/gtk/theme/HighContrast/gtk.css @@ -1629,6 +1629,7 @@ GtkTreeView.view.progressbar { **********/ GtkSwitch { -GtkSwitch-slider-width: 47px; + -GtkSwitch-slider-height: 28px; font: bold condensed 9; outline-offset: -4px; } GtkSwitch.trough {