2 #include "../../util/debug.h"
8 struct perf_gtk_context *pgctx;
10 struct perf_gtk_context *perf_gtk__activate_context(GtkWidget *window)
12 struct perf_gtk_context *ctx;
14 ctx = malloc(sizeof(*pgctx));
16 ctx->main_window = window;
21 int perf_gtk__deactivate_context(struct perf_gtk_context **ctx)
23 if (!perf_gtk__is_active_context(*ctx))
31 static int perf_gtk__error(const char *format, va_list args)
36 if (!perf_gtk__is_active_context(pgctx) ||
37 vasprintf(&msg, format, args) < 0) {
38 fprintf(stderr, "Error:\n");
39 vfprintf(stderr, format, args);
40 fprintf(stderr, "\n");
44 dialog = gtk_message_dialog_new_with_markup(GTK_WINDOW(pgctx->main_window),
45 GTK_DIALOG_DESTROY_WITH_PARENT,
48 "<b>Error</b>\n\n%s", msg);
49 gtk_dialog_run(GTK_DIALOG(dialog));
51 gtk_widget_destroy(dialog);
56 #ifdef HAVE_GTK_INFO_BAR
57 static int perf_gtk__warning_info_bar(const char *format, va_list args)
61 if (!perf_gtk__is_active_context(pgctx) ||
62 vasprintf(&msg, format, args) < 0) {
63 fprintf(stderr, "Warning:\n");
64 vfprintf(stderr, format, args);
65 fprintf(stderr, "\n");
69 gtk_label_set_text(GTK_LABEL(pgctx->message_label), msg);
70 gtk_info_bar_set_message_type(GTK_INFO_BAR(pgctx->info_bar),
72 gtk_widget_show(pgctx->info_bar);
78 static int perf_gtk__warning_statusbar(const char *format, va_list args)
82 if (!perf_gtk__is_active_context(pgctx) ||
83 vasprintf(&msg, format, args) < 0) {
84 fprintf(stderr, "Warning:\n");
85 vfprintf(stderr, format, args);
86 fprintf(stderr, "\n");
90 gtk_statusbar_pop(GTK_STATUSBAR(pgctx->statbar),
91 pgctx->statbar_ctx_id);
93 /* Only first line can be displayed */
94 p = strchr(msg, '\n');
98 gtk_statusbar_push(GTK_STATUSBAR(pgctx->statbar),
99 pgctx->statbar_ctx_id, msg);
106 struct perf_error_ops perf_gtk_eops = {
107 .error = perf_gtk__error,
108 #ifdef HAVE_GTK_INFO_BAR
109 .warning = perf_gtk__warning_info_bar,
111 .warning = perf_gtk__warning_statusbar,
116 * FIXME: Functions below should be implemented properly.
117 * For now, just add stubs for NO_NEWT=1 build.
119 #ifdef NO_NEWT_SUPPORT
120 void ui_progress__update(u64 curr __maybe_unused, u64 total __maybe_unused,
121 const char *title __maybe_unused)