[sysprof/newui: 14/24] Descendants line



commit 6f135a3b63c611fb7f56e4efd811a2879c6a5c87
Author: SÃren Sandmann Pedersen <sandmann daimi au dk>
Date:   Wed Nov 10 01:34:24 2010 -0500

    Descendants line

 sysprof.c       |   44 +++++++++++++++++++++++++++++---------------
 treeviewutils.c |    9 ++++++---
 2 files changed, 35 insertions(+), 18 deletions(-)
---
diff --git a/sysprof.c b/sysprof.c
index a76b255..a009ec9 100644
--- a/sysprof.c
+++ b/sysprof.c
@@ -415,9 +415,21 @@ get_current_object (Application *app)
 }
 
 static void
+set_row (FooTreeStore *store, GtkTreeIter *iter,
+	 const char *name, double self, double total)
+{
+    foo_tree_store_set (store, iter,
+			DESCENDANTS_NAME, name,
+			DESCENDANTS_SELF, self,
+			DESCENDANTS_CUMULATIVE, total,
+			DESCENDANTS_OBJECT, name,
+			-1);
+}
+
+static void
 add_node (FooTreeStore      *store,
 	  int                size,
-	  const GtkTreeIter *parent,
+	  GtkTreeIter       *parent,
 	  ProfileDescendant *node)
 {
     GtkTreeIter iter;
@@ -427,17 +439,17 @@ add_node (FooTreeStore      *store,
 
     foo_tree_store_insert (store, &iter, (GtkTreeIter *)parent, 0);
     
-    foo_tree_store_set (store, &iter,
-			DESCENDANTS_NAME, node->name,
-			DESCENDANTS_SELF, 100 * (node->self)/(double)size,
-			DESCENDANTS_CUMULATIVE, 100 * (node->cumulative)/(double)size,
-#if 0
-			DESCENDANTS_SELF, (double)node->self,
-			DESCENDANTS_CUMULATIVE, (double)node->non_recursion,
-#endif
-			DESCENDANTS_OBJECT, node->name,
-			-1);
+    set_row (store, &iter, node->name,
+	     100 * (node->self)/(double)size,
+	     100 * (node->cumulative)/(double)size);
 
+    if (parent == NULL)
+    {
+	foo_tree_store_insert (store, &iter, &iter, 0);
+    
+	set_row (store, &iter, "<i>Descendants</i>", 1.0, 1.0);
+    }
+		
     add_node (store, size, parent, node->siblings);
     add_node (store, size, &iter, node->children);
 }
@@ -467,6 +479,7 @@ fill_descendants_tree (Application *app)
 	    {
 		ProfileDescendant *node =
 		    profile_create_descendants (app->profile, object->name);
+
 		add_node (tree_store,
 			  profile_get_size (app->profile), NULL, node);
 	    }
@@ -495,8 +508,8 @@ add_callers (GtkListStore  *list_store,
 	gtk_list_store_set (
 	    list_store, &iter,
 	    CALLERS_NAME, "",
-	    CALLERS_SELF, 0.0,
-	    CALLERS_TOTAL, 0.0, -1);
+	    CALLERS_SELF, -1.0,
+	    CALLERS_TOTAL, -1.0, -1);
     }
     
     while (callers)
@@ -896,9 +909,10 @@ expand_descendants_tree (Application *app, gpointer object)
     GtkTreePath *first_path;
     GList *list;
 
-    gtk_tree_view_collapse_all (app->descendants_view);
+    if (!(first_path = find_object (model, object)))
+	return;
 
-    first_path = find_object (model, object);
+    gtk_tree_view_collapse_all (app->descendants_view);
 
     gtk_tree_view_set_cursor (app->descendants_view, first_path,
 			      NULL, FALSE);
diff --git a/treeviewutils.c b/treeviewutils.c
index a73de20..3d66ba9 100644
--- a/treeviewutils.c
+++ b/treeviewutils.c
@@ -148,7 +148,7 @@ add_plain_text_column (GtkTreeView *view, const gchar *title, gint model_column)
     g_object_set (renderer, "xpad", PADDING, NULL);
 #endif
     column = gtk_tree_view_column_new_with_attributes (title, renderer,
-						       "text", model_column,
+						       "markup", model_column,
 						       NULL);
     gtk_tree_view_column_set_resizable (column, TRUE);
     gtk_tree_view_append_column (view, column);
@@ -188,8 +188,11 @@ double_to_text (GtkTreeViewColumn *tree_column,
     ColumnInfo *info = data;
     
     gtk_tree_model_get (tree_model, iter, info->column, &d, -1);
-    
-    text = g_strdup_printf (info->format, d);
+
+    if (d < 0)
+	text = g_strdup ("");
+    else
+	text = g_strdup_printf (info->format, d);
     
     g_object_set (cell, "markup", text, NULL);
     g_free (text);



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