src/ui/gui/psppire.c: Fold long line
[pspp] / src / ui / gui / psppire.c
index 1f903beda993c75616491e08f11f7100408ac2aa..12a5e2612fadfbca29180b306b6a5fc2eb168392 100644 (file)
@@ -1,5 +1,6 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011, 2012, 2013, 2014, 2016  Free Software Foundation
+   Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011, 2012, 2013, 2014,
+   2016  Free Software Foundation
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,7 +18,6 @@
 #include <config.h>
 
 
-#include <assert.h>
 #include <gsl/gsl_errno.h>
 #include <gtk/gtk.h>
 #include <libintl.h>
@@ -38,7 +38,8 @@
 
 #include "output/driver.h"
 #include "output/journal.h"
-#include "output/message-item.h"
+#include "output/output-item.h"
+#include "output/spv/spv.h"
 
 #include "ui/gui/dict-display.h"
 #include "ui/gui/executor.h"
@@ -105,7 +106,7 @@ initialize (const struct init_source *is)
       bind_textdomain_codeset (PACKAGE, "UTF-8");
       break;
     case 8:
-      if ( ! gtk_parse_args (is->argc, is->argv) )
+      if (! gtk_parse_args (is->argc, is->argv))
        {
          perror ("Error parsing arguments");
          exit (1);
@@ -139,12 +140,6 @@ psppire_quit (GApplication *app)
   g_application_quit (app);
 }
 
-struct icon_size
-{
-  int resolution;  /* The dimension of the images which will be used */
-  size_t n_sizes;  /* The number of items in the array below. */
-  const GtkIconSize *usage; /* An array determining for what the icon set is used */
-};
 \f
 static void
 handle_msg (const struct msg *m_, void *lexer_)
@@ -160,9 +155,11 @@ handle_msg (const struct msg *m_, void *lexer_)
       m.first_column = lex_get_first_column (lexer, 0);
       m.last_column = lex_get_last_column (lexer, 0);
     }
-  m.command_name = CONST_CAST (char *, output_get_command_name ());
+  m.command_name = output_get_uppercase_command_name ();
+
+  output_item_submit (message_item_create (&m));
 
-  message_item_submit (message_item_create (&m));
+  free (m.command_name);
 }
 
 void
@@ -173,7 +170,7 @@ psppire_set_lexer (struct lexer *lexer)
 
 
 GtkWindow *
-psppire_preload_file (const gchar *file)
+psppire_preload_file (const gchar *file, GtkWindow *victim)
 {
   const gchar *local_encoding = "UTF-8";
 
@@ -189,11 +186,18 @@ psppire_preload_file (const gchar *file)
   /* Check to see if the file is a .sav or a .por file.  If not
      assume that it is a syntax file */
   if (retval == 1)
-    w = open_data_window (NULL, filename, NULL, NULL);
+    w = open_data_window (PSPPIRE_WINDOW (victim), filename, NULL, NULL);
   else if (retval == 0)
     {
-      create_data_window ();
-      w = open_syntax_window (filename, NULL);
+      char *error = spv_detect (filename);
+      if (!error)
+        read_spv_file (filename);
+      else
+        {
+          free (error);
+          create_data_window ();
+          open_syntax_window (filename, NULL);
+        }
     }
 
   fh_unref (fh);