[gtk+/gtk-style-context: 414/540] Make "button" class depend on mode for GtkToggleButtons



commit 763e82fa2d5177d0653bf0c6bf57bac117a3f753
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Nov 19 19:56:25 2010 +0100

    Make "button" class depend on mode for GtkToggleButtons

 gtk/gtkcheckbutton.c  |    9 ---------
 gtk/gtktogglebutton.c |   12 ++++++++++++
 2 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 3584060..a272904 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -93,18 +93,9 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
 static void
 gtk_check_button_init (GtkCheckButton *check_button)
 {
-  GtkStyleContext *context;
-
   gtk_widget_set_has_window (GTK_WIDGET (check_button), FALSE);
   gtk_widget_set_receives_default (GTK_WIDGET (check_button), FALSE);
   gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (check_button), TRUE);
-
-  /* Remove the "button" class added in GtkButton constructor,
-   * since this widget implementation doesn't look like a button
-   * at all.
-   */
-  context = gtk_widget_get_style_context (GTK_WIDGET (check_button));
-  gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BUTTON);
 }
 
 GtkWidget*
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 4fbaad5..9f67cf7 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -329,6 +329,8 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
 
   if (priv->draw_indicator != draw_indicator)
     {
+      GtkStyleContext *context;
+
       priv->draw_indicator = draw_indicator;
       GTK_BUTTON (toggle_button)->priv->depress_on_activate = !draw_indicator;
 
@@ -336,6 +338,16 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
 	gtk_widget_queue_resize (GTK_WIDGET (toggle_button));
 
       g_object_notify (G_OBJECT (toggle_button), "draw-indicator");
+
+      /* Make toggle buttons conditionally have the "button"
+       * class depending on draw_indicator.
+       */
+      context = gtk_widget_get_style_context (GTK_WIDGET (toggle_button));
+
+      if (draw_indicator)
+        gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BUTTON);
+      else
+        gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON);
     }
 }
 



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