[gtk/kill-containers: 166/199] shortcutswindow: Stop using container api



commit b44f5c0238643e72db42ad19645bc7f11bd5b232
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 9 21:02:56 2020 -0400

    shortcutswindow: Stop using container api

 gtk/gtkshortcutswindow.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index 93d3b40bff..68ce8b8c70 100644
--- a/gtk/gtkshortcutswindow.c
+++ b/gtk/gtkshortcutswindow.c
@@ -160,17 +160,21 @@ static GParamSpec *properties[LAST_PROP];
 static guint signals[LAST_SIGNAL];
 
 
-static gint
-number_of_children (GtkContainer *container)
+static gboolean
+more_than_three_children (GtkWidget *widget)
 {
-  GList *children;
-  gint n;
+  GtkWidget *child;
+  int i;
 
-  children = gtk_container_get_children (container);
-  n = g_list_length (children);
-  g_list_free (children);
+  for (child = gtk_widget_get_first_child (widget), i = 0;
+       child != NULL;
+       child = gtk_widget_get_next_sibling (child), i++)
+    {
+      if (i == 3)
+        return TRUE;
+    }
 
-  return n;
+  return FALSE;
 }
 
 static void
@@ -183,9 +187,9 @@ update_title_stack (GtkShortcutsWindow *self)
 
   if (GTK_IS_SHORTCUTS_SECTION (visible_child))
     {
-      if (number_of_children (GTK_CONTAINER (priv->stack)) > 3)
+      if (more_than_three_children (GTK_WIDGET (priv->stack)))
         {
-          gchar *title;
+          char *title;
 
           gtk_stack_set_visible_child_name (priv->title_stack, "sections");
           g_object_get (visible_child, "title", &title, NULL);
@@ -402,20 +406,18 @@ gtk_shortcuts_window_set_view_name (GtkShortcutsWindow *self,
                                     const gchar        *view_name)
 {
   GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
-  GList *sections, *l;
+  GtkWidget *section;
 
   g_free (priv->view_name);
   priv->view_name = g_strdup (view_name);
 
-  sections = gtk_container_get_children (GTK_CONTAINER (priv->stack));
-  for (l = sections; l; l = l->next)
+  for (section = gtk_widget_get_first_child (GTK_WIDGET (priv->stack));
+       section != NULL;
+       section = gtk_widget_get_next_sibling (section))
     {
-      GtkShortcutsSection *section = l->data;
-
       if (GTK_IS_SHORTCUTS_SECTION (section))
         g_object_set (section, "view-name", priv->view_name, NULL);
     }
-  g_list_free (sections);
 }
 
 static void


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