[gtk/wip/exalm/buttons: 28/32] button: Reset style classes when setting arbitrary children
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/exalm/buttons: 28/32] button: Reset style classes when setting arbitrary children
- Date: Thu, 24 Jun 2021 18:14:03 +0000 (UTC)
commit f3befe530b38f1ff9da111ca2385c2f31a7c4f38
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Jun 21 13:59:28 2021 +0500
button: Reset style classes when setting arbitrary children
Don't leave leftover .image-button or .text-button.
gtk/gtkbutton.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 295fd83119..2638539d7f 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -407,6 +407,16 @@ gtk_button_set_child_type (GtkButton *button, guint child_type)
if (priv->child_type == child_type)
return;
+ if (child_type == LABEL_CHILD)
+ gtk_widget_add_css_class (GTK_WIDGET (button), "text-button");
+ else
+ gtk_widget_remove_css_class (GTK_WIDGET (button), "text-button");
+
+ if (child_type == ICON_CHILD)
+ gtk_widget_add_css_class (GTK_WIDGET (button), "image-button");
+ else
+ gtk_widget_remove_css_class (GTK_WIDGET (button), "image-button");
+
if (child_type != LABEL_CHILD)
g_object_notify_by_pspec (G_OBJECT (button), props[PROP_LABEL]);
else if (child_type != ICON_CHILD)
@@ -835,8 +845,6 @@ gtk_button_set_label (GtkButton *button,
gtk_label_set_xalign (GTK_LABEL (child), 0.0);
gtk_button_set_child (button, child);
- gtk_widget_remove_css_class (GTK_WIDGET (button), "image-button");
- gtk_widget_add_css_class (GTK_WIDGET (button), "text-button");
}
gtk_label_set_label (GTK_LABEL (priv->child), label);
@@ -966,8 +974,6 @@ gtk_button_set_icon_name (GtkButton *button,
NULL);
gtk_button_set_child (GTK_BUTTON (button), child);
gtk_widget_set_valign (child, GTK_ALIGN_CENTER);
- gtk_widget_remove_css_class (GTK_WIDGET (button), "text-button");
- gtk_widget_add_css_class (GTK_WIDGET (button), "image-button");
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]