diff options
Diffstat (limited to 'trace-dialog.c')
-rw-r--r-- | trace-dialog.c | 48 |
1 files changed, 48 insertions, 0 deletions
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; | |||
35 | static GtkWidget *statuspix; | 36 | static GtkWidget *statuspix; |
36 | static GString *statusstr; | 37 | static GString *statusstr; |
37 | 38 | ||
39 | static GtkWidget *parent_window; | ||
40 | |||
38 | void pr_stat(char *fmt, ...) | 41 | void 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 | */ | ||
77 | void trace_dialog_register_window(GtkWidget *window) | ||
78 | { | ||
79 | parent_window = window; | ||
80 | } | ||
81 | |||
82 | void 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 | |||
65 | static void | 113 | static void |
66 | status_display_clicked (gpointer data) | 114 | status_display_clicked (gpointer data) |
67 | { | 115 | { |