[tepl] Tab: better pack info bars



commit 776b24328032768350912f70159d31edf2a85545
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun May 24 16:54:22 2020 +0200

    Tab: better pack info bars
    
    gtk_container_get_children() doesn't guarantee to return the children in
    the order that they were added.

 tepl/tepl-tab.c | 16 ++--------------
 tepl/tepl-tab.h |  6 ++----
 2 files changed, 4 insertions(+), 18 deletions(-)
---
diff --git a/tepl/tepl-tab.c b/tepl/tepl-tab.c
index ad8e860..a8eb9ea 100644
--- a/tepl/tepl-tab.c
+++ b/tepl/tepl-tab.c
@@ -124,25 +124,13 @@ static void
 tepl_tab_pack_info_bar_default (TeplTab    *tab,
                                GtkInfoBar *info_bar)
 {
-       GList *children;
-       GList *l;
        GtkWidget *sibling = NULL;
 
-       children = gtk_container_get_children (GTK_CONTAINER (tab));
-
-       for (l = children; l != NULL; l = l->next)
+       if (tab->priv->scrolled_window != NULL)
        {
-               GtkWidget *child = l->data;
-
-               if (!GTK_IS_INFO_BAR (child))
-               {
-                       sibling = child;
-                       break;
-               }
+               sibling = GTK_WIDGET (tab->priv->scrolled_window);
        }
 
-       g_list_free (children);
-
        if (sibling != NULL)
        {
                gtk_grid_insert_next_to (GTK_GRID (tab), sibling, GTK_POS_TOP);
diff --git a/tepl/tepl-tab.h b/tepl/tepl-tab.h
index 6bd4f9d..0dc9a8f 100644
--- a/tepl/tepl-tab.h
+++ b/tepl/tepl-tab.h
@@ -43,10 +43,8 @@ struct _TeplTab
  *   #GtkScrolledWindow and the #GtkScrolledWindow is added to the #TeplTab with
  *   gtk_container_add().
  * @pack_info_bar: Virtual function pointer to add a #GtkInfoBar in the #TeplTab
- *   container. By default the #GtkInfoBar is inserted above the first
- *   non-#GtkInfoBar child widget of #TeplTab (so by default it is inserted
- *   below other #GtkInfoBar's, but above the #GtkScrolledWindow containing the
- *   #TeplView).
+ *   container. By default the #GtkInfoBar is inserted just above the
+ *   #GtkScrolledWindow containing the #TeplView.
  * @pack_goto_line_bar: Virtual function pointer to add a #TeplGotoLineBar in
  *   the #TeplTab container. By default the #TeplGotoLineBar is added at the
  *   bottom.


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