[gtk+] overlay: Keep the main child at the bottom



commit c3176ed302471af5db9e2369d1bab12b200602ab
Author: Timm Bäder <mail baedert org>
Date:   Thu Jul 20 12:33:57 2017 +0200

    overlay: Keep the main child at the bottom
    
    Since gtk_bin_add does a gtk_widget_set_parent call, we cannot use it in
    a GtkBin implementation that has multiple child widgets and cares about
    their order.

 gtk/gtkoverlay.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c
index 71dfd2d..3e1de96 100644
--- a/gtk/gtkoverlay.c
+++ b/gtk/gtkoverlay.c
@@ -336,6 +336,19 @@ gtk_overlay_get_child_position (GtkOverlay    *overlay,
 }
 
 static void
+gtk_overlay_add (GtkContainer *container,
+                 GtkWidget    *widget)
+{
+
+  /* We only get into this path if we have no child
+   * (since GtkOverlay is a GtkBin) and the only child
+   * we can add through gtk_container_add is the main child,
+   * which we want to keep the lowest in the hierarchy. */
+  gtk_widget_insert_after (widget, GTK_WIDGET (container), NULL);
+  _gtk_bin_set_child (GTK_BIN (container), widget);
+}
+
+static void
 gtk_overlay_remove (GtkContainer *container,
                     GtkWidget    *widget)
 {
@@ -596,6 +609,7 @@ gtk_overlay_class_init (GtkOverlayClass *klass)
 
   widget_class->size_allocate = gtk_overlay_size_allocate;
 
+  container_class->add = gtk_overlay_add;
   container_class->remove = gtk_overlay_remove;
   container_class->forall = gtk_overlay_forall;
   container_class->set_child_property = gtk_overlay_set_child_property;


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