Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 1 | #include "../cache.h" |
2 | #include "../debug.h" | ||||
Arnaldo Carvalho de Melo | 5c35d69 | 2011-02-09 11:38:43 -0200 | [diff] [blame] | 3 | |
Arnaldo Carvalho de Melo | 3f7247e | 2011-10-18 13:45:16 -0200 | [diff] [blame] | 4 | |
Arnaldo Carvalho de Melo | 229ade9 | 2011-01-31 18:08:39 -0200 | [diff] [blame] | 5 | void setup_browser(bool fallback_to_pager) |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 6 | { |
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 7 | if (!isatty(1) || dump_trace) |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 8 | use_browser = 0; |
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 9 | |
10 | /* default to TUI */ | ||||
11 | if (use_browser < 0) | ||||
12 | use_browser = 1; | ||||
13 | |||||
14 | switch (use_browser) { | ||||
15 | case 2: | ||||
Namhyung Kim | dc41b9b | 2012-04-30 13:55:09 +0900 | [diff] [blame] | 16 | if (perf_gtk__init() == 0) |
17 | break; | ||||
18 | /* fall through */ | ||||
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 19 | case 1: |
Namhyung Kim | dc41b9b | 2012-04-30 13:55:09 +0900 | [diff] [blame] | 20 | use_browser = 1; |
21 | if (ui__init() == 0) | ||||
22 | break; | ||||
23 | /* fall through */ | ||||
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 24 | default: |
Namhyung Kim | 21f0d42 | 2012-05-28 23:53:22 +0900 | [diff] [blame^] | 25 | use_browser = 0; |
Arnaldo Carvalho de Melo | 229ade9 | 2011-01-31 18:08:39 -0200 | [diff] [blame] | 26 | if (fallback_to_pager) |
27 | setup_pager(); | ||||
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 28 | break; |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 29 | } |
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 30 | } |
31 | |||||
32 | void exit_browser(bool wait_for_ok) | ||||
33 | { | ||||
Namhyung Kim | 281ef54 | 2012-04-30 13:55:08 +0900 | [diff] [blame] | 34 | switch (use_browser) { |
35 | case 2: | ||||
36 | perf_gtk__exit(wait_for_ok); | ||||
37 | break; | ||||
38 | |||||
39 | case 1: | ||||
40 | ui__exit(wait_for_ok); | ||||
41 | break; | ||||
42 | |||||
43 | default: | ||||
44 | break; | ||||
Arnaldo Carvalho de Melo | 1e6dd07 | 2010-08-10 15:58:50 -0300 | [diff] [blame] | 45 | } |
46 | } |