[sysprof/wip/gtk4-port: 54/125] visualizergroup: port to GTK 4




commit f8771736262f0750a25e77702bad67d923e5e8c8
Author: Christian Hergert <chergert redhat com>
Date:   Thu Sep 30 19:16:01 2021 -0700

    visualizergroup: port to GTK 4

 src/libsysprof-ui/sysprof-visualizer-group.c | 38 +++++++++++++---------------
 1 file changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-visualizer-group.c b/src/libsysprof-ui/sysprof-visualizer-group.c
index 45d15314..fe789d1d 100644
--- a/src/libsysprof-ui/sysprof-visualizer-group.c
+++ b/src/libsysprof-ui/sysprof-visualizer-group.c
@@ -312,7 +312,7 @@ sysprof_visualizer_group_init (SysprofVisualizerGroup *self)
                                     "orientation", GTK_ORIENTATION_VERTICAL,
                                     "visible", TRUE,
                                     NULL);
-  gtk_container_add (GTK_CONTAINER (self), GTK_WIDGET (priv->visualizers));
+  gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (self), GTK_WIDGET (priv->visualizers));
 }
 
 void
@@ -328,7 +328,6 @@ _sysprof_visualizer_group_set_header (SysprofVisualizerGroup       *self,
     {
       if (header != NULL)
         {
-          GList *children;
           guint position = 0;
 
           gtk_widget_insert_action_group (GTK_WIDGET (header),
@@ -336,11 +335,11 @@ _sysprof_visualizer_group_set_header (SysprofVisualizerGroup       *self,
                                           G_ACTION_GROUP (priv->actions));
           gtk_size_group_add_widget (priv->size_group, GTK_WIDGET (header));
 
-          children = gtk_container_get_children (GTK_CONTAINER (priv->visualizers));
-
-          for (const GList *iter = children; iter; iter = iter->next)
+          for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (priv->visualizers));
+               child;
+               child = gtk_widget_get_next_sibling (child))
             {
-              SysprofVisualizer *vis = iter->data;
+              SysprofVisualizer *vis = SYSPROF_VISUALIZER (child);
               const gchar *title;
               GMenuModel *menu = NULL;
 
@@ -362,19 +361,10 @@ _sysprof_visualizer_group_set_header (SysprofVisualizerGroup       *self,
 
               position++;
             }
-
-          g_list_free (children);
         }
     }
 }
 
-static void
-sysprof_visualizer_group_set_reader_cb (SysprofVisualizer    *visualizer,
-                                        SysprofCaptureReader *reader)
-{
-  sysprof_visualizer_set_reader (visualizer, reader);
-}
-
 void
 _sysprof_visualizer_group_set_reader (SysprofVisualizerGroup *self,
                                       SysprofCaptureReader   *reader)
@@ -384,9 +374,10 @@ _sysprof_visualizer_group_set_reader (SysprofVisualizerGroup *self,
   g_return_if_fail (SYSPROF_IS_VISUALIZER_GROUP (self));
   g_return_if_fail (reader != NULL);
 
-  gtk_container_foreach (GTK_CONTAINER (priv->visualizers),
-                         (GtkCallback) sysprof_visualizer_group_set_reader_cb,
-                         reader);
+  for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (priv->visualizers));
+       child;
+       child = gtk_widget_get_next_sibling (child))
+    sysprof_visualizer_set_reader (SYSPROF_VISUALIZER (child), reader);
 }
 
 void
@@ -396,13 +387,18 @@ sysprof_visualizer_group_insert (SysprofVisualizerGroup *self,
                                  gboolean                can_toggle)
 {
   SysprofVisualizerGroupPrivate *priv = sysprof_visualizer_group_get_instance_private (self);
+  GtkWidget *sibling = NULL;
 
   g_return_if_fail (SYSPROF_IS_VISUALIZER_GROUP (self));
   g_return_if_fail (SYSPROF_IS_VISUALIZER (visualizer));
 
-  gtk_container_add_with_properties (GTK_CONTAINER (priv->visualizers), GTK_WIDGET (visualizer),
-                                     "position", position,
-                                     NULL);
+  sibling = gtk_widget_get_first_child (GTK_WIDGET (priv->visualizers));
+  while (position > 1 && sibling)
+    {
+      sibling = gtk_widget_get_next_sibling (sibling);
+      position--;
+    }
+  gtk_box_insert_child_after (priv->visualizers, GTK_WIDGET (visualizer), sibling);
 
   if (can_toggle)
     {


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