X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-window.c;h=d9488b354990c6b4135a7db9cbe7d75a0de9402a;hb=3b07fccffef73bba4bb1839fced20554df75901e;hp=73c98b383efcd6624809471dffbdf12badcfc25d;hpb=b3fcf4b1644bf4af9b5eb7b0b0f8856c51118128;p=pspp diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index 73c98b383e..d9488b3549 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -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) +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; } @@ -701,7 +713,7 @@ on_recent_data_select (GtkMenuShell *menushell, g_free (uri); - open_data_window (window, file); + open_data_window (window, file, NULL); g_free (file); } @@ -764,7 +776,7 @@ on_recent_files_select (GtkMenuShell *menushell, gpointer user_data) free (encoding); - if ( psppire_window_load (PSPPIRE_WINDOW (se), file) ) + if ( psppire_window_load (PSPPIRE_WINDOW (se), file, NULL) ) gtk_widget_show (se); else gtk_widget_destroy (se); @@ -779,7 +791,7 @@ set_unsaved (gpointer w) } static void -on_switch_page (PsppireDataEditor *de, GtkNotebookPage *p, +on_switch_page (PsppireDataEditor *de, gpointer p, gint pagenum, PsppireDataWindow *dw) { GtkWidget *page_menu_item; @@ -940,7 +952,7 @@ psppire_data_window_finish_init (PsppireDataWindow *de, connect_action (de, "file_new_data", G_CALLBACK (create_data_window)); - connect_action (de, "file_import-text", G_CALLBACK (text_data_import_assistant)); + connect_action (de, "file_import", G_CALLBACK (text_data_import_assistant)); connect_action (de, "file_save", G_CALLBACK (psppire_window_save)); @@ -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) { @@ -1317,7 +1329,7 @@ create_data_window (void) } void -open_data_window (PsppireWindow *victim, const char *file_name) +open_data_window (PsppireWindow *victim, const char *file_name, gpointer hint) { GtkWidget *window; @@ -1330,7 +1342,7 @@ open_data_window (PsppireWindow *victim, const char *file_name) else window = psppire_data_window_new (NULL); - psppire_window_load (PSPPIRE_WINDOW (window), file_name); + psppire_window_load (PSPPIRE_WINDOW (window), file_name, hint); gtk_widget_show_all (window); }