[gtk+] Make gtk_box_set_center_widget take NULL



commit bb4f8d8ce1961c2d7cb10d198803b4cea6da7b03
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 18 21:16:35 2014 -0500

    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.

 gtk/gtkbox.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index 0620081..f67770b 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;
 }


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