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.
This commit is contained in:
Matthias Clasen
2020-05-05 22:59:43 -04:00
parent 73df127928
commit 64591e0fbd

View File

@@ -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;