[gtk/bin-removal: 38/44] Add gtk_overlay_remove_overlay



commit 3088c29b7b6cb636ec68689e3fb523057111fc31
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun May 3 10:51:49 2020 -0400

    Add gtk_overlay_remove_overlay
    
    Now that GtkOverlay is not a container anymore,
    gtk_container_remove can't be used for this anymore,
    so add a separate api.

 docs/reference/gtk/gtk4-sections.txt |  1 +
 gtk/gtkoverlay.c                     | 20 ++++++++++++++++++++
 gtk/gtkoverlay.h                     |  3 +++
 3 files changed, 24 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 112bb9c65c..862d499c15 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -5485,6 +5485,7 @@ gtk_overlay_new
 gtk_overlay_set_child
 gtk_overlay_get_child
 gtk_overlay_add_overlay
+gtk_overlay_remove_overlay
 gtk_overlay_get_measure_overlay
 gtk_overlay_set_measure_overlay
 gtk_overlay_get_clip_overlay
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index 7791488814..22943750ae 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -433,10 +433,30 @@ gtk_overlay_add_overlay (GtkOverlay *overlay,
 {
   g_return_if_fail (GTK_IS_OVERLAY (overlay));
   g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (widget != overlay->child);
 
   gtk_widget_insert_before (widget, GTK_WIDGET (overlay), NULL);
 }
 
+/**
+ * gtk_overlay_remove_overlay:
+ * @overlay: a #GtkOverlay
+ * @widget: a #GtkWidget to be removed
+ *
+ * Removes an overlay that was added with gtk_overlay_add_overlay().
+ */
+void
+gtk_overlay_remove_overlay (GtkOverlay *overlay,
+                            GtkWidget  *widget)
+{
+  g_return_if_fail (GTK_IS_OVERLAY (overlay));
+  g_return_if_fail (GTK_IS_WIDGET (widget));
+  g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (overlay));
+  g_return_if_fail (widget != overlay->child);
+
+  gtk_widget_unparent (widget);
+}
+
 /**
  * gtk_overlay_set_measure_overlay:
  * @overlay: a #GtkOverlay
diff --git a/gtk/gtkoverlay.h b/gtk/gtkoverlay.h
index 65b0412b36..bfe37100a7 100644
--- a/gtk/gtkoverlay.h
+++ b/gtk/gtkoverlay.h
@@ -42,6 +42,9 @@ GtkWidget *gtk_overlay_new         (void);
 GDK_AVAILABLE_IN_ALL
 void       gtk_overlay_add_overlay (GtkOverlay *overlay,
                                     GtkWidget  *widget);
+GDK_AVAILABLE_IN_ALL
+void       gtk_overlay_remove_overlay (GtkOverlay *overlay,
+                                       GtkWidget  *widget);
 
 GDK_AVAILABLE_IN_ALL
 void                  gtk_overlay_set_child (GtkOverlay *overlay,


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