xref: /linux/tools/perf/ui/setup.c (revision dc41b9b8f02dbe2228ae787d525dac43beebb7fa)
1aca7a94dSNamhyung Kim #include "../cache.h"
2aca7a94dSNamhyung Kim #include "../debug.h"
3aca7a94dSNamhyung Kim 
4aca7a94dSNamhyung Kim 
5aca7a94dSNamhyung Kim void setup_browser(bool fallback_to_pager)
6aca7a94dSNamhyung Kim {
7281ef544SNamhyung Kim 	if (!isatty(1) || dump_trace)
8aca7a94dSNamhyung Kim 		use_browser = 0;
9281ef544SNamhyung Kim 
10281ef544SNamhyung Kim 	/* default to TUI */
11281ef544SNamhyung Kim 	if (use_browser < 0)
12281ef544SNamhyung Kim 		use_browser = 1;
13281ef544SNamhyung Kim 
14281ef544SNamhyung Kim 	switch (use_browser) {
15281ef544SNamhyung Kim 	case 2:
16*dc41b9b8SNamhyung Kim 		if (perf_gtk__init() == 0)
17281ef544SNamhyung Kim 			break;
18*dc41b9b8SNamhyung Kim 		/* fall through */
19281ef544SNamhyung Kim 	case 1:
20*dc41b9b8SNamhyung Kim 		use_browser = 1;
21*dc41b9b8SNamhyung Kim 		if (ui__init() == 0)
22281ef544SNamhyung Kim 			break;
23*dc41b9b8SNamhyung Kim 		/* fall through */
24281ef544SNamhyung Kim 	default:
25aca7a94dSNamhyung Kim 		if (fallback_to_pager)
26aca7a94dSNamhyung Kim 			setup_pager();
27281ef544SNamhyung Kim 		break;
28aca7a94dSNamhyung Kim 	}
29aca7a94dSNamhyung Kim }
30aca7a94dSNamhyung Kim 
31aca7a94dSNamhyung Kim void exit_browser(bool wait_for_ok)
32aca7a94dSNamhyung Kim {
33281ef544SNamhyung Kim 	switch (use_browser) {
34281ef544SNamhyung Kim 	case 2:
35281ef544SNamhyung Kim 		perf_gtk__exit(wait_for_ok);
36281ef544SNamhyung Kim 		break;
37281ef544SNamhyung Kim 
38281ef544SNamhyung Kim 	case 1:
39281ef544SNamhyung Kim 		ui__exit(wait_for_ok);
40281ef544SNamhyung Kim 		break;
41281ef544SNamhyung Kim 
42281ef544SNamhyung Kim 	default:
43281ef544SNamhyung Kim 		break;
44aca7a94dSNamhyung Kim 	}
45aca7a94dSNamhyung Kim }
46