1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #define _(msgid) gettext (msgid)
24 #define N_(msgid) msgid
26 #include <libpspp/message.h>
27 #include <libpspp/msg-locator.h>
28 #include "message-dialog.h"
33 #include <glade/glade.h>
38 static void enqueue_msg (const struct msg *m);
41 static GQueue *message_queue;
45 message_dialog_init (struct source_stream *ss)
47 message_queue = g_queue_new ();
48 msg_init (ss, enqueue_msg);
52 message_dialog_done (void)
55 g_queue_free (message_queue);
59 dequeue_message (gpointer data)
63 /* If a pointer grab is in effect, then the combination of that, and
64 a modal dialog box, will cause an impossible situation.
65 So don't pop it up just yet.
67 if ( gdk_pointer_is_grabbed ())
70 m = g_queue_pop_tail (message_queue);
83 enqueue_msg (const struct msg *msg)
85 struct msg *m = msg_dup (msg);
87 g_queue_push_head (message_queue, m);
89 g_idle_add (dequeue_message, 0);
94 popup_message (const struct msg *m)
97 gchar *location = NULL;
105 message_type = GTK_MESSAGE_ERROR;
108 message_type = GTK_MESSAGE_WARNING;
112 message_type = GTK_MESSAGE_INFO;
119 msg = _("Script Error");
123 msg = _("Data File Error");
128 msg = _("PSPP Error");
132 dialog = gtk_message_dialog_new ( NULL,
137 if ( m->where.line_number != -1)
139 location = g_strdup_printf (_("%s (line %d)"),
140 m->where.file_name ? m->where.file_name : "",
141 m->where.line_number);
145 location = g_strdup_printf (_("%s"),
146 m->where.file_name ? m->where.file_name : ""); }
148 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
154 gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
156 gtk_dialog_run (GTK_DIALOG (dialog));
158 gtk_widget_destroy (dialog);