aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-04-06 14:48:18 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-04-09 11:56:19 -0400
commit0af521a7ba132afbc83aff1216ce3457f97cc09c (patch)
treee18d0c92cb2eaca88fdf0e2601347b3e0dfeeeb0
parent25d1c51565706f7d9e2a8cec31a80dd32c2c889b (diff)
kernelshark: Add warning dialogs
When a warning happens, show it with a dialog instead of printing to the console. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel-shark.c2
-rw-r--r--trace-dialog.c48
-rw-r--r--trace-graph-main.c2
-rw-r--r--trace-gui.h2
-rw-r--r--trace-view-main.c2
5 files changed, 56 insertions, 0 deletions
diff --git a/kernel-shark.c b/kernel-shark.c
index a9e5137..ee47ff5 100644
--- a/kernel-shark.c
+++ b/kernel-shark.c
@@ -788,6 +788,8 @@ void kernel_shark(int argc, char **argv)
788 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 788 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
789 info->window = window; 789 info->window = window;
790 790
791 trace_dialog_register_window(window);
792
791 if (input_file) 793 if (input_file)
792 update_title(window, input_file); 794 update_title(window, input_file);
793 795
diff --git a/trace-dialog.c b/trace-dialog.c
index 4ed5b7b..c220a52 100644
--- a/trace-dialog.c
+++ b/trace-dialog.c
@@ -22,6 +22,7 @@
22#include <stdlib.h> 22#include <stdlib.h>
23#include <string.h> 23#include <string.h>
24#include <stdarg.h> 24#include <stdarg.h>
25#include <errno.h>
25#include <ctype.h> 26#include <ctype.h>
26 27
27#include "trace-compat.h" 28#include "trace-compat.h"
@@ -35,6 +36,8 @@ static GtkWidget *statusbar;
35static GtkWidget *statuspix; 36static GtkWidget *statuspix;
36static GString *statusstr; 37static GString *statusstr;
37 38
39static GtkWidget *parent_window;
40
38void pr_stat(char *fmt, ...) 41void pr_stat(char *fmt, ...)
39{ 42{
40 GString *str; 43 GString *str;
@@ -62,6 +65,51 @@ void pr_stat(char *fmt, ...)
62 g_string_free(str, TRUE); 65 g_string_free(str, TRUE);
63} 66}
64 67
68/**
69 * trace_dialog_register_window - register window for warning dialogs
70 * @window: parent window to use for other dialogs
71 *
72 * The warning messages do not have a way to pass the window to
73 * the function, since these functions are also used by the command
74 * line interface. This allows an application to give the warning
75 * messages a window to use.
76 */
77void trace_dialog_register_window(GtkWidget *window)
78{
79 parent_window = window;
80}
81
82void warning(char *fmt, ...)
83{
84 GString *str;
85 va_list ap;
86
87 if (!parent_window) {
88 va_start(ap, fmt);
89 __vwarning(fmt, ap);
90 va_end(ap);
91 return;
92 }
93
94 str = g_string_new("");
95
96 va_start(ap, fmt);
97 g_string_vprintf(str, fmt, ap);
98 va_end(ap);
99
100 g_string_append(str, "\n");
101
102 if (errno)
103 g_string_prepend(str, strerror(errno));
104
105 errno = 0;
106
107 trace_dialog(GTK_WINDOW(parent_window), TRACE_GUI_WARNING,
108 str->str);
109
110 g_string_free(str, TRUE);
111}
112
65static void 113static void
66status_display_clicked (gpointer data) 114status_display_clicked (gpointer data)
67{ 115{
diff --git a/trace-graph-main.c b/trace-graph-main.c
index 286e417..2ba9447 100644
--- a/trace-graph-main.c
+++ b/trace-graph-main.c
@@ -262,6 +262,8 @@ void trace_graph(int argc, char **argv)
262 262
263 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 263 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
264 264
265 trace_dialog_register_window(window);
266
265 /* --- Top Level Vbox --- */ 267 /* --- Top Level Vbox --- */
266 268
267 vbox = gtk_vbox_new(FALSE, 0); 269 vbox = gtk_vbox_new(FALSE, 0);
diff --git a/trace-gui.h b/trace-gui.h
index 59784c6..a2d261f 100644
--- a/trace-gui.h
+++ b/trace-gui.h
@@ -31,6 +31,8 @@ enum trace_dialog_type {
31 31
32GtkWidget *trace_status_bar_new(void); 32GtkWidget *trace_status_bar_new(void);
33 33
34void trace_dialog_register_window(GtkWidget *window);
35
34void trace_show_help(GtkWidget *window, const gchar *link, GError **error); 36void trace_show_help(GtkWidget *window, const gchar *link, GError **error);
35 37
36void trace_dialog(GtkWindow *parent, enum trace_dialog_type type, 38void trace_dialog(GtkWindow *parent, enum trace_dialog_type type,
diff --git a/trace-view-main.c b/trace-view-main.c
index bc7e4ee..8fa9aa6 100644
--- a/trace-view-main.c
+++ b/trace-view-main.c
@@ -479,6 +479,8 @@ void trace_view(int argc, char **argv)
479 479
480 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 480 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
481 481
482 trace_dialog_register_window(window);
483
482 /* --- Top Level Vbox --- */ 484 /* --- Top Level Vbox --- */
483 485
484 vbox = gtk_vbox_new(FALSE, 0); 486 vbox = gtk_vbox_new(FALSE, 0);