[gtk+] button: Handle :checked in gtktogglebutton.c



commit cd349dcd48c9e71d81e56a0810d0f4f5cf5e9cd7
Author: Benjamin Otte <otte redhat com>
Date:   Fri Aug 15 16:58:39 2014 +0200

    button: Handle :checked in gtktogglebutton.c
    
    Don't try to handle it elsewhere.

 gtk/gtkcheckbutton.c  |    4 ----
 gtk/gtkradiobutton.c  |   11 -----------
 gtk/gtktogglebutton.c |   12 +++++++-----
 3 files changed, 7 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 89ce961..1221200 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -561,15 +561,11 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
 
   state &= ~(GTK_STATE_FLAG_INCONSISTENT |
              GTK_STATE_FLAG_ACTIVE |
-             GTK_STATE_FLAG_CHECKED |
              GTK_STATE_FLAG_PRELIGHT);
 
   if (gtk_toggle_button_get_inconsistent (toggle_button))
     state |= GTK_STATE_FLAG_INCONSISTENT;
   
-  if (gtk_toggle_button_get_active (toggle_button))
-    state |= GTK_STATE_FLAG_CHECKED;
-
   if (button->priv->activate_timeout || (button->priv->button_down && button->priv->in_button))
     state |= GTK_STATE_FLAG_ACTIVE;
 
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 131348a..e4a01a5 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -209,8 +209,6 @@ gtk_radio_button_init (GtkRadioButton *radio_button)
   _gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE);
 
   priv->group = g_slist_prepend (NULL, radio_button);
-
-  gtk_widget_set_state_flags (GTK_WIDGET (radio_button), GTK_STATE_FLAG_CHECKED, TRUE);
 }
 
 static void
@@ -815,11 +813,6 @@ gtk_radio_button_clicked (GtkButton *button)
 
   if (toggled)
     {
-      if (gtk_toggle_button_get_active (toggle_button))
-        gtk_widget_set_state_flags (GTK_WIDGET (button), GTK_STATE_FLAG_CHECKED, FALSE);
-      else
-        gtk_widget_unset_state_flags (GTK_WIDGET (button), GTK_STATE_FLAG_CHECKED);
-
       gtk_toggle_button_toggled (toggle_button);
 
       g_object_notify (G_OBJECT (toggle_button), "active");
@@ -866,15 +859,11 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
 
   state &= ~(GTK_STATE_FLAG_INCONSISTENT |
              GTK_STATE_FLAG_ACTIVE |
-             GTK_STATE_FLAG_CHECKED |
              GTK_STATE_FLAG_PRELIGHT);
 
   if (gtk_toggle_button_get_inconsistent (toggle_button))
     state |= GTK_STATE_FLAG_INCONSISTENT;
   
-  if (gtk_toggle_button_get_active (toggle_button))
-    state |= GTK_STATE_FLAG_CHECKED;
-
   if (button->priv->activate_timeout ||
       (button->priv->button_down && button->priv->in_button))
     state |= GTK_STATE_FLAG_ACTIVE;
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index cca85e9..ba97368 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -487,6 +487,12 @@ _gtk_toggle_button_set_active (GtkToggleButton *toggle_button,
                                gboolean         is_active)
 {
   toggle_button->priv->active = is_active;
+
+  if (is_active)
+    gtk_widget_set_state_flags (GTK_WIDGET (toggle_button), GTK_STATE_FLAG_CHECKED, FALSE);
+  else
+    gtk_widget_unset_state_flags (GTK_WIDGET (toggle_button), GTK_STATE_FLAG_CHECKED);
+
 }
 
 /**
@@ -624,7 +630,7 @@ gtk_toggle_button_clicked (GtkButton *button)
   GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button);
   GtkToggleButtonPrivate *priv = toggle_button->priv;
 
-  priv->active = !priv->active;
+  _gtk_toggle_button_set_active (toggle_button, !priv->active);
 
   gtk_toggle_button_toggled (toggle_button);
 
@@ -653,15 +659,11 @@ gtk_toggle_button_update_state (GtkButton *button)
   new_state = gtk_widget_get_state_flags (GTK_WIDGET (button)) &
     ~(GTK_STATE_FLAG_INCONSISTENT |
       GTK_STATE_FLAG_PRELIGHT |
-      GTK_STATE_FLAG_CHECKED |
       GTK_STATE_FLAG_ACTIVE);
 
   if (priv->inconsistent)
     new_state |= GTK_STATE_FLAG_INCONSISTENT;
   
-  if (priv->active)
-    new_state |= GTK_STATE_FLAG_CHECKED;
-
   if (button->priv->in_button && button->priv->button_down)
     new_state |= GTK_STATE_FLAG_ACTIVE;
 


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