From 02242d500b99312bc6efa180a87365399d1e4d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Sandmann?= Date: Mon, 19 Dec 2005 22:39:34 +0000 Subject: [PATCH] Make the tree tree-shapeed. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mon Dec 19 17:39:09 2005 Søren Sandmann * sysprof.c (add_text): Make the tree tree-shapeed. --- ChangeLog | 4 ++++ sysprof.c | 24 +++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2e78f49..18b75135 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Dec 19 17:39:09 2005 Søren Sandmann + + * sysprof.c (add_text): Make the tree tree-shapeed. + Mon Dec 19 15:15:48 2005 Søren Sandmann * module/sysprof-module.c (timer_notify): A few formatting diff --git a/sysprof.c b/sysprof.c index 19866961..d9ee2886 100644 --- 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