diff options
Diffstat (limited to 'tools/perf/ui/setup.c')
-rw-r--r-- | tools/perf/ui/setup.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c new file mode 100644 index 000000000000..9f5f888f73e3 --- /dev/null +++ b/tools/perf/ui/setup.c | |||
@@ -0,0 +1,45 @@ | |||
1 | #include "../cache.h" | ||
2 | #include "../debug.h" | ||
3 | |||
4 | |||
5 | void setup_browser(bool fallback_to_pager) | ||
6 | { | ||
7 | if (!isatty(1) || dump_trace) | ||
8 | use_browser = 0; | ||
9 | |||
10 | /* default to TUI */ | ||
11 | if (use_browser < 0) | ||
12 | use_browser = 1; | ||
13 | |||
14 | switch (use_browser) { | ||
15 | case 2: | ||
16 | if (perf_gtk__init() == 0) | ||
17 | break; | ||
18 | /* fall through */ | ||
19 | case 1: | ||
20 | use_browser = 1; | ||
21 | if (ui__init() == 0) | ||
22 | break; | ||
23 | /* fall through */ | ||
24 | default: | ||
25 | if (fallback_to_pager) | ||
26 | setup_pager(); | ||
27 | break; | ||
28 | } | ||
29 | } | ||
30 | |||
31 | void exit_browser(bool wait_for_ok) | ||
32 | { | ||
33 | switch (use_browser) { | ||
34 | case 2: | ||
35 | perf_gtk__exit(wait_for_ok); | ||
36 | break; | ||
37 | |||
38 | case 1: | ||
39 | ui__exit(wait_for_ok); | ||
40 | break; | ||
41 | |||
42 | default: | ||
43 | break; | ||
44 | } | ||
45 | } | ||