1*0985a948SNamhyung Kim #include <pthread.h> 2*0985a948SNamhyung Kim 3aca7a94dSNamhyung Kim #include "../cache.h" 4aca7a94dSNamhyung Kim #include "../debug.h" 5aca7a94dSNamhyung Kim 6aca7a94dSNamhyung Kim 7*0985a948SNamhyung Kim pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER; 8*0985a948SNamhyung Kim 9aca7a94dSNamhyung Kim void setup_browser(bool fallback_to_pager) 10aca7a94dSNamhyung Kim { 11281ef544SNamhyung Kim if (!isatty(1) || dump_trace) 12aca7a94dSNamhyung Kim use_browser = 0; 13281ef544SNamhyung Kim 14281ef544SNamhyung Kim /* default to TUI */ 15281ef544SNamhyung Kim if (use_browser < 0) 16281ef544SNamhyung Kim use_browser = 1; 17281ef544SNamhyung Kim 18281ef544SNamhyung Kim switch (use_browser) { 19281ef544SNamhyung Kim case 2: 20dc41b9b8SNamhyung Kim if (perf_gtk__init() == 0) 21281ef544SNamhyung Kim break; 22dc41b9b8SNamhyung Kim /* fall through */ 23281ef544SNamhyung Kim case 1: 24dc41b9b8SNamhyung Kim use_browser = 1; 25dc41b9b8SNamhyung Kim if (ui__init() == 0) 26281ef544SNamhyung Kim break; 27dc41b9b8SNamhyung Kim /* fall through */ 28281ef544SNamhyung Kim default: 2921f0d423SNamhyung Kim use_browser = 0; 30aca7a94dSNamhyung Kim if (fallback_to_pager) 31aca7a94dSNamhyung Kim setup_pager(); 32281ef544SNamhyung Kim break; 33aca7a94dSNamhyung Kim } 34aca7a94dSNamhyung Kim } 35aca7a94dSNamhyung Kim 36aca7a94dSNamhyung Kim void exit_browser(bool wait_for_ok) 37aca7a94dSNamhyung Kim { 38281ef544SNamhyung Kim switch (use_browser) { 39281ef544SNamhyung Kim case 2: 40281ef544SNamhyung Kim perf_gtk__exit(wait_for_ok); 41281ef544SNamhyung Kim break; 42281ef544SNamhyung Kim 43281ef544SNamhyung Kim case 1: 44281ef544SNamhyung Kim ui__exit(wait_for_ok); 45281ef544SNamhyung Kim break; 46281ef544SNamhyung Kim 47281ef544SNamhyung Kim default: 48281ef544SNamhyung Kim break; 49aca7a94dSNamhyung Kim } 50aca7a94dSNamhyung Kim } 51