2 PSPPIRE --- A Graphical User Interface for PSPP
3 Copyright (C) 2004,2005 Free Software Foundation
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 #define _(msgid) gettext (msgid)
28 #define N_(msgid) msgid
30 #include <libpspp/message.h>
31 #include <libpspp/msg-locator.h>
32 #include "message-dialog.h"
37 #include <glade/glade.h>
42 static void enqueue_msg (const struct msg *m);
45 static GQueue *message_queue;
49 message_dialog_init (struct source_stream *ss)
51 message_queue = g_queue_new ();
52 msg_init (ss, enqueue_msg);
56 message_dialog_done (void)
59 g_queue_free (message_queue);
63 dequeue_message (gpointer data)
67 /* If a pointer grab is in effect, then the combination of that, and
68 a modal dialog box, will cause an impossible situation.
69 So don't pop it up just yet.
71 if ( gdk_pointer_is_grabbed ())
74 m = g_queue_pop_tail (message_queue);
87 enqueue_msg (const struct msg *msg)
89 struct msg *m = msg_dup (msg);
91 g_queue_push_head (message_queue, m);
93 g_idle_add (dequeue_message, 0);
98 popup_message (const struct msg *m)
101 gchar *location = NULL;
109 message_type = GTK_MESSAGE_ERROR;
112 message_type = GTK_MESSAGE_WARNING;
116 message_type = GTK_MESSAGE_INFO;
123 msg = _("Script Error");
127 msg = _("Data File Error");
132 msg = _("PSPP Error");
136 dialog = gtk_message_dialog_new ( NULL,
141 if ( m->where.line_number != -1)
143 location = g_strdup_printf (_("%s (line %d)"),
144 m->where.file_name ? m->where.file_name : "",
145 m->where.line_number);
149 location = g_strdup_printf (_("%s"),
150 m->where.file_name ? m->where.file_name : ""); }
152 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
158 gtk_window_set_keep_above (GTK_WINDOW (dialog), TRUE);
160 gtk_dialog_run (GTK_DIALOG (dialog));
162 gtk_widget_destroy (dialog);