[gtk+] Gtk(Toggle)Button: preserve untouched state flags when updating state.



commit a0e1fa9e77a0082afda4b86d2f50f78c54a00ee7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jan 23 18:04:41 2011 +0100

    Gtk(Toggle)Button: preserve untouched state flags when updating state.
    
    Partly fixes bug #640282, noticed by Christian Persch. buttons were
    clobbering the insensitive flag when updating their state.

 gtk/gtkbutton.c       |    5 ++++-
 gtk/gtktogglebutton.c |    5 +++++
 2 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index baad6eb..d038b31 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -2298,7 +2298,7 @@ static void
 gtk_button_update_state (GtkButton *button)
 {
   GtkButtonPrivate *priv = button->priv;
-  GtkStateFlags new_state = 0;
+  GtkStateFlags new_state;
   gboolean depressed;
 
   if (priv->activate_timeout)
@@ -2306,6 +2306,9 @@ gtk_button_update_state (GtkButton *button)
   else
     depressed = priv->in_button && priv->button_down;
 
+  new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
+    ~(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE);
+
   if (priv->in_button)
     new_state |= GTK_STATE_FLAG_PRELIGHT;
 
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 43dbd49..a05d98a 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -563,6 +563,11 @@ gtk_toggle_button_update_state (GtkButton *button)
                 "gtk-touchscreen-mode", &touchscreen,
                 NULL);
 
+  new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
+    ~(GTK_STATE_FLAG_INCONSISTENT |
+      GTK_STATE_FLAG_PRELIGHT |
+      GTK_STATE_FLAG_ACTIVE);
+
   if (priv->inconsistent)
     new_state |= GTK_STATE_FLAG_INCONSISTENT;
 



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