diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-02-18 21:16:35 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-02-18 22:50:37 -0500 |
commit | bb4f8d8ce1961c2d7cb10d198803b4cea6da7b03 (patch) | |
tree | dc31335b0f7e1b0db634e27945a420da1ffafa41 /gtk/gtkbox.c | |
parent | 5eaebde394ba755b1f614c7d0e7c5513cf531493 (diff) | |
download | gtk+-bb4f8d8ce1961c2d7cb10d198803b4cea6da7b03.tar.gz |
Make gtk_box_set_center_widget take NULL
It makes sense to allow this, and gtk_action_bar_set_center_widget
already assumes that it can pass NULL to this function.
Diffstat (limited to 'gtk/gtkbox.c')
-rw-r--r-- | gtk/gtkbox.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index 062008130f..f67770b38c 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -2585,7 +2585,7 @@ _gtk_box_get_children (GtkBox *box) /** * gtk_box_set_center_widget: * @box: a #GtkBox - * @widget: the widget to center + * @widget: (allow-none): the widget to center * * Sets a center widget; that is a child widget that will be * centered with respect to the full width of the box, even @@ -2598,11 +2598,14 @@ void gtk_box_set_center_widget (GtkBox *box, GtkWidget *widget) { + GtkBoxPrivate *priv = box->priv; + g_return_if_fail (GTK_IS_BOX (box)); - box->priv->center = gtk_box_pack (box, widget, - FALSE, TRUE, 0, - GTK_PACK_START); + if (widget) + priv->center = gtk_box_pack (box, widget, FALSE, TRUE, 0, GTK_PACK_START); + else if (priv->center) + gtk_box_remove (GTK_CONTAINER (box), priv->center->widget); } /** @@ -2618,10 +2621,12 @@ gtk_box_set_center_widget (GtkBox *box, GtkWidget * gtk_box_get_center_widget (GtkBox *box) { + GtkBoxPrivate *priv = box->priv; + g_return_val_if_fail (GTK_IS_BOX (box), NULL); - if (box->priv->center) - return box->priv->center->widget; + if (priv->center) + return priv->center->widget; return NULL; } |