Continue reforming error message support. In this phase, we divide
[pspp-builds.git] / src / ui / gui / message-dialog.c
index 01eb8ce509409219622a8039b9b90d596c7cb1e9..c5928d357306b1928e0230081614c460fafdbfc3 100644 (file)
@@ -26,6 +26,7 @@
 #include <config.h>
 #include <libpspp/message.h>
 #include "message-dialog.h"
+#include "progname.h"
 
 
 #include <gtk/gtk.h>
@@ -49,41 +50,31 @@ vmsg(int klass, const char *fmt, va_list args)
                    
   gint message_type;
 
-  switch (klass)
+  switch (msg_class_to_severity (klass))
     {
-    case SE:
-    case DE:
-    case ME:
+    case MSG_ERROR:
       message_type = GTK_MESSAGE_ERROR;
       break;
-    case SW:
-    case DW:
-    case MW:
+    case MSG_WARNING:
       message_type = GTK_MESSAGE_WARNING;
       break;
-    case SM:
-    case MM:
+    case MSG_NOTE:
     default:
       message_type = GTK_MESSAGE_INFO;
       break;
     };
   
-  switch (klass
+  switch (msg_class_to_category (klass)
     {
-    case SE:
-    case SW:
-    case SM:
+    case MSG_SYNTAX:
       msg = g_strdup(_("Script Error"));
       break;
 
-    case DE:
-    case DW:
+    case MSG_DATA:
       msg = g_strdup(_("Data File Error"));
       break;
 
-    case ME:
-    case MW:
-    case MM:
+    case MSG_GENERAL:
     default:
       msg = g_strdup(_("PSPP Error"));
       break;
@@ -112,7 +103,7 @@ vmsg(int klass, const char *fmt, va_list args)
 
 
 void 
-msg(int klass, const char *fmt, ...)
+msg(enum msg_class klass, const char *fmt, ...)
 {
   va_list ap;
   va_start(ap, fmt);
@@ -124,7 +115,8 @@ msg(int klass, const char *fmt, ...)
 void
 err_vmsg (const struct error *e, const char *format, va_list args)
 {
-  vmsg(e->class, format, args);
+  vmsg(msg_class_from_category_and_severity (e->category, e->severity),
+       format, args);
 }
 
 
@@ -134,29 +126,21 @@ err_assert_fail(const char *expr, const char *file, int line)
   msg(ME, "Assertion failed: %s:%d; (%s)\n",file,line,expr);
 }
 
-/* The GUI is always interactive.
-   So this function does nothing */
-void 
-err_cond_fail(void)
-{
-}
-
-
+/* Writes MESSAGE formatted with printf, to stderr, if the
+   verbosity level is at least LEVEL. */
 void
-err_failure(void)
+verbose_msg (int level, const char *format, ...)
 {
-  msg(ME, _("Terminating NOW due to fatal error"));
-  gtk_main_quit();
+  /* Do nothing for now. */
 }
 
-
 /* FIXME: This is a stub .
  * A temporary workaround until getl.c is rearranged
  */
 void
 err_location (struct file_locator *f)
 {
-       f->filename = 0;
+       f->file_name = 0;
        f->line_number = -1;
 }