mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
	David Ahern <dsahern@gmail.com>,
	Stephane Eranian <eranian@google.com>,
	Pekka Enberg <penberg@kernel.org>
Subject: [PATCH 3/7] perf gtk/hists: Factor out perf_gtk__add_entries()
Date: Tue, 21 May 2013 15:14:34 +0900	[thread overview]
Message-ID: <1369116878-12489-4-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1369116878-12489-1-git-send-email-namhyung@kernel.org>

From: Namhyung Kim <namhyung.kim@lge.com>

This is a preparation for supporting hierarchical output in the hist
browser.

Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/ui/gtk/hists.c | 72 +++++++++++++++++++++++++++--------------------
 1 file changed, 41 insertions(+), 31 deletions(-)

diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index ba59d5d63d74..e1b8f702daf2 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -124,6 +124,46 @@ void perf_gtk__init_hpp(void)
 				perf_gtk__hpp_color_overhead_guest_us;
 }
 
+static void perf_gtk__add_entries(struct hists *hists, struct perf_hpp *hpp,
+				  GtkTreeStore *store)
+{
+	int col_idx;
+	struct rb_node *nd;
+	struct perf_hpp_fmt *fmt;
+	struct sort_entry *se;
+
+	for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
+		struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
+		GtkTreeIter iter;
+
+		if (h->filtered)
+			continue;
+
+		gtk_tree_store_append(store, &iter, NULL);
+
+		col_idx = 0;
+
+		perf_hpp__for_each_format(fmt) {
+			if (fmt->color)
+				fmt->color(hpp, h);
+			else
+				fmt->entry(hpp, h);
+
+			gtk_tree_store_set(store, &iter, col_idx++, hpp->buf, -1);
+		}
+
+		list_for_each_entry(se, &hist_entry__sort_list, list) {
+			if (se->elide)
+				continue;
+
+			se->se_snprintf(h, hpp->buf, hpp->size,
+					hists__col_len(hists, se->se_width_idx));
+
+			gtk_tree_store_set(store, &iter, col_idx++, hpp->buf, -1);
+		}
+	}
+}
+
 static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)
 {
 	struct perf_hpp_fmt *fmt;
@@ -131,7 +171,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)
 	GtkCellRenderer *renderer;
 	struct sort_entry *se;
 	GtkTreeStore *store;
-	struct rb_node *nd;
 	GtkWidget *view;
 	int col_idx;
 	int nr_cols;
@@ -186,36 +225,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)
 
 	g_object_unref(GTK_TREE_MODEL(store));
 
-	for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
-		struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
-		GtkTreeIter iter;
-
-		if (h->filtered)
-			continue;
-
-		gtk_tree_store_append(store, &iter, NULL);
-
-		col_idx = 0;
-
-		perf_hpp__for_each_format(fmt) {
-			if (fmt->color)
-				fmt->color(&hpp, h);
-			else
-				fmt->entry(&hpp, h);
-
-			gtk_tree_store_set(store, &iter, col_idx++, s, -1);
-		}
-
-		list_for_each_entry(se, &hist_entry__sort_list, list) {
-			if (se->elide)
-				continue;
-
-			se->se_snprintf(h, s, ARRAY_SIZE(s),
-					hists__col_len(hists, se->se_width_idx));
-
-			gtk_tree_store_set(store, &iter, col_idx++, s, -1);
-		}
-	}
+	perf_gtk__add_entries(hists, &hpp, store);
 
 	gtk_container_add(GTK_CONTAINER(window), view);
 }
-- 
1.7.11.7


  parent reply	other threads:[~2013-05-21  6:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21  6:14 [RFC 0/7] perf report/gtk: Add support for hierarchy view Namhyung Kim
2013-05-21  6:14 ` [PATCH 1/7] perf hists: Basic support of hierarchical view Namhyung Kim
2013-05-21  6:14 ` [PATCH 2/7] perf gtk/hists: Use GtkTreeStore instead of GtkListStore Namhyung Kim
2013-05-21  6:14 ` Namhyung Kim [this message]
2013-05-21  6:14 ` [PATCH 4/7] perf gtk/hists: Add support for hierachical output Namhyung Kim
2013-05-21  6:14 ` [PATCH 5/7] perf report: Add -H (--hierarchy) option Namhyung Kim
2013-05-21  6:14 ` [PATCH 6/7] perf gtk/hists: Add a double-click handler for hierarchy mode Namhyung Kim
2013-05-21  6:14 ` [PATCH 7/7] perf gtk/hists: Set rules hint for the hist browser Namhyung Kim
2013-05-21  7:04 ` [RFC 0/7] perf report/gtk: Add support for hierarchy view Pekka Enberg
2013-05-21  7:26   ` Namhyung Kim
2013-05-22  8:45     ` Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369116878-12489-4-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®