[PATCH 1/6] perf report: Add a popup menu to ask what operation is to be performed

Previous thread: [PATCH 4/6] perf annotate: Allow specifying DSOs where to look for symbol by Arnaldo Carvalho de Melo on Wednesday, March 24, 2010 - 11:02 am. (1 message)

Next thread: Re: [PATCH 4/6] drivers:misc: sources for Init manager module by Pavan Savoy on Wednesday, March 24, 2010 - 11:46 am. (2 messages)
From: Arnaldo Carvalho de Melo
Date: Wednesday, March 24, 2010 - 11:02 am

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Right now it presents a menu with these options:

 +------------------------------+
 | Annotate CURRENT_SYMBOL_NAME |
 | Exit                         |
 +------------------------------+

If the highlighted (current) symbol is not annotatable only the "Exit"
option will appear.

Also add a confirmation dialog when ESC is pressed on the top level to
avoid exiting the application by pressing one too many ESC key.

To get to the menu just press the -> (Right navigation key), to exit
just press ESC.

Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/newt.c |   96 ++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 88 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index 12b229b..a3465a0 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -28,6 +28,47 @@ static newtComponent newt_form__new(void)
 	return self;
 }
 
+static int popup_menu(int argc, const char *argv[])
+{
+	struct newtExitStruct es;
+	int i, rc = -1, max_len = 5;
+	newtComponent listbox, form = newt_form__new();
+
+	if (form == NULL)
+		return -1;
+
+	listbox = newtListbox(0, 0, argc, NEWT_FLAG_RETURNEXIT);
+	if (listbox == NULL)
+		goto out_destroy_form;
+
+	newtFormAddComponents(form, listbox, NULL);
+
+	for (i = 0; i < argc; ++i) {
+		int len = strlen(argv[i]);
+		if (len > max_len)
+			max_len = len;
+		if (newtListboxAddEntry(listbox, argv[i], (void *)(long)i))
+			goto out_destroy_form;
+	}
+
+	newtCenteredWindow(max_len, argc, NULL);
+	newtFormRun(form, &es);
+	rc = newtListboxGetCurrent(listbox) - NULL;
+	if (es.reason == NEWT_EXIT_HOTKEY)
+		rc = -1;
+	newtPopWindow();
+out_destroy_form:
+	newtFormDestroy(form);
+	return rc;
+}
+
+static bool dialog_yesno(const ...
Previous thread: [PATCH 4/6] perf annotate: Allow specifying DSOs where to look for symbol by Arnaldo Carvalho de Melo on Wednesday, March 24, 2010 - 11:02 am. (1 message)

Next thread: Re: [PATCH 4/6] drivers:misc: sources for Init manager module by Pavan Savoy on Wednesday, March 24, 2010 - 11:46 am. (2 messages)