perf ui: Add basic error handling for GTK2 front-end (v3)
cover perf ui: Add basic error handling for GTK2 front-end (v3)
Hi,
This patchset implements ui__warning/error() functions for GTK2. Patch 1 is a resend (which forgot to cc LKML) and independent of this series. Patch 2 converts invocations of ui__warning followed by exit (or similar effect) into ui__error.
I chose GtkInfoBar widget to implement ui__warning since it provides a simple way to do what we want IMHO. In fact, a guy sat next to me at the Korean GNOME hackfest suggested to use it. The only problem is it requires 2.18 (or newer) version of GTK+ libraries. So I added status bar as a fallback when info bar is not supported, and this can be used to implement helpline functions later.
Changes from v2:
* Convert critical use of ui__warning to ui__error (by Ingo)
* Use GtkInfoBar instead of a message dialog (by Pekka)
Any comments are welcome.
Thanks,
Namhyung
Namhyung Kim (7):
perf ui: Make --stdio default when TUI is not supported perf tools: Convert critical messages to ui__error() perf ui: Introduce struct perf_error_ops
perf ui/gtk: Introduce struct perf_gtk_context perf ui/gtk: Add GTK statusbar widget to browser window perf ui/gtk: Add GTK info_bar widget to browser window perf ui/gtk: Use struct perf_error_ops
tools/perf/Makefile | 6 + tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-record.c | 14 +- tools/perf/builtin-report.c | 14 +- tools/perf/builtin-top.c | 22 +-- tools/perf/config/feature-tests.mak | 13 ++ tools/perf/ui/gtk/browser.c | 67 ++++++++- tools/perf/ui/gtk/gtk.h | 31 ++++ tools/perf/ui/gtk/setup.c | 5 + tools/perf/ui/gtk/util.c | 129 ++++++++++++++++ tools/perf/ui/setup.c | 1 + tools/perf/ui/tui/setup.c | 6 + tools/perf/ui/tui/util.c | 243 ++++++++++++++++++++++++++++++ tools/perf/ui/util.c | 277 +++++++---------------------------- tools/perf/ui/util.h | 9 +- tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 23 ++- 17 files changed, 609 insertions(+), 255 deletions(-) create mode 100644 tools/perf/ui/gtk/util.c create mode 100644 tools/perf/ui/tui/util.c
Signature · 1 line
1.7.9.2
PATCH RESEND 1/7 perf ui: Make --stdio default when TUI is not supported
The commit dc41b9b8f02db ("perf ui: Change fallback policy of setup_browser") changed default behavior of the function but missed setting the use_browser variable to 0 accidently. So perf report ends up doing nothing in such cases. Fix it.
--- tools/perf/ui/setup.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/ui/setup.c +1 -0
@@ -22,6 +22,7 @@ void setup_browser(bool fallback_to_pager)break ;/* fall through */ default : + use_browser =0 ;if (fallback_to_pager)setup_pager ();break ;
Signature · 1 line
1.7.9.2
PATCH 2/7 perf tools: Convert critical messages to ui__error()
In reply to Namhyung KimThere were places where use ui__warning (or even fprintf) to show critical messages. This patch converts them to ui__error so that the front-end code can implement appropriate behavior.
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-record.c | 14 +++++++------- tools/perf/builtin-report.c | 14 ++++++-------- tools/perf/builtin-top.c | 22 +++++++++++----------- 4 files changed, 25 insertions(+), 27 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann) }if (total_nr_samples ==0 ) { -ui__warning ("The %s file has no samples!\n" , session->filename); +ui__error ("The %s file has no samples!\n" , session->filename); goto out_delete; } out_delete:
tools/perf/builtin-record.c +7 -7
@@ -264,7 +264,7 @@ try_again: }if (err ==ENOENT ) { -ui__warning ("The %s event is not supported.\n" , +ui__error ("The %s event is not supported.\n" ,event_name (pos));exit (EXIT_FAILURE ); }
@@ -858,8 +858,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)usage_with_options (record_usage, record_options);if (rec->force && rec->append_file) { -fprintf (stderr,"Can't overwrite and append at the same time." -" You need to choose between -f and -A" ); +ui__error ("Can't overwrite and append at the same time." +" You need to choose between -f and -A" );usage_with_options (record_usage, record_options); }else if (rec->append_file) { rec->write_mode =WRITE_APPEND ;
@@ -868,8 +868,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) }if (nr_cgroups && !rec->opts.target.system_wide) { -fprintf (stderr,"cgroup monitoring only available in" -" system-wide mode\n" ); +ui__error ("cgroup monitoring only available in" +" system-wide mode\n" );usage_with_options (record_usage, record_options); }
@@ -905,7 +905,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)int saved_errno = errno;perf_target__strerror (&rec->opts.target, err, errbuf,BUFSIZ ); -ui__warning ("%s" , errbuf); +ui__error ("%s" , errbuf); err = -saved_errno; goto out_free_fd;
@@ -933,7 +933,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)else if (rec->opts.freq) { rec->opts.default_interval = rec->opts.freq; }else { -fprintf (stderr,"frequency and count are zero, aborting\n" ); +ui__error ("frequency and count are zero, aborting\n" ); err = -EINVAL ; goto out_free_fd; }
tools/perf/builtin-report.c +6 -8
@@ -251,13 +251,13 @@ static int perf_report__setup_sample_type(struct perf_report *rep)if (!(self->sample_type &PERF_SAMPLE_CALLCHAIN )) {if (sort__has_parent) { -ui__warning ("Selected --sort parent, but no " +ui__error ("Selected --sort parent, but no " "callchain data. Did you call " "'perf record' without -g?\n" );return -EINVAL ; }if (symbol_conf.use_callchain) { -ui__warning ("Selected -g but no callchain data. Did " +ui__error ("Selected -g but no callchain data. Did " "you call 'perf record' without -g?\n" );return -1 ; }
@@ -266,17 +266,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep) !symbol_conf.use_callchain) { symbol_conf.use_callchain = true;if (callchain_register_param (&callchain_param) <0 ) { -ui__warning ("Can't register callchain " -"params.\n" ); +ui__error ("Can't register callchain params.\n" );return -EINVAL ; } }if (sort__branch_mode ==1 ) {if (!(self->sample_type &PERF_SAMPLE_BRANCH_STACK )) { -fprintf (stderr,"selected -b but no branch data." -" Did you call perf record without" -" -b?\n" ); +ui__error ("Selected -b but no branch data. " +"Did you call perf record without -b?\n" );return -1 ; } }
@@ -420,7 +418,7 @@ static int __cmd_report(struct perf_report *rep) }if (nr_samples ==0 ) { -ui__warning ("The %s file has no samples!\n" , session->filename); +ui__error ("The %s file has no samples!\n" , session->filename); goto out_delete; }
tools/perf/builtin-top.c +11 -11
@@ -959,16 +959,16 @@ try_again: }if (err ==ENOENT ) { -ui__warning ("The %s event is not supported.\n" , +ui__error ("The %s event is not supported.\n" ,event_name (counter)); goto out_err; }else if (err ==EMFILE ) { -ui__warning ("Too many events are opened.\n" +ui__error ("Too many events are opened.\n" "Try again after reducing the number of events\n" ); goto out_err; } -ui__warning ("The sys_perf_event_open() syscall " +ui__error ("The sys_perf_event_open() syscall " "returned with %d (%s). /bin/dmesg " "may provide additional information.\n" "No CONFIG_PERF_EVENTS=y kernel support "
@@ -978,7 +978,7 @@ try_again: }if (perf_evlist__mmap (evlist, top->mmap_pages, false) <0 ) { -ui__warning ("Failed to mmap with %d (%s)\n" , +ui__error ("Failed to mmap with %d (%s)\n" , errno,strerror (errno)); goto out_err; }
@@ -994,12 +994,12 @@ static int perf_top__setup_sample_type(struct perf_top *top) {if (!top->sort_has_symbols) {if (symbol_conf.use_callchain) { -ui__warning ("Selected -g but \"sym\" not present in --sort/-s." ); +ui__error ("Selected -g but \"sym\" not present in --sort/-s." );return -EINVAL ; } }else if (!top->dont_use_callchains && callchain_param.mode !=CHAIN_NONE ) {if (callchain_register_param (&callchain_param) <0 ) { -ui__warning ("Can't register callchain params.\n" ); +ui__error ("Can't register callchain params.\n" );return -EINVAL ; } }
@@ -1041,7 +1041,7 @@ static int __cmd_top(struct perf_top *top)if (pthread_create (&thread,NULL , (use_browser >0 ? display_thread_tui : display_thread), top)) { -printf ("Could not create display thread.\n" ); +ui__error ("Could not create display thread.\n" );exit (-1 ); }
@@ -1050,7 +1050,7 @@ static int __cmd_top(struct perf_top *top) param.sched_priority = top->realtime_prio;if (sched_setscheduler (0 ,SCHED_FIFO , ¶m)) { -printf ("Could not set realtime priority.\n" ); +ui__error ("Could not set realtime priority.\n" );exit (-1 ); } }
@@ -1274,7 +1274,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)int saved_errno = errno;perf_target__strerror (&top.target, status, errbuf,BUFSIZ ); -ui__warning ("%s" , errbuf); +ui__error ("%s" , errbuf); status = -saved_errno; goto out_delete_evlist;
@@ -1288,7 +1288,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)if (!top.evlist->nr_entries &&perf_evlist__add_default (top.evlist) <0 ) { -pr_err ("Not enough memory for event selector list\n" ); +ui__error ("Not enough memory for event selector list\n" );return -ENOMEM ; }
@@ -1305,7 +1305,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)else if (top.freq) { top.default_interval = top.freq; }else { -fprintf (stderr,"frequency and count are zero, aborting\n" ); +ui__error ("frequency and count are zero, aborting\n" );exit (EXIT_FAILURE ); }
Signature · 1 line
1.7.9.2
[tip:perf/urgent] perf tools: Convert critical messages to ui__error()
Commit-ID: 3780f4883b2f3319afe88bf3ddc73ef426851d49 Gitweb: http://git.kernel.org/tip/3780f4883b2f3319afe88bf3ddc73ef426851d49 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 29 May 2012 13:22:57 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 29 May 2012 11:53:42 -0300
perf tools: Convert critical messages to ui__error()
There were places where use ui__warning (or even fprintf) to show critical messages. This patch converts them to ui__error so that the front-end code can implement appropriate behavior.
--- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-record.c | 14 +++++++------- tools/perf/builtin-report.c | 14 ++++++-------- tools/perf/builtin-top.c | 22 +++++++++++----------- 4 files changed, 25 insertions(+), 27 deletions(-)
tools/perf/builtin-annotate.c +1 -1
@@ -215,7 +215,7 @@ static int __cmd_annotate(struct perf_annotate *ann) }if (total_nr_samples ==0 ) { -ui__warning ("The %s file has no samples!\n" , session->filename); +ui__error ("The %s file has no samples!\n" , session->filename); goto out_delete; } out_delete:
tools/perf/builtin-record.c +7 -7
@@ -264,7 +264,7 @@ try_again: }if (err ==ENOENT ) { -ui__warning ("The %s event is not supported.\n" , +ui__error ("The %s event is not supported.\n" ,event_name (pos));exit (EXIT_FAILURE ); }
@@ -858,8 +858,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)usage_with_options (record_usage, record_options);if (rec->force && rec->append_file) { -fprintf (stderr,"Can't overwrite and append at the same time." -" You need to choose between -f and -A" ); +ui__error ("Can't overwrite and append at the same time." +" You need to choose between -f and -A" );usage_with_options (record_usage, record_options); }else if (rec->append_file) { rec->write_mode =WRITE_APPEND ;
@@ -868,8 +868,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) }if (nr_cgroups && !rec->opts.target.system_wide) { -fprintf (stderr,"cgroup monitoring only available in" -" system-wide mode\n" ); +ui__error ("cgroup monitoring only available in" +" system-wide mode\n" );usage_with_options (record_usage, record_options); }
@@ -905,7 +905,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)int saved_errno = errno;perf_target__strerror (&rec->opts.target, err, errbuf,BUFSIZ ); -ui__warning ("%s" , errbuf); +ui__error ("%s" , errbuf); err = -saved_errno; goto out_free_fd;
@@ -933,7 +933,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)else if (rec->opts.freq) { rec->opts.default_interval = rec->opts.freq; }else { -fprintf (stderr,"frequency and count are zero, aborting\n" ); +ui__error ("frequency and count are zero, aborting\n" ); err = -EINVAL ; goto out_free_fd; }
tools/perf/builtin-report.c +6 -8
@@ -251,13 +251,13 @@ static int perf_report__setup_sample_type(struct perf_report *rep)if (!(self->sample_type &PERF_SAMPLE_CALLCHAIN )) {if (sort__has_parent) { -ui__warning ("Selected --sort parent, but no " +ui__error ("Selected --sort parent, but no " "callchain data. Did you call " "'perf record' without -g?\n" );return -EINVAL ; }if (symbol_conf.use_callchain) { -ui__warning ("Selected -g but no callchain data. Did " +ui__error ("Selected -g but no callchain data. Did " "you call 'perf record' without -g?\n" );return -1 ; }
@@ -266,17 +266,15 @@ static int perf_report__setup_sample_type(struct perf_report *rep) !symbol_conf.use_callchain) { symbol_conf.use_callchain = true;if (callchain_register_param (&callchain_param) <0 ) { -ui__warning ("Can't register callchain " -"params.\n" ); +ui__error ("Can't register callchain params.\n" );return -EINVAL ; } }if (sort__branch_mode ==1 ) {if (!(self->sample_type &PERF_SAMPLE_BRANCH_STACK )) { -fprintf (stderr,"selected -b but no branch data." -" Did you call perf record without" -" -b?\n" ); +ui__error ("Selected -b but no branch data. " +"Did you call perf record without -b?\n" );return -1 ; } }
@@ -420,7 +418,7 @@ static int __cmd_report(struct perf_report *rep) }if (nr_samples ==0 ) { -ui__warning ("The %s file has no samples!\n" , session->filename); +ui__error ("The %s file has no samples!\n" , session->filename); goto out_delete; }
tools/perf/builtin-top.c +11 -11
@@ -959,16 +959,16 @@ try_again: }if (err ==ENOENT ) { -ui__warning ("The %s event is not supported.\n" , +ui__error ("The %s event is not supported.\n" ,event_name (counter)); goto out_err; }else if (err ==EMFILE ) { -ui__warning ("Too many events are opened.\n" +ui__error ("Too many events are opened.\n" "Try again after reducing the number of events\n" ); goto out_err; } -ui__warning ("The sys_perf_event_open() syscall " +ui__error ("The sys_perf_event_open() syscall " "returned with %d (%s). /bin/dmesg " "may provide additional information.\n" "No CONFIG_PERF_EVENTS=y kernel support "
@@ -978,7 +978,7 @@ try_again: }if (perf_evlist__mmap (evlist, top->mmap_pages, false) <0 ) { -ui__warning ("Failed to mmap with %d (%s)\n" , +ui__error ("Failed to mmap with %d (%s)\n" , errno,strerror (errno)); goto out_err; }
@@ -994,12 +994,12 @@ static int perf_top__setup_sample_type(struct perf_top *top) {if (!top->sort_has_symbols) {if (symbol_conf.use_callchain) { -ui__warning ("Selected -g but \"sym\" not present in --sort/-s." ); +ui__error ("Selected -g but \"sym\" not present in --sort/-s." );return -EINVAL ; } }else if (!top->dont_use_callchains && callchain_param.mode !=CHAIN_NONE ) {if (callchain_register_param (&callchain_param) <0 ) { -ui__warning ("Can't register callchain params.\n" ); +ui__error ("Can't register callchain params.\n" );return -EINVAL ; } }
@@ -1041,7 +1041,7 @@ static int __cmd_top(struct perf_top *top)if (pthread_create (&thread,NULL , (use_browser >0 ? display_thread_tui : display_thread), top)) { -printf ("Could not create display thread.\n" ); +ui__error ("Could not create display thread.\n" );exit (-1 ); }
@@ -1050,7 +1050,7 @@ static int __cmd_top(struct perf_top *top) param.sched_priority = top->realtime_prio;if (sched_setscheduler (0 ,SCHED_FIFO , ¶m)) { -printf ("Could not set realtime priority.\n" ); +ui__error ("Could not set realtime priority.\n" );exit (-1 ); } }
@@ -1274,7 +1274,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)int saved_errno = errno;perf_target__strerror (&top.target, status, errbuf,BUFSIZ ); -ui__warning ("%s" , errbuf); +ui__error ("%s" , errbuf); status = -saved_errno; goto out_delete_evlist;
@@ -1288,7 +1288,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)if (!top.evlist->nr_entries &&perf_evlist__add_default (top.evlist) <0 ) { -pr_err ("Not enough memory for event selector list\n" ); +ui__error ("Not enough memory for event selector list\n" );return -ENOMEM ; }
@@ -1305,7 +1305,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)else if (top.freq) { top.default_interval = top.freq; }else { -fprintf (stderr,"frequency and count are zero, aborting\n" ); +ui__error ("frequency and count are zero, aborting\n" );exit (EXIT_FAILURE ); }
PATCH 3/7 perf ui: Introduce struct perf_error_ops
In reply to Namhyung KimFrom: Namhyung Kim <[email protected]>
The struct perf_error_ops is for flexible error logging. We can register appropriate functions based on front-end.
--- tools/perf/Makefile | 3 + tools/perf/ui/gtk/util.c | 20 ++++ tools/perf/ui/tui/setup.c | 6 + tools/perf/ui/tui/util.c | 243 +++++++++++++++++++++++++++++++++++++++ tools/perf/ui/util.c | 277 +++++++++------------------------------------ tools/perf/ui/util.h | 9 +- tools/perf/util/debug.c | 2 +- tools/perf/util/debug.h | 23 +++- 8 files changed, 357 insertions(+), 226 deletions(-) create mode 100644 tools/perf/ui/gtk/util.c create mode 100644 tools/perf/ui/tui/util.c
tools/perf/Makefile +3 -0
@@ -503,6 +503,7 @@ else LIB_OBJS += $(OUTPUT)ui/progress.o LIB_OBJS += $(OUTPUT)ui/util.o LIB_OBJS += $(OUTPUT)ui/tui/setup.o + LIB_OBJS += $(OUTPUT)ui/tui/util.o LIB_H += ui/browser.h LIB_H += ui/browsers/map.h LIB_H += ui/helpline.h
@@ -526,9 +527,11 @@ else EXTLIBS += $(shell pkg-config --libs gtk+-2.0) LIB_OBJS += $(OUTPUT)ui/gtk/browser.o LIB_OBJS += $(OUTPUT)ui/gtk/setup.o + LIB_OBJS += $(OUTPUT)ui/gtk/util.o # Make sure that it'd be included only once. ifneq ($(findstring -DNO_NEWT_SUPPORT,$(BASIC_CFLAGS)),) LIB_OBJS += $(OUTPUT)ui/setup.o + LIB_OBJS += $(OUTPUT)ui/util.o endif endif endif
tools/perf/ui/gtk/util.c new file +20 -0
@@ -0,0 +1,20 @@ +#include "../util.h" +#include "../../util/debug.h" +#include "gtk.h" + + +/* +* FIXME: Functions below should be implemented properly. +* For now, just add stubs for NO_NEWT=1 build. +*/ +#ifdef NO_NEWT_SUPPORT +int ui_helpline__show_help (const char *format__used ,va_list ap__used ) +{ +return 0 ; +} + +void ui_progress__update (u64 curr__used ,u64 total__used , +const char *title__used ) +{ +} +#endif
tools/perf/ui/tui/setup.c +6 -0
@@ -15,6 +15,8 @@ pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;static volatile int ui__need_resize; +extern struct perf_error_ops perf_tui_eops; +void ui__refresh_dimensions (bool force) {if (force || ui__need_resize) {
@@ -122,6 +124,8 @@ int ui__init(void)signal (SIGINT , ui__signal);signal (SIGQUIT , ui__signal);signal (SIGTERM , ui__signal); + +perf_error__register (&perf_tui_eops); out:return err; }
@@ -137,4 +141,6 @@ void ui__exit(bool wait_for_ok)SLsmg_refresh ();SLsmg_reset_smg ();SLang_reset_tty (); + +perf_error__unregister (&perf_tui_eops); }
tools/perf/ui/tui/util.c new file +243 -0
243 lines not on this page · raw message
tools/perf/ui/util.c +56 -221
306 lines not on this page · raw message
tools/perf/ui/util.h +8 -1
@@ -9,6 +9,13 @@ int ui__help_window(const char *text);int ui__dialog_yesno (const char *msg);int ui__question_window (const char *title,const char *text,const char *exit_msg,int delay_secs); -int __ui__warning (const char *title,const char *format,va_list args); + +struct perf_error_ops { +int (*error)(const char *format,va_list args); +int (*warning)(const char *format,va_list args); +}; + +int perf_error__register (struct perf_error_ops *eops); +int perf_error__unregister (struct perf_error_ops *eops);#endif /* _PERF_UI_UTIL_H_ */
tools/perf/util/debug.c +1 -1
@@ -47,7 +47,7 @@ int dump_printf(const char *fmt, ...)return ret; } -#ifdef NO_NEWT_SUPPORT +#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )int ui__warning (const char *format, ...) {va_list args;
tools/perf/util/debug.h +20 -3
@@ -12,8 +12,9 @@ int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));void trace_event (union perf_event *event);struct ui_progress ; +struct perf_error_ops ; -#ifdef NO_NEWT_SUPPORT +#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )static inline int ui_helpline__show_help (const char *format__used ,va_list ap__used ) {return 0 ;
@@ -23,12 +24,28 @@ static inline void ui_progress__update(u64 curr __used, u64 total __used, const char *title __used) {} #define ui__error(format, arg...) ui__warning(format, ##arg) -#else + +static inline int +perf_error__register (struct perf_error_ops *eops__used ) +{ +return 0 ; +} + +static inline int +perf_error__unregister (struct perf_error_ops *eops__used ) +{ +return 0 ; +} + +#else /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +extern char ui_helpline__last_msg[];int ui_helpline__show_help (const char *format,va_list ap);#include "../ui/progress.h" int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 ))); -#endif +#include "../ui/util.h" + +#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ int ui__warning (const char *format, ...) __attribute__((format (printf,1 ,2 )));int ui__error_paranoid (void );
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui: Introduce struct perf_error_ops
Commit-ID: ba47a142d9f9b84e0464a11b7a067e5ad95c5d4b Gitweb: http://git.kernel.org/tip/ba47a142d9f9b84e0464a11b7a067e5ad95c5d4b Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 29 May 2012 13:22:58 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 19 Jun 2012 13:06:18 -0300
perf ui: Introduce struct perf_error_ops
The struct perf_error_ops is for flexible error logging.
We can register appropriate functions based on front-end.
---
tools/perf/Makefile | 3 +
tools/perf/ui/gtk/util.c | 20 +++
tools/perf/ui/tui/setup.c | 6 +
tools/perf/ui/{ => tui}/util.c | 49 +++----
tools/perf/ui/util.c | 277 ++++++++--------------------------------
tools/perf/ui/util.h | 9 +-
tools/perf/util/debug.c | 2 +-
tools/perf/util/debug.h | 23 +++-
8 files changed, 135 insertions(+), 254 deletions(-)tools/perf/Makefile +3 -0
@@ -503,6 +503,7 @@ else LIB_OBJS += $(OUTPUT)ui/progress.o LIB_OBJS += $(OUTPUT)ui/util.o LIB_OBJS += $(OUTPUT)ui/tui/setup.o + LIB_OBJS += $(OUTPUT)ui/tui/util.o LIB_H += ui/browser.h LIB_H += ui/browsers/map.h LIB_H += ui/helpline.h
@@ -526,9 +527,11 @@ else EXTLIBS += $(shell pkg-config --libs gtk+-2.0) LIB_OBJS += $(OUTPUT)ui/gtk/browser.o LIB_OBJS += $(OUTPUT)ui/gtk/setup.o + LIB_OBJS += $(OUTPUT)ui/gtk/util.o # Make sure that it'd be included only once. ifneq ($(findstring -DNO_NEWT_SUPPORT,$(BASIC_CFLAGS)),) LIB_OBJS += $(OUTPUT)ui/setup.o + LIB_OBJS += $(OUTPUT)ui/util.o endif endif endif
tools/perf/ui/gtk/util.c new file +20 -0
@@ -0,0 +1,20 @@ +#include "../util.h" +#include "../../util/debug.h" +#include "gtk.h" + + +/* +* FIXME: Functions below should be implemented properly. +* For now, just add stubs for NO_NEWT=1 build. +*/ +#ifdef NO_NEWT_SUPPORT +int ui_helpline__show_help (const char *format__used ,va_list ap__used ) +{ +return 0 ; +} + +void ui_progress__update (u64 curr__used ,u64 total__used , +const char *title__used ) +{ +} +#endif
tools/perf/ui/tui/setup.c +6 -0
@@ -15,6 +15,8 @@ pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;static volatile int ui__need_resize; +extern struct perf_error_ops perf_tui_eops; +void ui__refresh_dimensions (bool force) {if (force || ui__need_resize) {
@@ -122,6 +124,8 @@ int ui__init(void)signal (SIGINT , ui__signal);signal (SIGQUIT , ui__signal);signal (SIGTERM , ui__signal); + +perf_error__register (&perf_tui_eops); out:return err; }
@@ -137,4 +141,6 @@ void ui__exit(bool wait_for_ok)SLsmg_refresh ();SLsmg_reset_smg ();SLang_reset_tty (); + +perf_error__unregister (&perf_tui_eops); }
tools/perf/ui/tui/util.c renamed from tools/perf/ui/util.c +21 -28
78 lines not on this page · raw message
tools/perf/ui/util.c +56 -221
306 lines not on this page · raw message
tools/perf/ui/util.h +8 -1
@@ -9,6 +9,13 @@ int ui__help_window(const char *text);int ui__dialog_yesno (const char *msg);int ui__question_window (const char *title,const char *text,const char *exit_msg,int delay_secs); -int __ui__warning (const char *title,const char *format,va_list args); + +struct perf_error_ops { +int (*error)(const char *format,va_list args); +int (*warning)(const char *format,va_list args); +}; + +int perf_error__register (struct perf_error_ops *eops); +int perf_error__unregister (struct perf_error_ops *eops);#endif /* _PERF_UI_UTIL_H_ */
tools/perf/util/debug.c +1 -1
@@ -47,7 +47,7 @@ int dump_printf(const char *fmt, ...)return ret; } -#ifdef NO_NEWT_SUPPORT +#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )int ui__warning (const char *format, ...) {va_list args;
tools/perf/util/debug.h +20 -3
@@ -12,8 +12,9 @@ int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));void trace_event (union perf_event *event);struct ui_progress ; +struct perf_error_ops ; -#ifdef NO_NEWT_SUPPORT +#if defined(NO_NEWT_SUPPORT ) && defined(NO_GTK2_SUPPORT )static inline int ui_helpline__show_help (const char *format__used ,va_list ap__used ) {return 0 ;
@@ -23,12 +24,28 @@ static inline void ui_progress__update(u64 curr __used, u64 total __used, const char *title __used) {} #define ui__error(format, arg...) ui__warning(format, ##arg) -#else + +static inline int +perf_error__register (struct perf_error_ops *eops__used ) +{ +return 0 ; +} + +static inline int +perf_error__unregister (struct perf_error_ops *eops__used ) +{ +return 0 ; +} + +#else /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ +extern char ui_helpline__last_msg[];int ui_helpline__show_help (const char *format,va_list ap);#include "../ui/progress.h" int ui__error (const char *format, ...) __attribute__((format (printf,1 ,2 ))); -#endif +#include "../ui/util.h" + +#endif /* NO_NEWT_SUPPORT && NO_GTK2_SUPPORT */ int ui__warning (const char *format, ...) __attribute__((format (printf,1 ,2 )));int ui__error_paranoid (void );
PATCH 4/7 perf ui/gtk: Introduce struct perf_gtk_context
In reply to Namhyung KimThe struct perf_gtk_context is for tracking current state of GTK window and/or other things. This is a preparation of next changes.
--- tools/perf/ui/gtk/browser.c | 8 +++++++- tools/perf/ui/gtk/gtk.h | 17 +++++++++++++++++ tools/perf/ui/gtk/util.c | 23 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-)
tools/perf/ui/gtk/browser.c +7 -1
@@ -11,8 +11,8 @@static void perf_gtk__signal (int sig) { +perf_gtk__exit (false);psignal (sig,"perf" ); -gtk_main_quit (); }static void perf_gtk__resize_window (GtkWidget *window)
@@ -143,6 +143,10 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,g_signal_connect (window,"delete_event" , gtk_main_quit,NULL ); + pgctx =perf_gtk__activate_context (window); +if (!pgctx) +return -1 ; + notebook =gtk_notebook_new ();list_for_each_entry (pos, &evlist->entries, node) {
@@ -174,5 +178,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,gtk_main (); +perf_gtk__deactivate_context (&pgctx); +return 0 ; }
tools/perf/ui/gtk/gtk.h +17 -0
@@ -1,8 +1,25 @@#ifndef _PERF_GTK_H_#define _PERF_GTK_H_ 1 +#include <stdbool.h> +#pragma GCC diagnostic ignored "-Wstrict-prototypes"#include <gtk/gtk.h> #pragma GCC diagnostic error "-Wstrict-prototypes" + +struct perf_gtk_context { +GtkWidget *main_window; +}; + +extern struct perf_gtk_context *pgctx; + +static inline bool perf_gtk__is_active_context (struct perf_gtk_context *ctx) +{ +return ctx && ctx->main_window; +} + +struct perf_gtk_context *perf_gtk__activate_context (GtkWidget *window); +int perf_gtk__deactivate_context (struct perf_gtk_context **ctx); +#endif /* _PERF_GTK_H_ */
tools/perf/ui/gtk/util.c +23 -0
@@ -3,6 +3,29 @@#include "gtk.h" +struct perf_gtk_context *pgctx; + +struct perf_gtk_context *perf_gtk__activate_context (GtkWidget *window) +{ +struct perf_gtk_context *ctx; + + ctx =malloc (sizeof (*pgctx)); +if (ctx) + ctx->main_window = window; + +return ctx; +} + +int perf_gtk__deactivate_context (struct perf_gtk_context **ctx) +{ +if (!perf_gtk__is_active_context (*ctx)) +return -1 ; + +free (*ctx); + *ctx =NULL ; +return 0 ; +} +/* * FIXME: Functions below should be implemented properly. * For now, just add stubs for NO_NEWT=1 build.
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui/gtk: Introduce struct perf_gtk_context
Commit-ID: 42ab68a35ffee04700648ec42c9507145a66837d Gitweb: http://git.kernel.org/tip/42ab68a35ffee04700648ec42c9507145a66837d Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 29 May 2012 13:22:59 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 19 Jun 2012 13:06:18 -0300
perf ui/gtk: Introduce struct perf_gtk_context
The struct perf_gtk_context is for tracking current state of GTK window and/or other things. This is a preparation of next changes.
--- tools/perf/ui/gtk/browser.c | 8 +++++++- tools/perf/ui/gtk/gtk.h | 17 +++++++++++++++++ tools/perf/ui/gtk/util.c | 23 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletions(-)
tools/perf/ui/gtk/browser.c +7 -1
@@ -11,8 +11,8 @@static void perf_gtk__signal (int sig) { +perf_gtk__exit (false);psignal (sig,"perf" ); -gtk_main_quit (); }static void perf_gtk__resize_window (GtkWidget *window)
@@ -143,6 +143,10 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,g_signal_connect (window,"delete_event" , gtk_main_quit,NULL ); + pgctx =perf_gtk__activate_context (window); +if (!pgctx) +return -1 ; + notebook =gtk_notebook_new ();list_for_each_entry (pos, &evlist->entries, node) {
@@ -174,5 +178,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,gtk_main (); +perf_gtk__deactivate_context (&pgctx); +return 0 ; }
tools/perf/ui/gtk/gtk.h +17 -0
@@ -1,8 +1,25 @@#ifndef _PERF_GTK_H_#define _PERF_GTK_H_ 1 +#include <stdbool.h> +#pragma GCC diagnostic ignored "-Wstrict-prototypes"#include <gtk/gtk.h> #pragma GCC diagnostic error "-Wstrict-prototypes" + +struct perf_gtk_context { +GtkWidget *main_window; +}; + +extern struct perf_gtk_context *pgctx; + +static inline bool perf_gtk__is_active_context (struct perf_gtk_context *ctx) +{ +return ctx && ctx->main_window; +} + +struct perf_gtk_context *perf_gtk__activate_context (GtkWidget *window); +int perf_gtk__deactivate_context (struct perf_gtk_context **ctx); +#endif /* _PERF_GTK_H_ */
tools/perf/ui/gtk/util.c +23 -0
@@ -3,6 +3,29 @@#include "gtk.h" +struct perf_gtk_context *pgctx; + +struct perf_gtk_context *perf_gtk__activate_context (GtkWidget *window) +{ +struct perf_gtk_context *ctx; + + ctx =malloc (sizeof (*pgctx)); +if (ctx) + ctx->main_window = window; + +return ctx; +} + +int perf_gtk__deactivate_context (struct perf_gtk_context **ctx) +{ +if (!perf_gtk__is_active_context (*ctx)) +return -1 ; + +free (*ctx); + *ctx =NULL ; +return 0 ; +} +/* * FIXME: Functions below should be implemented properly. * For now, just add stubs for NO_NEWT=1 build.
PATCH 5/7 perf ui/gtk: Add GTK statusbar widget to browser window
In reply to Namhyung KimAdd statusbar widget to display non-critical messages at the bottom of the window. This can be used for showing a status change, warning or help message.
--- tools/perf/ui/gtk/browser.c | 26 +++++++++++++++++++++++++- tools/perf/ui/gtk/gtk.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-)
tools/perf/ui/gtk/browser.c +25 -1
@@ -122,13 +122,30 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)gtk_container_add (GTK_CONTAINER (window), view); } +static GtkWidget *perf_gtk__setup_statusbar (void ) +{ +GtkWidget *stbar; +unsigned ctxid; + + stbar =gtk_statusbar_new (); + + ctxid =gtk_statusbar_get_context_id (GTK_STATUSBAR (stbar), +"perf report" ); + pgctx->statbar = stbar; + pgctx->statbar_ctx_id = ctxid; + +return stbar; +} +int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help__used ,void (*timer) (void *arg)__used ,void *arg__used ,int delay_secs__used ) {struct perf_evsel *pos; +GtkWidget *vbox;GtkWidget *notebook; +GtkWidget *statbar;GtkWidget *window;signal (SIGSEGV , perf_gtk__signal);
@@ -147,6 +164,8 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,if (!pgctx)return -1 ; + vbox =gtk_vbox_new (FALSE,0 ); + notebook =gtk_notebook_new ();list_for_each_entry (pos, &evlist->entries, node) {
@@ -168,7 +187,12 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_window, tab_label); } -gtk_container_add (GTK_CONTAINER (window), notebook); +gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE,0 ); + + statbar =perf_gtk__setup_statusbar (); +gtk_box_pack_start (GTK_BOX (vbox), statbar, FALSE, FALSE,0 ); + +gtk_container_add (GTK_CONTAINER (window), vbox);gtk_widget_show_all (window);
tools/perf/ui/gtk/gtk.h +2 -0
@@ -10,6 +10,8 @@struct perf_gtk_context {GtkWidget *main_window; +GtkWidget *statbar; +guint statbar_ctx_id; };extern struct perf_gtk_context *pgctx;
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui/gtk: Add GTK statusbar widget to browser window
Commit-ID: b4418c6848dcd56cc90625dcfaef7cb019492233 Gitweb: http://git.kernel.org/tip/b4418c6848dcd56cc90625dcfaef7cb019492233 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 29 May 2012 13:23:00 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 19 Jun 2012 13:06:19 -0300
perf ui/gtk: Add GTK statusbar widget to browser window
Add statusbar widget to display non-critical messages at the bottom of the window. This can be used for showing a status change, warning or help message.
--- tools/perf/ui/gtk/browser.c | 26 +++++++++++++++++++++++++- tools/perf/ui/gtk/gtk.h | 2 ++ 2 files changed, 27 insertions(+), 1 deletions(-)
tools/perf/ui/gtk/browser.c +25 -1
@@ -122,13 +122,30 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)gtk_container_add (GTK_CONTAINER (window), view); } +static GtkWidget *perf_gtk__setup_statusbar (void ) +{ +GtkWidget *stbar; +unsigned ctxid; + + stbar =gtk_statusbar_new (); + + ctxid =gtk_statusbar_get_context_id (GTK_STATUSBAR (stbar), +"perf report" ); + pgctx->statbar = stbar; + pgctx->statbar_ctx_id = ctxid; + +return stbar; +} +int perf_evlist__gtk_browse_hists (struct perf_evlist *evlist,const char *help__used ,void (*timer) (void *arg)__used ,void *arg__used ,int delay_secs__used ) {struct perf_evsel *pos; +GtkWidget *vbox;GtkWidget *notebook; +GtkWidget *statbar;GtkWidget *window;signal (SIGSEGV , perf_gtk__signal);
@@ -147,6 +164,8 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,if (!pgctx)return -1 ; + vbox =gtk_vbox_new (FALSE,0 ); + notebook =gtk_notebook_new ();list_for_each_entry (pos, &evlist->entries, node) {
@@ -168,7 +187,12 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,gtk_notebook_append_page (GTK_NOTEBOOK (notebook), scrolled_window, tab_label); } -gtk_container_add (GTK_CONTAINER (window), notebook); +gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE,0 ); + + statbar =perf_gtk__setup_statusbar (); +gtk_box_pack_start (GTK_BOX (vbox), statbar, FALSE, FALSE,0 ); + +gtk_container_add (GTK_CONTAINER (window), vbox);gtk_widget_show_all (window);
tools/perf/ui/gtk/gtk.h +2 -0
@@ -10,6 +10,8 @@struct perf_gtk_context {GtkWidget *main_window; +GtkWidget *statbar; +guint statbar_ctx_id; };extern struct perf_gtk_context *pgctx;
PATCH 6/7 perf ui/gtk: Add GTK info_bar widget to browser window
In reply to Namhyung KimThe GtkInfoBar is a modern UI component to display messages without bothering the main window. It'll be used for showing a warning message.
As the GtkInfoBar requires 2.18 (or newer) version of GTK+ library, add availability check to Makefile too.
--- tools/perf/Makefile | 3 +++ tools/perf/config/feature-tests.mak | 13 +++++++++++++ tools/perf/ui/gtk/browser.c | 33 +++++++++++++++++++++++++++++++++ tools/perf/ui/gtk/gtk.h | 12 ++++++++++++ 4 files changed, 61 insertions(+)
tools/perf/Makefile +3 -0
@@ -523,6 +523,9 @@ else msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); BASIC_CFLAGS += -DNO_GTK2_SUPPORT else + ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y) + BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR + endif BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0) EXTLIBS += $(shell pkg-config --libs gtk+-2.0) LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
tools/perf/config/feature-tests.mak +13 -0
@@ -78,6 +78,19 @@ int main(int argc, char *argv[]) return 0; } endef + +define SOURCE_GTK2_INFOBAR +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" +#include <gtk/gtk.h> +#pragma GCC diagnostic error \"-Wstrict-prototypes\" + +int main(void) +{ + gtk_info_bar_new(); + + return 0; +} +endef endif ifndef NO_LIBPERL
tools/perf/ui/gtk/browser.c +33 -0
@@ -122,6 +122,34 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)gtk_container_add (GTK_CONTAINER (window), view); } +#ifdef HAVE_GTK_INFO_BAR +static GtkWidget *perf_gtk__setup_info_bar (void ) +{ +GtkWidget *info_bar; +GtkWidget *label; +GtkWidget *content_area; + + info_bar =gtk_info_bar_new (); +gtk_widget_set_no_show_all (info_bar, TRUE); + + label =gtk_label_new ("" ); +gtk_widget_show (label); + + content_area =gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)); +gtk_container_add (GTK_CONTAINER (content_area), label); + +gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),GTK_STOCK_OK , +GTK_RESPONSE_OK ); +g_signal_connect (info_bar,"response" , +G_CALLBACK (gtk_widget_hide),NULL ); + + pgctx->info_bar = info_bar; + pgctx->message_label = label; + +return info_bar; +} +#endif +static GtkWidget *perf_gtk__setup_statusbar (void ) {GtkWidget *stbar;
@@ -145,6 +173,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,struct perf_evsel *pos;GtkWidget *vbox;GtkWidget *notebook; +GtkWidget *info_bar;GtkWidget *statbar;GtkWidget *window;
@@ -189,6 +218,10 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE,0 ); + info_bar =perf_gtk__setup_info_bar (); +if (info_bar) +gtk_box_pack_start (GTK_BOX (vbox), info_bar, FALSE, FALSE,0 ); + statbar =perf_gtk__setup_statusbar ();gtk_box_pack_start (GTK_BOX (vbox), statbar, FALSE, FALSE,0 );
tools/perf/ui/gtk/gtk.h +12 -0
@@ -10,6 +10,11 @@struct perf_gtk_context {GtkWidget *main_window; + +#ifdef HAVE_GTK_INFO_BAR +GtkWidget *info_bar; +GtkWidget *message_label; +#endif GtkWidget *statbar;guint statbar_ctx_id; };
@@ -24,4 +29,11 @@ static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)struct perf_gtk_context *perf_gtk__activate_context (GtkWidget *window);int perf_gtk__deactivate_context (struct perf_gtk_context **ctx); +#ifndef HAVE_GTK_INFO_BAR +static inline GtkWidget *perf_gtk__setup_info_bar (void ) +{ +return NULL ; +} +#endif +#endif /* _PERF_GTK_H_ */
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui/gtk: Add GTK info_bar widget to browser window
Commit-ID: a6b702c117f839023814c1e03453c701d26de522 Gitweb: http://git.kernel.org/tip/a6b702c117f839023814c1e03453c701d26de522 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 29 May 2012 13:23:01 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 19 Jun 2012 13:06:19 -0300
perf ui/gtk: Add GTK info_bar widget to browser window
The GtkInfoBar is a modern UI component to display messages without bothering the main window. It'll be used for showing a warning message.
As the GtkInfoBar requires 2.18 (or newer) version of GTK+ library, add availability check to Makefile too.
--- tools/perf/Makefile | 3 +++ tools/perf/config/feature-tests.mak | 13 +++++++++++++ tools/perf/ui/gtk/browser.c | 33 +++++++++++++++++++++++++++++++++ tools/perf/ui/gtk/gtk.h | 12 ++++++++++++ 4 files changed, 61 insertions(+), 0 deletions(-)
tools/perf/Makefile +3 -0
@@ -523,6 +523,9 @@ else msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); BASIC_CFLAGS += -DNO_GTK2_SUPPORT else + ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y) + BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR + endif BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0) EXTLIBS += $(shell pkg-config --libs gtk+-2.0) LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
tools/perf/config/feature-tests.mak +13 -0
@@ -78,6 +78,19 @@ int main(int argc, char *argv[]) return 0; } endef + +define SOURCE_GTK2_INFOBAR +#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" +#include <gtk/gtk.h> +#pragma GCC diagnostic error \"-Wstrict-prototypes\" + +int main(void) +{ + gtk_info_bar_new(); + + return 0; +} +endef endif ifndef NO_LIBPERL
tools/perf/ui/gtk/browser.c +33 -0
@@ -122,6 +122,34 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists)gtk_container_add (GTK_CONTAINER (window), view); } +#ifdef HAVE_GTK_INFO_BAR +static GtkWidget *perf_gtk__setup_info_bar (void ) +{ +GtkWidget *info_bar; +GtkWidget *label; +GtkWidget *content_area; + + info_bar =gtk_info_bar_new (); +gtk_widget_set_no_show_all (info_bar, TRUE); + + label =gtk_label_new ("" ); +gtk_widget_show (label); + + content_area =gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar)); +gtk_container_add (GTK_CONTAINER (content_area), label); + +gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),GTK_STOCK_OK , +GTK_RESPONSE_OK ); +g_signal_connect (info_bar,"response" , +G_CALLBACK (gtk_widget_hide),NULL ); + + pgctx->info_bar = info_bar; + pgctx->message_label = label; + +return info_bar; +} +#endif +static GtkWidget *perf_gtk__setup_statusbar (void ) {GtkWidget *stbar;
@@ -145,6 +173,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,struct perf_evsel *pos;GtkWidget *vbox;GtkWidget *notebook; +GtkWidget *info_bar;GtkWidget *statbar;GtkWidget *window;
@@ -189,6 +218,10 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,gtk_box_pack_start (GTK_BOX (vbox), notebook, TRUE, TRUE,0 ); + info_bar =perf_gtk__setup_info_bar (); +if (info_bar) +gtk_box_pack_start (GTK_BOX (vbox), info_bar, FALSE, FALSE,0 ); + statbar =perf_gtk__setup_statusbar ();gtk_box_pack_start (GTK_BOX (vbox), statbar, FALSE, FALSE,0 );
tools/perf/ui/gtk/gtk.h +12 -0
@@ -10,6 +10,11 @@struct perf_gtk_context {GtkWidget *main_window; + +#ifdef HAVE_GTK_INFO_BAR +GtkWidget *info_bar; +GtkWidget *message_label; +#endif GtkWidget *statbar;guint statbar_ctx_id; };
@@ -24,4 +29,11 @@ static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)struct perf_gtk_context *perf_gtk__activate_context (GtkWidget *window);int perf_gtk__deactivate_context (struct perf_gtk_context **ctx); +#ifndef HAVE_GTK_INFO_BAR +static inline GtkWidget *perf_gtk__setup_info_bar (void ) +{ +return NULL ; +} +#endif +#endif /* _PERF_GTK_H_ */
PATCH 7/7 perf ui/gtk: Use struct perf_error_ops
In reply to Namhyung KimDefine and use perf_gtk_eops to provide a GTK2 message dialog for error reporting and a info_bar for warning.
As GtkInfoBar requires recent GTK+ libraries, provides a fallback implementation using statusbar widget too.
--- tools/perf/ui/gtk/setup.c | 5 +++ tools/perf/ui/gtk/util.c | 86 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+)
tools/perf/ui/gtk/setup.c +5 -0
@@ -1,12 +1,17 @@#include "gtk.h" #include "../../util/cache.h" +#include "../../util/debug.h" + +extern struct perf_error_ops perf_gtk_eops;int perf_gtk__init (void ) { +perf_error__register (&perf_gtk_eops);return gtk_init_check (NULL ,NULL ) ?0 :-1 ; }void perf_gtk__exit (bool wait_for_ok__used ) { +perf_error__unregister (&perf_gtk_eops);gtk_main_quit (); }
tools/perf/ui/gtk/util.c +86 -0
98 lines not on this page · raw message
Signature · 1 line
1.7.9.2
[tip:perf/core] perf ui/gtk: Use struct perf_error_ops
Commit-ID: e078ba14dff5c315ce19a978574883f417d2cfa0 Gitweb: http://git.kernel.org/tip/e078ba14dff5c315ce19a978574883f417d2cfa0 Author: Namhyung Kim <[email protected]> AuthorDate: Tue, 29 May 2012 13:23:02 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 19 Jun 2012 13:06:19 -0300
perf ui/gtk: Use struct perf_error_ops
Define and use perf_gtk_eops to provide a GTK2 message dialog for error reporting and a info_bar for warning.
As GtkInfoBar requires recent GTK+ libraries, provides a fallback implementation using statusbar widget too.
--- tools/perf/ui/gtk/setup.c | 5 +++ tools/perf/ui/gtk/util.c | 86 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 0 deletions(-)
tools/perf/ui/gtk/setup.c +5 -0
@@ -1,12 +1,17 @@#include "gtk.h" #include "../../util/cache.h" +#include "../../util/debug.h" + +extern struct perf_error_ops perf_gtk_eops;int perf_gtk__init (void ) { +perf_error__register (&perf_gtk_eops);return gtk_init_check (NULL ,NULL ) ?0 :-1 ; }void perf_gtk__exit (bool wait_for_ok__used ) { +perf_error__unregister (&perf_gtk_eops);gtk_main_quit (); }
tools/perf/ui/gtk/util.c +86 -0
98 lines not on this page · raw message
Em Tue, May 29, 2012 at 01:22:55PM +0900, Namhyung Kim escreveu:
Quoted 6 lines
Hi,
This patchset implements ui__warning/error() functions for GTK2. Patch 1 is a resend (which forgot to cc LKML) and independent of this series. Patch 2 converts invocations of
ui__warningfollowed by exit (or similar effect) intoui__error.
Pekka, all well with you? Acked-by?
- Arnaldo
Pekka Enberg
Acked-byQuoted 9 lines · Arnaldo Carvalho de Melo
Em Tue, May 29, 2012 at 01:22:55PM +0900, Namhyung Kim escreveu:
Quoted 6 lines
Hi,
This patchset implements ui__warning/error() functions for GTK2. Patch 1 is a resend (which forgot to cc LKML) and independent of this series. Patch 2 converts invocations of
ui__warningfollowed by exit (or similar effect) intoui__error.Pekka, all well with you? Acked-by?
Looks good to me!