browser.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. #include <signal.h>
  10. void perf_gtk__signal(int sig)
  11. {
  12. perf_gtk__exit(false);
  13. psignal(sig, "perf");
  14. }
  15. void perf_gtk__resize_window(GtkWidget *window)
  16. {
  17. GdkRectangle rect;
  18. GdkScreen *screen;
  19. int monitor;
  20. int height;
  21. int width;
  22. screen = gtk_widget_get_screen(window);
  23. monitor = gdk_screen_get_monitor_at_window(screen, window->window);
  24. gdk_screen_get_monitor_geometry(screen, monitor, &rect);
  25. width = rect.width * 3 / 4;
  26. height = rect.height * 3 / 4;
  27. gtk_window_resize(GTK_WINDOW(window), width, height);
  28. }
  29. const char *perf_gtk__get_percent_color(double percent)
  30. {
  31. if (percent >= MIN_RED)
  32. return "<span fgcolor='red'>";
  33. if (percent >= MIN_GREEN)
  34. return "<span fgcolor='dark green'>";
  35. return NULL;
  36. }
  37. #ifdef HAVE_GTK_INFO_BAR_SUPPORT
  38. GtkWidget *perf_gtk__setup_info_bar(void)
  39. {
  40. GtkWidget *info_bar;
  41. GtkWidget *label;
  42. GtkWidget *content_area;
  43. info_bar = gtk_info_bar_new();
  44. gtk_widget_set_no_show_all(info_bar, TRUE);
  45. label = gtk_label_new("");
  46. gtk_widget_show(label);
  47. content_area = gtk_info_bar_get_content_area(GTK_INFO_BAR(info_bar));
  48. gtk_container_add(GTK_CONTAINER(content_area), label);
  49. gtk_info_bar_add_button(GTK_INFO_BAR(info_bar), GTK_STOCK_OK,
  50. GTK_RESPONSE_OK);
  51. g_signal_connect(info_bar, "response",
  52. G_CALLBACK(gtk_widget_hide), NULL);
  53. pgctx->info_bar = info_bar;
  54. pgctx->message_label = label;
  55. return info_bar;
  56. }
  57. #endif
  58. GtkWidget *perf_gtk__setup_statusbar(void)
  59. {
  60. GtkWidget *stbar;
  61. unsigned ctxid;
  62. stbar = gtk_statusbar_new();
  63. ctxid = gtk_statusbar_get_context_id(GTK_STATUSBAR(stbar),
  64. "perf report");
  65. pgctx->statbar = stbar;
  66. pgctx->statbar_ctx_id = ctxid;
  67. return stbar;
  68. }