[gtk/wip/otte/listview: 12/24] DEBUG: Add debug prints to list item manager




commit 9436033175c1e9d104e499a77fcdfc608f389dff
Author: Benjamin Otte <otte redhat com>
Date:   Sat Feb 12 18:55:11 2022 +0100

    DEBUG: Add debug prints to list item manager

 gtk/gtklistitemmanager.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
---
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c
index a4e84733eb..21b549a4e7 100644
--- a/gtk/gtklistitemmanager.c
+++ b/gtk/gtklistitemmanager.c
@@ -77,6 +77,41 @@ static void             gtk_list_item_manager_release_list_item (GtkListItemMana
                                                                  GtkWidget              *widget);
 G_DEFINE_TYPE (GtkListItemManager, gtk_list_item_manager, G_TYPE_OBJECT)
 
+static void
+dump_items (GtkListItemManager *self)
+{
+  GtkListItemManagerItem *item;
+  guint position;
+  gboolean tracked;
+
+  item = gtk_rb_tree_get_first (self->items);
+  if (item == NULL)
+    {
+      g_print ("0\n");
+      return;
+    }
+
+  g_print ("0 %s ", item->widget ? "X" : "-");
+  tracked = !!item->widget;
+  position = item->n_items;
+
+  for (item = gtk_rb_tree_node_get_next (item);
+       item != NULL;
+       item = gtk_rb_tree_node_get_next (item))
+    {
+      if (item->n_items == 0)
+        continue;
+
+      if (!!item->widget != tracked)
+        {
+          tracked = !tracked;
+          g_print ("%u %s ", position, tracked ? "X" : "-");
+        }
+      position += item->n_items;
+    }
+  g_print ("%u\n", position);
+}
+
 void
 gtk_list_item_manager_augment_node (GtkRbTree *tree,
                                     gpointer   node_augment,
@@ -523,6 +558,7 @@ gtk_list_item_manager_release_items (GtkListItemManager *self,
   while (position < n_items)
     {
       gtk_list_item_query_tracked_range (self, n_items, position, &query_n_items, &tracked);
+      g_print ("tracked: %u => %u %s\n", position, position + query_n_items, tracked ? "X" : "-");
       if (tracked)
         {
           position += query_n_items;
@@ -544,6 +580,8 @@ gtk_list_item_manager_release_items (GtkListItemManager *self,
         }
       position += query_n_items;
     }
+
+  dump_items (self);
 }
 
 static void
@@ -646,6 +684,8 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
 
   while ((widget = g_queue_pop_head (&released)))
     gtk_list_item_manager_release_list_item (self, NULL, widget);
+
+  dump_items (self);
 }
 
 static void


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