2010-08-10 15:58:50 -03:00
|
|
|
#include "../cache.h"
|
|
|
|
#include "../debug.h"
|
2011-10-25 13:45:16 -02:00
|
|
|
|
|
|
|
|
2012-04-30 13:55:08 +09:00
|
|
|
void setup_browser(bool fallback_to_pager)
|
2011-10-20 16:59:15 -02:00
|
|
|
{
|
2012-04-30 13:55:08 +09:00
|
|
|
if (!isatty(1) || dump_trace)
|
|
|
|
use_browser = 0;
|
2012-04-30 13:55:05 +09:00
|
|
|
|
2012-04-30 13:55:08 +09:00
|
|
|
/* default to TUI */
|
|
|
|
if (use_browser < 0)
|
|
|
|
use_browser = 1;
|
2012-04-30 13:55:05 +09:00
|
|
|
|
2012-04-30 13:55:08 +09:00
|
|
|
switch (use_browser) {
|
|
|
|
case 2:
|
2012-04-30 13:55:09 +09:00
|
|
|
if (perf_gtk__init() == 0)
|
|
|
|
break;
|
|
|
|
/* fall through */
|
2012-04-30 13:55:08 +09:00
|
|
|
case 1:
|
2012-04-30 13:55:09 +09:00
|
|
|
use_browser = 1;
|
|
|
|
if (ui__init() == 0)
|
|
|
|
break;
|
|
|
|
/* fall through */
|
2012-04-30 13:55:08 +09:00
|
|
|
default:
|
2012-05-28 23:53:22 +09:00
|
|
|
use_browser = 0;
|
2011-01-31 18:08:39 -02:00
|
|
|
if (fallback_to_pager)
|
|
|
|
setup_pager();
|
2012-04-30 13:55:08 +09:00
|
|
|
break;
|
2010-08-10 15:58:50 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void exit_browser(bool wait_for_ok)
|
|
|
|
{
|
2012-04-30 13:55:08 +09:00
|
|
|
switch (use_browser) {
|
|
|
|
case 2:
|
|
|
|
perf_gtk__exit(wait_for_ok);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
ui__exit(wait_for_ok);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2010-08-10 15:58:50 -03:00
|
|
|
}
|
|
|
|
}
|