}
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;
}
switch (ia->asst.response)
{
case GTK_RESPONSE_APPLY:
- free (execute_syntax_string (dw, generate_syntax (ia)));
+ {
+ gchar *fn = g_path_get_basename (ia->file.file_name);
+ open_data_window (PSPPIRE_WINDOW (dw), fn, generate_syntax (ia));
+ g_free (fn);
+ }
break;
case PSPPIRE_RESPONSE_PASTE:
free (paste_syntax_to_window (generate_syntax (ia)));