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