summaryrefslogtreecommitdiff
path: root/gtk/gtktogglebutton.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-10-30 00:27:13 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-10-30 00:40:50 -0400
commitc631656f0ca4e13c7a262ed076bc7eda52fe03a1 (patch)
tree6843367057510705ea4234a4b1d8fae371d8b3a2 /gtk/gtktogglebutton.c
parent826633b5b7a53aeed47b75455ecac1648f5ba027 (diff)
downloadgtk+-c631656f0ca4e13c7a262ed076bc7eda52fe03a1.tar.gz
toggle button: Convert to css nodes
Convert GtkToggleButton and its subclasses to CSS nodes. Keep the button element name for when we want to render these button-like (but with .toggle, .check and .radio style classes for differentiation). When we want to render them with an indicator, use distinct element names checkbutton and radiobutton, and add a subnode for the indicator with name check or radio.
Diffstat (limited to 'gtk/gtktogglebutton.c')
-rw-r--r--gtk/gtktogglebutton.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index c4ac1d4630..cc73223fa8 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -59,6 +59,11 @@
*
* To simply switch the state of a toggle button, use gtk_toggle_button_toggled().
*
+ * # CSS nodes
+ *
+ * GtkToggleButton has a single CSS node with name button. To differentiate
+ * it from a plain #GtkButton, it gets the .toggle style class.
+ *
* ## Creating two #GtkToggleButton widgets.
*
* |[<!-- language="C" -->
@@ -215,6 +220,7 @@ gtk_toggle_button_class_init (GtkToggleButtonClass *class)
G_TYPE_NONE, 0);
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_TOGGLE_BUTTON_ACCESSIBLE);
+ gtk_widget_class_set_css_name (widget_class, "button");
}
static void
@@ -413,24 +419,12 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button,
if (priv->draw_indicator != draw_indicator)
{
- GtkStyleContext *context;
-
priv->draw_indicator = draw_indicator;
if (gtk_widget_get_visible (GTK_WIDGET (toggle_button)))
gtk_widget_queue_resize (GTK_WIDGET (toggle_button));
g_object_notify_by_pspec (G_OBJECT (toggle_button), toggle_button_props[PROP_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);
}
}