Make the tree tree-shapeed.
authorSøren Sandmann <sandmann@redhat.com>
Mon, 19 Dec 2005 22:39:34 +0000 (22:39 +0000)
committerSøren Sandmann Pedersen <ssp@src.gnome.org>
Mon, 19 Dec 2005 22:39:34 +0000 (22:39 +0000)
Mon Dec 19 17:39:09 2005  Søren Sandmann  <sandmann@redhat.com>

* sysprof.c (add_text): Make the tree tree-shapeed.

ChangeLog
sysprof.c

index f2e78f4..18b7513 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Dec 19 17:39:09 2005  Søren Sandmann  <sandmann@redhat.com>
+
+       * sysprof.c (add_text): Make the tree tree-shapeed.
+
 Mon Dec 19 15:15:48 2005  Søren Sandmann  <sandmann@redhat.com>
 
        * module/sysprof-module.c (timer_notify): A few formatting
index 1986696..d9ee288 100644 (file)
--- a/sysprof.c
+++ b/sysprof.c
@@ -1044,6 +1044,12 @@ get_data (GtkTreeView *view,
        -1);
 }
 
+static int
+get_indent (GtkTreePath *path)
+{
+    return 2 * (gtk_tree_path_get_depth (path) - 1);
+}
+
 static void
 compute_text_width (GtkTreeView  *view,
                    GtkTreePath  *path,
@@ -1051,11 +1057,12 @@ compute_text_width (GtkTreeView  *view,
                    gpointer      data)
 {
    int *width = data;
-    char *name;
+   char *name;
+   int indent;
+   
+   get_data (view, iter, &name, NULL, NULL);
 
-    get_data (view, iter, &name, NULL, NULL);
-    
-    *width = MAX (g_utf8_strlen (name, -1), *width);
+   *width = MAX (g_utf8_strlen (name, -1) + get_indent (path), *width);
 }
 
 typedef struct
@@ -1074,10 +1081,17 @@ add_text (GtkTreeView *view,
     char *name;
     double self;
     double cumulative;
+    int indent;
+    int i;
 
     get_data (view, iter, &name, &self, &cumulative);
+
+    indent = get_indent (path);
+
+    for (i = 0; i < indent; ++i)
+       g_string_append_c (info->text, ' ');
     
-    g_string_append_printf (info->text, "%-*s %6.2f %6.2f\n", info->max_width, name, self, cumulative);
+    g_string_append_printf (info->text, "%-*s %6.2f %6.2f\n", info->max_width - indent, name, self, cumulative);
 }
 
 static void