browser.c 1.8 KB

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