aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@gmail.com>2012-05-29 00:22:59 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-06-19 12:06:18 -0400
commit42ab68a35ffee04700648ec42c9507145a66837d (patch)
treed447878f8831a472534cddac6cdd5f2e23d5be92 /tools/perf/ui
parentba47a142d9f9b84e0464a11b7a067e5ad95c5d4b (diff)
perf ui/gtk: Introduce struct perf_gtk_context
The struct perf_gtk_context is for tracking current state of GTK window and/or other things. This is a preparation of next changes. Signed-off-by: Namhyung Kim <namhyung@gmail.com> Acked-by: Pekka Enberg <penberg@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1338265382-6872-5-git-send-email-namhyung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/gtk/browser.c8
-rw-r--r--tools/perf/ui/gtk/gtk.h17
-rw-r--r--tools/perf/ui/gtk/util.c23
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
12static void perf_gtk__signal(int sig) 12static 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
18static void perf_gtk__resize_window(GtkWidget *window) 18static 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
11struct perf_gtk_context {
12 GtkWidget *main_window;
13};
14
15extern struct perf_gtk_context *pgctx;
16
17static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)
18{
19 return ctx && ctx->main_window;
20}
21
22struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);
23int 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
6struct perf_gtk_context *pgctx;
7
8struct 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
19int 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.