#include "fallback-c89.c"
#define DEFAULT_SLIDER_WIDTH (36)
+#define DEFAULT_SLIDER_HEIGHT (22)
struct _GtkSwitchPrivate
{
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
- gint height, slider_width, min_height;
+ gint height, slider_height;
PangoLayout *layout;
PangoRectangle logical_rect;
gchar *str;
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"));
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);
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.