[gtk+/parasite2] inspector: Show interfaces in the object hierarchy



commit 9b75d03cc1c001603111e2e8fc60635d58b1df90
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 8 01:59:37 2014 -0400

    inspector: Show interfaces in the object hierarchy
    
    This gives a more complete picture.

 modules/inspector/object-hierarchy.c |   35 +++++++++++++++++++++++++++------
 1 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/modules/inspector/object-hierarchy.c b/modules/inspector/object-hierarchy.c
index 71af2bf..50ce6b2 100644
--- a/modules/inspector/object-hierarchy.c
+++ b/modules/inspector/object-hierarchy.c
@@ -62,21 +62,42 @@ void
 gtk_inspector_object_hierarchy_set_object (GtkInspectorObjectHierarchy *oh,
                                            GObject                     *object)
 {
-  GObjectClass *klass = G_OBJECT_GET_CLASS (object);
+  GType type;
   const gchar *class_name;
   GtkTreeIter iter, parent;
-  GSList *list = NULL, *l;
+  GList *list = NULL, *l;
+  GHashTable *interfaces;
+  GHashTableIter hit;
+  GType *ifaces;
+  gint i;
 
   gtk_tree_store_clear (oh->priv->model);
 
+  interfaces = g_hash_table_new (g_str_hash, g_str_equal);
+  type = ((GTypeInstance*)object)->g_class->g_type;
+  
   do
     {
-      class_name = G_OBJECT_CLASS_NAME (klass);
-      list = g_slist_append (list, (gpointer)class_name);
+      class_name = g_type_name (type);
+      list = g_list_append (list, (gpointer)class_name);
+      ifaces = g_type_interfaces (type, NULL);
+      for (i = 0; ifaces[i]; i++)
+        g_hash_table_add (interfaces, (gchar *)g_type_name (ifaces[i]));
+      g_free (ifaces);
     }
-  while ((klass = g_type_class_peek_parent (klass)));
-  list = g_slist_reverse (list);
+  while ((type = g_type_parent (type)));
 
+  g_hash_table_iter_init (&hit, interfaces);
+  while (g_hash_table_iter_next (&hit, (gpointer *)&class_name, NULL))
+    {
+      gtk_tree_store_append (oh->priv->model, &iter, NULL);
+      gtk_tree_store_set (oh->priv->model, &iter,
+                          COLUMN_OBJECT_NAME, class_name,
+                          -1);
+    }
+  g_hash_table_unref (interfaces);
+
+  list = g_list_reverse (list);
   for (l = list; l; l = l->next)
     {
       gtk_tree_store_append (oh->priv->model, &iter, l == list ? NULL : &parent);
@@ -86,7 +107,7 @@ gtk_inspector_object_hierarchy_set_object (GtkInspectorObjectHierarchy *oh,
       parent = iter;
     }
 
-  g_slist_free (list);
+  g_list_free (list);
 
   gtk_tree_view_expand_all (oh->priv->tree);
   gtk_tree_selection_select_iter (gtk_tree_view_get_selection (oh->priv->tree), &iter);


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