[gtk/box-layout-child-expand] checkbutton: Make the child expand



commit 64591e0fbd57dd7e00caabe2f6b65367ca541034
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue May 5 22:59:43 2020 -0400

    checkbutton: Make the child expand
    
    This is the proper behavior for check buttons -
    the indicator is fixed size, and the child takes
    all the remaining space.

 gtk/gtkcheckbutton.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 0704a8fdfa..72a51bc737 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -171,6 +171,30 @@ gtk_check_button_get_property (GObject      *object,
     }
 }
 
+static void
+gtk_check_button_notify (GObject    *object,
+                         GParamSpec *pspec)
+{
+  if (strcmp (pspec->name, "child") == 0)
+    {
+      GtkWidget *child;
+
+      child = gtk_button_get_child (GTK_BUTTON (object));
+      if (child)
+        {
+          GtkLayoutManager *layout;
+          GtkLayoutChild *layout_child;
+
+          layout = gtk_widget_get_layout_manager (GTK_WIDGET (object));
+          layout_child = gtk_layout_manager_get_layout_child (layout, child);
+          gtk_box_layout_child_set_expand (GTK_BOX_LAYOUT_CHILD (layout_child), TRUE);
+        }
+    }
+
+  if (G_OBJECT_CLASS (gtk_check_button_parent_class)->notify)
+    G_OBJECT_CLASS (gtk_check_button_parent_class)->notify (object, pspec);
+}
+
 static void
 gtk_check_button_class_init (GtkCheckButtonClass *class)
 {
@@ -180,6 +204,7 @@ gtk_check_button_class_init (GtkCheckButtonClass *class)
   object_class->finalize = gtk_check_button_finalize;
   object_class->set_property = gtk_check_button_set_property;
   object_class->get_property = gtk_check_button_get_property;
+  object_class->notify = gtk_check_button_notify;
 
   widget_class->state_flags_changed = gtk_check_button_state_flags_changed;
 


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