[gtk+/wip/baedert/gtk-widget-destroy: 139/149] container: Add gtk_container_remove_callback



commit b948a53c372ecfb69e094464ed870a975497b9b5
Author: Timm Bäder <mail baedert org>
Date:   Tue Sep 26 07:39:27 2017 +0200

    container: Add gtk_container_remove_callback
    
    Which can be used as callback passed to gtk_container_forall.

 docs/reference/gtk/gtk4-sections.txt |    1 +
 gtk/gtkcontainer.c                   |   21 +++++++++++++++++++++
 gtk/gtkcontainer.h                   |    4 ++++
 3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index f88b3bf..c99c4f0 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -767,6 +767,7 @@ gtk_container_class_find_child_property
 gtk_container_class_install_child_property
 gtk_container_class_install_child_properties
 gtk_container_class_list_child_properties
+gtk_container_remove_callback
 
 <SUBSECTION Standard>
 GTK_CONTAINER
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 820af54..2fcd883 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -2945,3 +2945,24 @@ gtk_container_get_path_for_child (GtkContainer *container,
   return path;
 }
 
+/**
+ * gtk_container_remove_callback:
+ * @child: child widget of @container. Does not have to be a direct child.
+ * @container: The #GtkContainer to remove @child from.
+ *
+ * Removes @child from @container. This function can be used as a callback
+ * passed to gtk_container_forall().
+ *
+ * Note that this does explicitly *not* check that @child's parent is @container,
+ * but @child must have been added to @container using gtk_container_add, otherwise
+ * this function will fail.
+ */
+void
+gtk_container_remove_callback (GtkWidget    *child,
+                               GtkContainer *container)
+{
+  g_return_if_fail (GTK_IS_WIDGET (child));
+  g_return_if_fail (GTK_IS_CONTAINER (container));
+
+  gtk_container_remove (container, child);
+}
diff --git a/gtk/gtkcontainer.h b/gtk/gtkcontainer.h
index 6c99944..c0d6b08 100644
--- a/gtk/gtkcontainer.h
+++ b/gtk/gtkcontainer.h
@@ -242,6 +242,10 @@ GDK_AVAILABLE_IN_ALL
 GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer      *container,
                                                   GtkWidget         *child);
 
+GDK_AVAILABLE_IN_3_92
+void gtk_container_remove_callback (GtkWidget    *child,
+                                    GtkContainer *container);
+
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref)
 
 G_END_DECLS


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