linux/tools/perf/ui/gtk/browser.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2#include "../evlist.h"
   3#include "../cache.h"
   4#include "../evsel.h"
   5#include "../sort.h"
   6#include "../hist.h"
   7#include "../helpline.h"
   8#include "gtk.h"
   9
  10#include <signal.h>
  11
  12void perf_gtk__signal(int sig)
  13{
  14        perf_gtk__exit(false);
  15        psignal(sig, "perf");
  16}
  17
  18void perf_gtk__resize_window(GtkWidget *window)
  19{
  20        GdkRectangle rect;
  21        GdkScreen *screen;
  22        int monitor;
  23        int height;
  24        int width;
  25
  26        screen = gtk_widget_get_screen(window);
  27
  28        monitor = gdk_screen_get_monitor_at_window(screen, window->window);
  29
  30        gdk_screen_get_monitor_geometry(screen, monitor, &rect);
  31
  32        width   = rect.width * 3 / 4;
  33        height  = rect.height * 3 / 4;
  34
  35        gtk_window_resize(GTK_WINDOW(window), width, height);
  36}
  37
  38const char *perf_gtk__get_percent_color(double percent)
  39{
  40        if (percent >= MIN_RED)
  41                return "<span fgcolor='red'>";
  42        if (percent >= MIN_GREEN)
  43                return "<span fgcolor='dark green'>";
  44        return NULL;
  45}
  46
  47#ifdef HAVE_GTK_INFO_BAR_SUPPORT
  48GtkWidget *perf_gtk__setup_info_bar(void)
  49{
  50        GtkWidget *info_bar;
  51        GtkWidget *label;
  52        GtkWidget *content_area;
  53
  54        info_bar = gtk_info_bar_new();
  55        gtk_widget_set_no_show_all(info_bar, TRUE);
  56
  57        label = gtk_label_new("");
  58        gtk_widget_show(label);
  59
  60        content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
  61        gtk_container_add(GTK_CONTAINER(content_area), label);
  62
  63        gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_OK,
  64                                GTK_RESPONSE_OK);
  65        g_signal_connect(info_bar, "response",
  66                         G_CALLBACK(gtk_widget_hide), NULL);
  67
  68        pgctx->info_bar = info_bar;
  69        pgctx->message_label = label;
  70
  71        return info_bar;
  72}
  73#endif
  74
  75GtkWidget *perf_gtk__setup_statusbar(void)
  76{
  77        GtkWidget *stbar;
  78        unsigned ctxid;
  79
  80        stbar = gtk_statusbar_new();
  81
  82        ctxid = gtk_statusbar_get_context_id(GTK_STATUSBAR(stbar),
  83                                             "perf report");
  84        pgctx->statbar = stbar;
  85        pgctx->statbar_ctx_id = ctxid;
  86
  87        return stbar;
  88}
  89