Add debug code
authorMatthias Clasen <mclasen@redhat.com>
Mon, 28 Nov 2011 15:22:25 +0000 (10:22 -0500)
committerRyan Lortie <desrt@desrt.ca>
Thu, 8 Dec 2011 23:05:13 +0000 (18:05 -0500)
This adds a dump method to show the entire tree of proxies.

gio/gmenuproxy.c

index 9de0c55..4eb0dbb 100644 (file)
@@ -854,5 +854,42 @@ g_menu_proxy_get (GDBusConnection *connection,
   return proxy;
 }
 
+static void
+dump_proxy (gpointer key, gpointer value, gpointer data)
+{
+  GMenuProxy *proxy = value;
+
+  g_print ("    menu %d refcount %d active %d\n",
+           proxy->id, G_OBJECT (proxy)->ref_count, proxy->active);
+}
+
+static void
+dump_group (gpointer key, gpointer value, gpointer data)
+{
+  GMenuProxyGroup *group = value;
+
+  g_print ("  group %d refcount %d state %d active %d\n",
+           group->id, group->ref_count, group->state, group->active);
+
+  g_hash_table_foreach (group->proxies, dump_proxy, NULL);
+}
+
+static void
+dump_path (gpointer key, gpointer value, gpointer data)
+{
+  PathIdentifier *pid = key;
+  GMenuProxyPath *path = value;
+
+  g_print ("%s active %d\n", pid->object_path, path->active);
+  g_hash_table_foreach (path->groups, dump_group, NULL);
+}
+
+void
+g_menu_proxy_dump (void)
+{
+  g_hash_table_foreach (g_menu_proxy_paths, dump_path, NULL);
+}
+
+
 /* Epilogue {{{1 */
 /* vim:set foldmethod=marker: */