[gtk/kill-containers: 38/55] headerbar: Add gtk_header_bar_remove



commit d59d9d4bd57d1a83d9db2fa92e108a0004a4cf13
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 8 09:19:21 2020 -0400

    headerbar: Add gtk_header_bar_remove
    
    This is a replacement for gtk_container_remove.

 docs/reference/gtk/gtk4-sections.txt |  1 +
 gtk/gtkheaderbar.c                   | 27 +++++++++++++++++----------
 gtk/gtkheaderbar.h                   |  3 +++
 3 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index aec527c5ba..c300fd207e 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -5597,6 +5597,7 @@ gtk_header_bar_set_title_widget
 gtk_header_bar_get_title_widget
 gtk_header_bar_pack_start
 gtk_header_bar_pack_end
+gtk_header_bar_remove
 gtk_header_bar_set_show_title_buttons
 gtk_header_bar_get_show_title_buttons
 gtk_header_bar_set_decoration_layout
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index eee669e2c8..208415c701 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -495,31 +495,38 @@ gtk_header_bar_add (GtkContainer *container,
   gtk_header_bar_pack (GTK_HEADER_BAR (container), child, GTK_PACK_START);
 }
 
-static void
-gtk_header_bar_remove (GtkContainer *container,
-                       GtkWidget    *widget)
+/**
+ * gtk_header_bar_remove:
+ * @bar: a #GtkHeaderBar
+ * @child: the child to remove
+ *
+ * Removes a child from @bar, after it has been added
+ * with gtk_header_bar_pack_start(), gtk_header_bar_pack_end()
+ * or gtk_header_bar_set_title_widget().
+ */
+void
+gtk_header_bar_remove (GtkHeaderBar *bar,
+                       GtkWidget    *child)
 {
-  GtkHeaderBar *bar = GTK_HEADER_BAR (container);
   GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
   GtkWidget *parent;
   gboolean removed = FALSE;
 
-  parent = gtk_widget_get_parent (widget);
+  parent = gtk_widget_get_parent (child);
 
   if (parent == priv->start_box)
     {
-      gtk_container_remove (GTK_CONTAINER (priv->start_box), widget);
+      gtk_container_remove (GTK_CONTAINER (priv->start_box), child);
       removed = TRUE;
     }
   else if (parent == priv->end_box)
     {
-      gtk_container_remove (GTK_CONTAINER (priv->end_box), widget);
+      gtk_container_remove (GTK_CONTAINER (priv->end_box), child);
       removed = TRUE;
     }
-  else if (parent == GTK_WIDGET (container) &&
-           gtk_center_box_get_center_widget (GTK_CENTER_BOX (priv->center_box)) == widget)
+  else if (parent == priv->center_box)
     {
-      gtk_widget_unparent (widget);
+      gtk_center_box_set_center_widget (GTK_CENTER_BOX (priv->center_box), NULL);
       removed = TRUE;
     }
 
diff --git a/gtk/gtkheaderbar.h b/gtk/gtkheaderbar.h
index 23334c5469..0bbd591759 100644
--- a/gtk/gtkheaderbar.h
+++ b/gtk/gtkheaderbar.h
@@ -50,6 +50,9 @@ void         gtk_header_bar_pack_start        (GtkHeaderBar *bar,
 GDK_AVAILABLE_IN_ALL
 void         gtk_header_bar_pack_end          (GtkHeaderBar *bar,
                                                GtkWidget    *child);
+GDK_AVAILABLE_IN_ALL
+void         gtk_header_bar_remove            (GtkHeaderBar *bar,
+                                               GtkWidget    *child);
 
 GDK_AVAILABLE_IN_ALL
 gboolean     gtk_header_bar_get_show_title_buttons (GtkHeaderBar *bar);


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