Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 312264
b: refs/heads/master
c: 42ab68a
h: refs/heads/master
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Jun 19, 2012
1 parent 3af7896 commit a0d828a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba47a142d9f9b84e0464a11b7a067e5ad95c5d4b
refs/heads/master: 42ab68a35ffee04700648ec42c9507145a66837d
8 changes: 7 additions & 1 deletion trunk/tools/perf/ui/gtk/browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

static void perf_gtk__signal(int sig)
{
perf_gtk__exit(false);
psignal(sig, "perf");
gtk_main_quit();
}

static void perf_gtk__resize_window(GtkWidget *window)
Expand Down Expand Up @@ -143,6 +143,10 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,

g_signal_connect(window, "delete_event", gtk_main_quit, NULL);

pgctx = perf_gtk__activate_context(window);
if (!pgctx)
return -1;

notebook = gtk_notebook_new();

list_for_each_entry(pos, &evlist->entries, node) {
Expand Down Expand Up @@ -174,5 +178,7 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist,

gtk_main();

perf_gtk__deactivate_context(&pgctx);

return 0;
}
17 changes: 17 additions & 0 deletions trunk/tools/perf/ui/gtk/gtk.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
#ifndef _PERF_GTK_H_
#define _PERF_GTK_H_ 1

#include <stdbool.h>

#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#include <gtk/gtk.h>
#pragma GCC diagnostic error "-Wstrict-prototypes"


struct perf_gtk_context {
GtkWidget *main_window;
};

extern struct perf_gtk_context *pgctx;

static inline bool perf_gtk__is_active_context(struct perf_gtk_context *ctx)
{
return ctx && ctx->main_window;
}

struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window);
int perf_gtk__deactivate_context(struct perf_gtk_context **ctx);

#endif /* _PERF_GTK_H_ */
23 changes: 23 additions & 0 deletions trunk/tools/perf/ui/gtk/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
#include "gtk.h"


struct perf_gtk_context *pgctx;

struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window)
{
struct perf_gtk_context *ctx;

ctx = malloc(sizeof(*pgctx));
if (ctx)
ctx->main_window = window;

return ctx;
}

int perf_gtk__deactivate_context(struct perf_gtk_context **ctx)
{
if (!perf_gtk__is_active_context(*ctx))
return -1;

free(*ctx);
*ctx = NULL;
return 0;
}

/*
* FIXME: Functions below should be implemented properly.
* For now, just add stubs for NO_NEWT=1 build.
Expand Down

0 comments on commit a0d828a

Please sign in to comment.