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