REGRESSION: Fix issues found by by review
[pspp] / src / ui / gui / psppire-data-window.c
index 927f9d5de3dc90c5b671a6c00712821be53cffe4..d9488b354990c6b4135a7db9cbe7d75a0de9402a 100644 (file)
@@ -1,5 +1,5 @@
 /* PSPPIRE - a graphical user interface for PSPP.
-   Copyright (C) 2008, 2009, 2010, 2011, 2012  Free Software Foundation
+   Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013  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
@@ -336,34 +336,46 @@ name_has_suffix (const gchar *name)
 }
 
 static gboolean
-load_file (PsppireWindow *de, const gchar *file_name, gpointer not_used)
+load_file (PsppireWindow *de, const gchar *file_name, gpointer syn)
 {
-  struct string filename;
-  gchar *utf8_file_name;
-  const char *mime_type;
-  gchar *syntax;
+  const char *mime_type = NULL;
+  gchar *syntax = NULL;
   bool ok;
 
-  ds_init_empty (&filename);
-
-  utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
-
-  syntax_gen_string (&filename, ss_cstr (utf8_file_name));
-
-  g_free (utf8_file_name);
+  if (syn == NULL)
+    {
+      gchar *utf8_file_name;
+      struct string filename;
+      ds_init_empty (&filename);
+      
+      utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
+    
+      syntax_gen_string (&filename, ss_cstr (utf8_file_name));
+      
+      g_free (utf8_file_name);
+      
+      syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
+      ds_destroy (&filename);
 
-  syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename));
-  ds_destroy (&filename);
+    }
+  else
+    {
+      syntax = syn;
+    }
 
   ok = execute_syntax (PSPPIRE_DATA_WINDOW (de),
                        lex_reader_for_string (syntax));
   g_free (syntax);
 
-  mime_type = (name_has_por_suffix (file_name)
-               ? "application/x-spss-por"
-               : "application/x-spss-sav");
-
-  add_most_recent (file_name, mime_type);
+  if (ok && syn == NULL)
+    {
+      if (name_has_por_suffix (file_name))
+       mime_type = "application/x-spss-por";
+      else if (name_has_sav_suffix (file_name))
+       mime_type = "application/x-spss-sav";
+      
+      add_most_recent (file_name, mime_type);
+    }
 
   return ok;
 }
@@ -1227,7 +1239,7 @@ psppire_data_window_new (struct dataset *ds)
   GtkWidget *dw;
 
   if (the_session == NULL)
-    the_session = session_create ();
+    the_session = session_create (NULL);
 
   if (ds == NULL)
     {