Merge branch 'master' of /home/john/Development/pspp-window-manager
[pspp-builds.git] / src / ui / gui / psppire.c
index 02415d68bc3df8a6250d0a115f622c52de6c787f..b87a29f2a48db9d12c692e9a126b66e2f199f2f9 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2004, 2005, 2006  Free Software Foundation
+   Copyright (C) 2004, 2005, 2006, 2009  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
 #include <assert.h>
 #include <libintl.h>
 #include <gsl/gsl_errno.h>
-#include <signal.h>
 
 #include <argp.h>
 #include <ui/command-line.h>
 #include "relocatable.h"
 
-#include "data-editor.h"
+#include "psppire-data-window.h"
 #include "psppire.h"
 
 #include <libpspp/getl.h>
@@ -53,7 +52,8 @@
 #include "message-dialog.h"
 #include <ui/syntax-gen.h>
 
-#include "output-viewer.h"
+
+#include "psppire-output-window.h"
 
 #include <data/sys-file-reader.h>
 #include <data/por-file-reader.h>
@@ -68,6 +68,7 @@ static void create_icon_factory (void);
 struct source_stream *the_source_stream ;
 struct dataset * the_dataset = NULL;
 
+static GtkWidget *the_data_window;
 
 static void
 replace_casereader (struct casereader *s)
@@ -78,6 +79,10 @@ replace_casereader (struct casereader *s)
 #define _(msgid) gettext (msgid)
 #define N_(msgid) msgid
 
+
+const char * output_file_name (void);
+
+
 void
 initialize (struct command_line_processor *clp, int argc, char **argv)
 {
@@ -117,32 +122,41 @@ initialize (struct command_line_processor *clp, int argc, char **argv)
   the_data_store = psppire_data_store_new (dictionary);
   replace_casereader (NULL);
 
+  create_icon_factory ();
 
+  {
+    const char *filename = output_file_name ();
 
-  create_icon_factory ();
+    struct string config_string;
+
+    ds_init_empty (&config_string);
+
+    ds_put_format (&config_string,
+                  "gui:ascii:screen:squeeze=on headers=off top-margin=0 "
+                  "bottom-margin=0 paginate=off length=auto width=auto "
+                  "emphasis=none "
+                  "output-file=\"%s\" append=yes", filename);
 
-  outp_configure_driver_line (
-    ss_cstr ("gui:ascii:screen:squeeze=on headers=off top-margin=0 "
-             "bottom-margin=0 paginate=off length=auto width=auto "
-            "emphasis=none "
-             "output-file=\"" OUTPUT_FILE_NAME "\" append=yes"));
+    outp_configure_driver_line (ds_ss (&config_string));
 
-  unlink (OUTPUT_FILE_NAME);
+    unlink (filename);
+
+    ds_destroy (&config_string);
+  }
 
   journal_enable ();
   textdomain (PACKAGE);
 
-  /* Ignore alarm clock signals */
-  signal (SIGALRM, SIG_IGN);
+  the_data_window = psppire_data_window_new ();
 
   command_line_processor_replace_aux (clp, &post_init_argp, the_source_stream);
   command_line_processor_replace_aux (clp, &non_option_argp, the_source_stream);
 
   command_line_processor_parse (clp, argc, argv);
 
-  new_data_window (NULL, NULL);
-
   execute_syntax (create_syntax_string_source (""));
+
+  gtk_widget_show (the_data_window);
 }
 
 
@@ -280,6 +294,9 @@ parse_non_options (int key, char *arg, struct argp_state *state)
                            ERRMODE_CONTINUE);
 
        ds_destroy (&syntax);
+
+       psppire_window_set_filename (PSPPIRE_WINDOW (the_data_window), arg);
+
        break;
       }
     default:
@@ -290,3 +307,17 @@ parse_non_options (int key, char *arg, struct argp_state *state)
 
 
 const struct argp non_option_argp = {NULL, parse_non_options, 0, 0, 0, 0, 0};
+
+
+const char *
+output_file_name (void)
+{
+  const char *dir = default_output_path ();
+  static char *filename = NULL;
+
+  if ( NULL == filename )
+    filename = xasprintf ("%s%s", dir, OUTPUT_FILE_NAME);
+
+
+  return filename;
+}