[gtk+] switch: Use the right state when querying padding



commit 1f1c7547da93e785f5e19564a468e8a404e9bc9a
Author: Benjamin Otte <otte redhat com>
Date:   Thu Oct 22 18:42:56 2015 +0200

    switch: Use the right state when querying padding
    
    We were using the state of the widget node, not the state of the slider
    node.
    
    This caused layout loops due to invalidations.

 gtk/gtkswitch.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index 8aecb88..8969baa 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -250,7 +250,6 @@ gtk_switch_pan_gesture_pan (GtkGesturePan   *gesture,
   GtkWidget *widget = GTK_WIDGET (sw);
   GtkSwitchPrivate *priv = sw->priv;
   GtkStyleContext *context;
-  GtkStateFlags state;
   GtkBorder padding;
   gint width;
 
@@ -260,10 +259,9 @@ gtk_switch_pan_gesture_pan (GtkGesturePan   *gesture,
   gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
 
   gtk_style_context_save_to_node (context, priv->slider_node);
-  gtk_style_context_get_padding (context, state, &padding);
+  gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
   gtk_style_context_restore (context);
 
   width = gtk_widget_get_allocated_width (widget);
@@ -357,7 +355,6 @@ gtk_switch_get_preferred_width (GtkWidget *widget,
   GtkSwitch *self;
   GtkSwitchPrivate *priv;
   GtkStyleContext *context;
-  GtkStateFlags state;
   GtkBorder padding;
   gint width, slider_width;
   PangoLayout *layout;
@@ -366,10 +363,9 @@ gtk_switch_get_preferred_width (GtkWidget *widget,
   self = GTK_SWITCH (widget);
   priv = self->priv;
   context = gtk_widget_get_style_context (widget);
-  state = gtk_style_context_get_state (context);
 
   gtk_style_context_save_to_node (context, priv->slider_node);
-  gtk_style_context_get_padding (context, state, &padding);
+  gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
 
   width = padding.left + padding.right;
 
@@ -410,7 +406,6 @@ gtk_switch_get_preferred_height (GtkWidget *widget,
   GtkSwitch *self;
   GtkSwitchPrivate *priv;
   GtkStyleContext *context;
-  GtkStateFlags state;
   GtkBorder padding;
   gint height, slider_height;
   PangoLayout *layout;
@@ -420,11 +415,10 @@ gtk_switch_get_preferred_height (GtkWidget *widget,
   self = GTK_SWITCH (widget);
   priv = self->priv;
   context = gtk_widget_get_style_context (widget);
-  state = gtk_style_context_get_state (context);
 
   gtk_style_context_save_to_node (context, priv->slider_node);
 
-  gtk_style_context_get_padding (context, state, &padding);
+  gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
 
   height = padding.top + padding.bottom;
 
@@ -592,15 +586,13 @@ gtk_switch_draw (GtkWidget *widget,
   PangoRectangle rect;
   gint label_x, label_y;
   GtkBorder padding;
-  GtkStateFlags state;
   gint x, y, width, height;
 
   context = gtk_widget_get_style_context (widget);
-  state = gtk_widget_get_state_flags (widget);
 
   gtk_style_context_save_to_node (context, priv->slider_node);
 
-  gtk_style_context_get_padding (context, state, &padding);
+  gtk_style_context_get_padding (context, gtk_style_context_get_state (context), &padding);
 
   gtk_style_context_restore (context);
 


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