[gtk/kill-containers: 13/45] stack: Add gtk_stack_remove



commit 29e713f7becf1ee3c49703cd03feed705a04c1e6
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 7 15:49:04 2020 -0400

    stack: Add gtk_stack_remove
    
    This is a replacement for gtk_container_remove.

 docs/reference/gtk/gtk4-sections.txt |  1 +
 gtk/gtkstack.c                       | 23 ++++++++++++++++-------
 gtk/gtkstack.h                       |  3 +++
 3 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index ddc5a983cf..52f8c2f043 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -5621,6 +5621,7 @@ GtkStack
 gtk_stack_new
 gtk_stack_add_named
 gtk_stack_add_titled
+gtk_stack_remove
 gtk_stack_get_child_by_name
 gtk_stack_get_page
 gtk_stack_get_pages
diff --git a/gtk/gtkstack.c b/gtk/gtkstack.c
index a0d8253edc..9feb4f8d0d 100644
--- a/gtk/gtkstack.c
+++ b/gtk/gtkstack.c
@@ -554,8 +554,6 @@ gtk_stack_pages_new (GtkStack *stack)
 
 static void     gtk_stack_add                            (GtkContainer  *widget,
                                                           GtkWidget     *child);
-static void     gtk_stack_remove                         (GtkContainer  *widget,
-                                                          GtkWidget     *child);
 static void     gtk_stack_forall                         (GtkContainer  *container,
                                                           GtkCallback    callback,
                                                           gpointer       callback_data);
@@ -1496,14 +1494,25 @@ stack_remove (GtkStack  *stack,
     gtk_widget_queue_resize (GTK_WIDGET (stack));
 }
 
-static void
-gtk_stack_remove (GtkContainer *container,
-                  GtkWidget    *child)
+/**
+ * gtk_stack_remove:
+ * @stack: a #GtkStack
+ * @child: the child to remove
+ *
+ * Removes a child widget from @stack.
+ */
+void
+gtk_stack_remove (GtkStack  *stack,
+                  GtkWidget *child)
 {
-  GtkStackPrivate *priv = gtk_stack_get_instance_private (GTK_STACK (container));
+  GtkStackPrivate *priv = gtk_stack_get_instance_private (stack);
   GList *l;
   guint position;
 
+  g_return_if_fail (GTK_IS_STACK (stack));
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (stack));
+
   for (l = priv->children, position = 0; l; l = l->next, position++)
     {
       GtkStackPage *page = l->data;
@@ -1511,7 +1520,7 @@ gtk_stack_remove (GtkContainer *container,
         break;
     }
 
-  stack_remove (GTK_STACK (container), child, FALSE);
+  stack_remove (stack, child, FALSE);
 
   if (priv->pages)
     g_list_model_items_changed (G_LIST_MODEL (priv->pages), position, 1, 0);
diff --git a/gtk/gtkstack.h b/gtk/gtkstack.h
index ad8b4cb697..23f22a6fb8 100644
--- a/gtk/gtkstack.h
+++ b/gtk/gtkstack.h
@@ -94,6 +94,9 @@ GtkStackPage *         gtk_stack_add_titled              (GtkStack
                                                           GtkWidget              *child,
                                                           const gchar            *name,
                                                           const gchar            *title);
+GDK_AVAILABLE_IN_ALL
+void                   gtk_stack_remove                  (GtkStack               *stack,
+                                                          GtkWidget              *child);
 
 GDK_AVAILABLE_IN_ALL
 GtkStackPage *         gtk_stack_get_page                (GtkStack               *stack,


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