[gtk+/gtk-style-context: 414/533] Make "button" class depend on mode for GtkToggleButtons
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-style-context: 414/533] Make "button" class depend on mode for GtkToggleButtons
- Date: Wed, 1 Dec 2010 02:40:37 +0000 (UTC)
commit e1c684306c9b8305f592c49591a45c846f0c4623
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]