diff options
-rw-r--r-- | tools/perf/ui/gtk/browser.c | 8 | ||||
-rw-r--r-- | tools/perf/ui/gtk/gtk.h | 17 | ||||
-rw-r--r-- | tools/perf/ui/gtk/util.c | 23 |
3 files changed, 47 insertions, 1 deletions
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c index 0656c381a89c..33ab1aee3472 100644 --- a/tools/perf/ui/gtk/browser.c +++ b/tools/perf/ui/gtk/browser.c | |||
@@ -11,8 +11,8 @@ | |||
11 | 11 | ||
12 | static void perf_gtk__signal(int sig) | 12 | static void perf_gtk__signal(int sig) |
13 | { | 13 | { |
14 | perf_gtk__exit(false); | ||
14 | psignal(sig, "perf"); | 15 | psignal(sig, "perf"); |
15 | gtk_main_quit(); | ||
16 | } | 16 | } |
17 | 17 | ||
18 | static void perf_gtk__resize_window(GtkWidget *window) | 18 | static void perf_gtk__resize_window(GtkWidget *window) |
@@ -143,6 +143,10 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, | |||
143 | 143 | ||
144 | g_signal_connect(window, "delete_event", gtk_main_quit, NULL); | 144 | g_signal_connect(window, "delete_event", gtk_main_quit, NULL); |
145 | 145 | ||
146 | pgctx = perf_gtk__activate_context(window); | ||
147 | if (!pgctx) | ||
148 | return -1; | ||
149 | |||
146 | notebook = gtk_notebook_new(); | 150 | notebook = gtk_notebook_new(); |
147 | 151 | ||
148 | list_for_each_entry(pos, &evlist->entries, node) { | 152 | list_for_each_entry(pos, &evlist->entries, node) { |
@@ -174,5 +178,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, | |||
174 | 178 | ||
175 | gtk_main(); | 179 | gtk_main(); |
176 | 180 | ||
181 | perf_gtk__deactivate_context(&pgctx); | ||
182 | |||
177 | return 0; | 183 | return 0; |
178 | } | 184 | } |
diff --git a/tools/perf/ui/gtk/gtk.h b/tools/perf/ui/gtk/gtk.h index 75177ee04032..34fbca6d48a2 100644 --- a/tools/perf/ui/gtk/gtk.h +++ b/tools/perf/ui/gtk/gtk.h | |||
@@ -1,8 +1,25 @@ | |||
1 | #ifndef _PERF_GTK_H_ | 1 | #ifndef _PERF_GTK_H_ |
2 | #define _PERF_GTK_H_ 1 | 2 | #define _PERF_GTK_H_ 1 |
3 | 3 | ||
4 | #include <stdbool.h> | ||
5 | |||
4 | #pragma GCC diagnostic ignored "-Wstrict-prototypes" | 6 | #pragma GCC diagnostic ignored "-Wstrict-prototypes" |
5 | #include <gtk/gtk.h> | 7 | #include <gtk/gtk.h> |
6 | #pragma GCC diagnostic error "-Wstrict-prototypes" | 8 | #pragma GCC diagnostic error "-Wstrict-prototypes" |
7 | 9 | ||
10 | |||
11 | struct perf_gtk_context { | ||
12 | GtkWidget *main_window; | ||
13 | }; | ||
14 | |||
15 | extern struct perf_gtk_context *pgctx; | ||
16 | |||
17 | static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx) | ||
18 | { | ||
19 | return ctx && ctx->main_window; | ||
20 | } | ||
21 | |||
22 | struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window); | ||
23 | int perf_gtk__deactivate_context(struct perf_gtk_context **ctx); | ||
24 | |||
8 | #endif /* _PERF_GTK_H_ */ | 25 | #endif /* _PERF_GTK_H_ */ |
diff --git a/tools/perf/ui/gtk/util.c b/tools/perf/ui/gtk/util.c index a727fe394e91..6fe13fdc513e 100644 --- a/tools/perf/ui/gtk/util.c +++ b/tools/perf/ui/gtk/util.c | |||
@@ -3,6 +3,29 @@ | |||
3 | #include "gtk.h" | 3 | #include "gtk.h" |
4 | 4 | ||
5 | 5 | ||
6 | struct perf_gtk_context *pgctx; | ||
7 | |||
8 | struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window) | ||
9 | { | ||
10 | struct perf_gtk_context *ctx; | ||
11 | |||
12 | ctx = malloc(sizeof(*pgctx)); | ||
13 | if (ctx) | ||
14 | ctx->main_window = window; | ||
15 | |||
16 | return ctx; | ||
17 | } | ||
18 | |||
19 | int perf_gtk__deactivate_context(struct perf_gtk_context **ctx) | ||
20 | { | ||
21 | if (!perf_gtk__is_active_context(*ctx)) | ||
22 | return -1; | ||
23 | |||
24 | free(*ctx); | ||
25 | *ctx = NULL; | ||
26 | return 0; | ||
27 | } | ||
28 | |||
6 | /* | 29 | /* |
7 | * FIXME: Functions below should be implemented properly. | 30 | * FIXME: Functions below should be implemented properly. |
8 | * For now, just add stubs for NO_NEWT=1 build. | 31 | * For now, just add stubs for NO_NEWT=1 build. |