blob: c95012cdb4387f95a4125f7da3f58cf224f33dc8 [file] [log] [blame]
Pekka Enbergc31a9452012-03-19 15:13:29 -03001#include "../evlist.h"
2#include "../cache.h"
3#include "../evsel.h"
4#include "../sort.h"
5#include "../hist.h"
Namhyung Kimed70c602012-08-16 17:14:53 +09006#include "../helpline.h"
Pekka Enbergc31a9452012-03-19 15:13:29 -03007#include "gtk.h"
8
9#include <signal.h>
10
Namhyung Kim0da41ce92012-12-21 17:20:13 +090011void perf_gtk__signal(int sig)
Pekka Enbergc31a9452012-03-19 15:13:29 -030012{
Namhyung Kim42ab68a2012-05-29 13:22:59 +090013 perf_gtk__exit(false);
Pekka Enbergc31a9452012-03-19 15:13:29 -030014 psignal(sig, "perf");
Pekka Enbergc31a9452012-03-19 15:13:29 -030015}
16
Namhyung Kim0da41ce92012-12-21 17:20:13 +090017void perf_gtk__resize_window(GtkWidget *window)
Pekka Enbergc31a9452012-03-19 15:13:29 -030018{
19 GdkRectangle rect;
20 GdkScreen *screen;
21 int monitor;
22 int height;
23 int width;
24
25 screen = gtk_widget_get_screen(window);
26
27 monitor = gdk_screen_get_monitor_at_window(screen, window->window);
28
29 gdk_screen_get_monitor_geometry(screen, monitor, &rect);
30
31 width = rect.width * 3 / 4;
32 height = rect.height * 3 / 4;
33
34 gtk_window_resize(GTK_WINDOW(window), width, height);
35}
36
Namhyung Kim0da41ce92012-12-21 17:20:13 +090037const char *perf_gtk__get_percent_color(double percent)
Namhyung Kim12ceade2012-09-03 11:53:10 +090038{
39 if (percent >= MIN_RED)
40 return "<span fgcolor='red'>";
41 if (percent >= MIN_GREEN)
42 return "<span fgcolor='dark green'>";
43 return NULL;
44}
45
Namhyung Kima6b702c2012-05-29 13:23:01 +090046#ifdef HAVE_GTK_INFO_BAR
Namhyung Kim0da41ce92012-12-21 17:20:13 +090047GtkWidget *perf_gtk__setup_info_bar(void)
Namhyung Kima6b702c2012-05-29 13:23:01 +090048{
49 GtkWidget *info_bar;
50 GtkWidget *label;
51 GtkWidget *content_area;
52
53 info_bar = gtk_info_bar_new();
54 gtk_widget_set_no_show_all(info_bar, TRUE);
55
56 label = gtk_label_new("");
57 gtk_widget_show(label);
58
59 content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
60 gtk_container_add(GTK_CONTAINER(content_area), label);
61
62 gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_OK,
63 GTK_RESPONSE_OK);
64 g_signal_connect(info_bar, "response",
65 G_CALLBACK(gtk_widget_hide), NULL);
66
67 pgctx->info_bar = info_bar;
68 pgctx->message_label = label;
69
70 return info_bar;
71}
72#endif
73
Namhyung Kim0da41ce92012-12-21 17:20:13 +090074GtkWidget *perf_gtk__setup_statusbar(void)
Namhyung Kimb4418c62012-05-29 13:23:00 +090075{
76 GtkWidget *stbar;
77 unsigned ctxid;
78
79 stbar = gtk_statusbar_new();
80
81 ctxid = gtk_statusbar_get_context_id(GTK_STATUSBAR(stbar),
82 "perf report");
83 pgctx->statbar = stbar;
84 pgctx->statbar_ctx_id = ctxid;
85
86 return stbar;
87}