aboutsummaryrefslogtreecommitdiffstats
path: root/trace-dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'trace-dialog.c')
-rw-r--r--trace-dialog.c48
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;
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{