blob: 791fb15ce3507c2d42d695be12c1f87a16affa0f [file] [log] [blame]
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -03001#include "../cache.h"
2#include "../debug.h"
Arnaldo Carvalho de Melo5c35d692011-02-09 11:38:43 -02003
Arnaldo Carvalho de Melo3f7247e2011-10-18 13:45:16 -02004
Arnaldo Carvalho de Melo229ade92011-01-31 18:08:39 -02005void setup_browser(bool fallback_to_pager)
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -03006{
Namhyung Kim281ef542012-04-30 13:55:08 +09007 if (!isatty(1) || dump_trace)
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -03008 use_browser = 0;
Namhyung Kim281ef542012-04-30 13:55:08 +09009
10 /* default to TUI */
11 if (use_browser < 0)
12 use_browser = 1;
13
14 switch (use_browser) {
15 case 2:
Namhyung Kimdc41b9b2012-04-30 13:55:09 +090016 if (perf_gtk__init() == 0)
17 break;
18 /* fall through */
Namhyung Kim281ef542012-04-30 13:55:08 +090019 case 1:
Namhyung Kimdc41b9b2012-04-30 13:55:09 +090020 use_browser = 1;
21 if (ui__init() == 0)
22 break;
23 /* fall through */
Namhyung Kim281ef542012-04-30 13:55:08 +090024 default:
Namhyung Kim21f0d422012-05-28 23:53:22 +090025 use_browser = 0;
Arnaldo Carvalho de Melo229ade92011-01-31 18:08:39 -020026 if (fallback_to_pager)
27 setup_pager();
Namhyung Kim281ef542012-04-30 13:55:08 +090028 break;
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030029 }
Arnaldo Carvalho de Melo1e6dd072010-08-10 15:58:50 -030030}
31
32void exit_browser(bool wait_for_ok)
33{
Namhyung Kim281ef542012-04-30 13:55:08 +090034 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 Melo1e6dd072010-08-10 15:58:50 -030045 }
46}