]> Pileus Git - ~andy/gtk/commitdiff
Make "button" class depend on mode for GtkToggleButtons
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 19 Nov 2010 18:56:25 +0000 (19:56 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Sat, 4 Dec 2010 14:39:20 +0000 (15:39 +0100)
gtk/gtkcheckbutton.c
gtk/gtktogglebutton.c

index 358406099bc841ad116b0f1224ae0d221cc6b8f7..a27290432e3aabb90fc3830d0dbeb53749253233 100644 (file)
@@ -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*
index 4fbaad5622e36bec1b604a3acffaf70617e34861..9f67cf7e91c616ad4685ff4e82160d40883759e2 100644 (file)
@@ -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);
     }
 }