summaryrefslogtreecommitdiff
path: root/gtk/gtkswitch.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2011-03-17 18:27:03 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2011-03-18 09:52:58 -0400
commit55c86bd44df95c926dd8f4277c9ce70e8872af75 (patch)
tree96e74b70848715480585ab22a413330da61c873a /gtk/gtkswitch.c
parent6e1aa0e0a9e66aec48db808453117fd36a423efd (diff)
downloadgtk+-55c86bd44df95c926dd8f4277c9ce70e8872af75.tar.gz
switch: fix boundaries for the switch motion
We were ignoring the focus ring padding, and we were incorrectly setting handle_x to padding.left, while the draw handler already takes padding into account while redrawing. https://bugzilla.gnome.org/show_bug.cgi?id=645134
Diffstat (limited to 'gtk/gtkswitch.c')
-rw-r--r--gtk/gtkswitch.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index d6a6ea76b2..b33a16825c 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -162,17 +162,30 @@ gtk_switch_motion (GtkWidget *widget,
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
+ gint width, focus_width, focus_pad;
+
+ gtk_widget_style_get (widget,
+ "focus-line-width", &focus_width,
+ "focus-padding", &focus_pad,
+ NULL);
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
gtk_style_context_get_padding (context, state, &padding);
+ gtk_style_context_restore (context);
+
gtk_widget_get_allocation (widget, &allocation);
+ width = allocation.width - 2 * (focus_width + focus_pad);
+
/* constrain the handle within the trough width */
- if (position > (allocation.width / 2 - padding.right))
- priv->handle_x = allocation.width / 2 - padding.right;
+ if (position > (width / 2) - padding.right)
+ priv->handle_x = width / 2 - padding.right;
else if (position < padding.left)
- priv->handle_x = padding.left;
+ priv->handle_x = 0;
else
priv->handle_x = position;