4 #include "../util/cache.h"
5 #include "../util/debug.h"
6 #include "../util/hist.h"
7 #include "../util/util.h"
9 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
10 void *perf_gtk_handle;
13 #ifdef HAVE_GTK2_SUPPORT
14 static int setup_gtk_browser(void)
16 int (*perf_ui_init)(void);
21 perf_gtk_handle = dlopen(PERF_GTK_DSO, RTLD_LAZY);
22 if (perf_gtk_handle == NULL) {
24 scnprintf(buf, sizeof(buf), "%s/%s", LIBDIR, PERF_GTK_DSO);
25 perf_gtk_handle = dlopen(buf, RTLD_LAZY);
27 if (perf_gtk_handle == NULL)
30 perf_ui_init = dlsym(perf_gtk_handle, "perf_gtk__init");
31 if (perf_ui_init == NULL)
34 if (perf_ui_init() == 0)
38 dlclose(perf_gtk_handle);
42 static void exit_gtk_browser(bool wait_for_ok)
44 void (*perf_ui_exit)(bool);
46 if (perf_gtk_handle == NULL)
49 perf_ui_exit = dlsym(perf_gtk_handle, "perf_gtk__exit");
50 if (perf_ui_exit == NULL)
53 perf_ui_exit(wait_for_ok);
56 dlclose(perf_gtk_handle);
58 perf_gtk_handle = NULL;
61 static inline int setup_gtk_browser(void) { return -1; }
62 static inline void exit_gtk_browser(bool wait_for_ok __maybe_unused) {}
65 int stdio__config_color(const struct option *opt __maybe_unused,
66 const char *mode, int unset __maybe_unused)
68 perf_use_color_default = perf_config_colorbool("color.ui", mode, -1);
72 void setup_browser(bool fallback_to_pager)
74 if (use_browser < 2 && (!isatty(1) || dump_trace))
81 switch (use_browser) {
83 if (setup_gtk_browser() == 0)
85 printf("GTK browser requested but could not find %s\n",
96 if (fallback_to_pager)
102 void exit_browser(bool wait_for_ok)
104 switch (use_browser) {
106 exit_gtk_browser(wait_for_ok);
110 ui__exit(wait_for_ok);