diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index ee2e2b37b5..123ec712e1 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 6d4962dbb6..b5c0d0d169 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 f24365c8a4..23216f24f7 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,