X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-window.c;h=49438d6cff14f5af7a68150455de8a741aa13410;hb=32ee0e0402d6d56674f53a47d879ec5c07dabe09;hp=0f14179a8566c287705d812b56a7084c7cd4e160;hpb=b6ff9071cb7359e7d6b06ee01064116117876c16;p=pspp diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index 0f14179a85..49438d6cff 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -23,12 +23,15 @@ #include "data/session.h" #include "language/lexer/lexer.h" #include "libpspp/message.h" +#include "libpspp/str.h" #include "ui/gui/aggregate-dialog.h" +#include "ui/gui/autorecode-dialog.h" #include "ui/gui/binomial-dialog.h" #include "ui/gui/chi-square-dialog.h" #include "ui/gui/comments-dialog.h" #include "ui/gui/compute-dialog.h" #include "ui/gui/correlation-dialog.h" +#include "ui/gui/count-dialog.h" #include "ui/gui/crosstabs-dialog.h" #include "ui/gui/descriptives-dialog.h" #include "ui/gui/entry-dialog.h" @@ -40,13 +43,17 @@ #include "ui/gui/goto-case-dialog.h" #include "ui/gui/help-menu.h" #include "ui/gui/helper.h" +#include "ui/gui/k-means-dialog.h" #include "ui/gui/k-related-dialog.h" +#include "ui/gui/npar-two-sample-related.h" #include "ui/gui/oneway-anova-dialog.h" #include "ui/gui/psppire-data-window.h" #include "ui/gui/psppire-syntax-window.h" #include "ui/gui/psppire-window.h" #include "ui/gui/psppire.h" #include "ui/gui/rank-dialog.h" +#include "ui/gui/runs-dialog.h" +#include "ui/gui/ks-one-sample-dialog.h" #include "ui/gui/recode-dialog.h" #include "ui/gui/regression-dialog.h" #include "ui/gui/reliability-dialog.h" @@ -64,6 +71,7 @@ #include "ui/syntax-gen.h" #include "gl/c-strcase.h" +#include "gl/c-strcasestr.h" #include "gl/xvasprintf.h" #include @@ -359,8 +367,9 @@ name_has_suffix (const gchar *name) static gboolean load_file (PsppireWindow *de, const gchar *file_name) { - gchar *utf8_file_name; struct string filename; + gchar *utf8_file_name; + const char *mime_type; gchar *syntax; bool ok; @@ -378,10 +387,15 @@ load_file (PsppireWindow *de, const gchar *file_name) ok = execute_syntax (PSPPIRE_DATA_WINDOW (de), lex_reader_for_string (syntax)); g_free (syntax); - return ok; -} + mime_type = (name_has_por_suffix (file_name) + ? "application/x-spss-por" + : "application/x-spss-sav"); + add_most_recent (file_name, mime_type); + + return ok; +} /* Save DE to file */ static void @@ -479,6 +493,7 @@ static void data_pick_filename (PsppireWindow *window) { PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (window); + GtkFileFilter *filter = gtk_file_filter_new (); GtkWidget *button_sys; GtkWidget *dialog = gtk_file_chooser_dialog_new (_("Save"), @@ -488,7 +503,8 @@ data_pick_filename (PsppireWindow *window) GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); - GtkFileFilter *filter = gtk_file_filter_new (); + g_object_set (dialog, "local-only", FALSE, NULL); + gtk_file_filter_set_name (filter, _("System Files (*.sav)")); gtk_file_filter_add_pattern (filter, "*.sav"); gtk_file_filter_add_pattern (filter, "*.SAV"); @@ -756,21 +772,63 @@ on_recent_data_select (GtkMenuShell *menushell, g_free (file); } +static char * +charset_from_mime_type (const char *mime_type) +{ + const char *charset; + struct string s; + const char *p; + + if (mime_type == NULL) + return NULL; + + charset = c_strcasestr (mime_type, "charset="); + if (charset == NULL) + return NULL; + + ds_init_empty (&s); + p = charset + 8; + if (*p == '"') + { + /* Parse a "quoted-string" as defined by RFC 822. */ + for (p++; *p != '\0' && *p != '"'; p++) + { + if (*p != '\\') + ds_put_byte (&s, *p); + else if (*++p != '\0') + ds_put_byte (&s, *p); + } + } + else + { + /* Parse a "token" as defined by RFC 2045. */ + while (*p > 32 && *p < 127 && strchr ("()<>@,;:\\\"/[]?=", *p) == NULL) + ds_put_byte (&s, *p++); + } + if (!ds_is_empty (&s)) + return ds_steal_cstr (&s); + + ds_destroy (&s); + return NULL; +} + static void on_recent_files_select (GtkMenuShell *menushell, gpointer user_data) { + GtkRecentInfo *item; + char *encoding; + GtkWidget *se; gchar *file; - GtkWidget *se ; - - gchar *uri = - gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell)); - - file = g_filename_from_uri (uri, NULL, NULL); + /* Get the file name and its encoding. */ + item = gtk_recent_chooser_get_current_item (GTK_RECENT_CHOOSER (menushell)); + file = g_filename_from_uri (gtk_recent_info_get_uri (item), NULL, NULL); + encoding = charset_from_mime_type (gtk_recent_info_get_mime_type (item)); + gtk_recent_info_unref (item); - g_free (uri); + se = psppire_syntax_window_new (encoding); - se = psppire_syntax_window_new (); + free (encoding); if ( psppire_window_load (PSPPIRE_WINDOW (se), file) ) gtk_widget_show (se); @@ -781,6 +839,7 @@ on_recent_files_select (GtkMenuShell *menushell, gpointer user_data) } + static void enable_delete_cases (GtkWidget *w, gint case_num, gpointer data) { @@ -1016,6 +1075,8 @@ psppire_data_window_finish_init (PsppireDataWindow *de, connect_action (de, "transform_compute", G_CALLBACK (compute_dialog)); + connect_action (de, "transform_autorecode", G_CALLBACK (autorecode_dialog)); + connect_action (de, "edit_find", G_CALLBACK (find_dialog)); connect_action (de, "data_split-file", G_CALLBACK (split_file_dialog)); @@ -1036,6 +1097,8 @@ psppire_data_window_finish_init (PsppireDataWindow *de, connect_action (de, "utilities_comments", G_CALLBACK (comments_dialog)); connect_action (de, "transform_rank", G_CALLBACK (rank_dialog)); + + connect_action (de, "transform_count", G_CALLBACK (count_dialog)); connect_action (de, "transform_recode-same", G_CALLBACK (recode_same_dialog)); @@ -1059,11 +1122,14 @@ psppire_data_window_finish_init (PsppireDataWindow *de, connect_action (de, "factor-analysis", G_CALLBACK (factor_dialog)); - connect_action (de, "chi-square", G_CALLBACK (chisquare_dialog)); + connect_action (de, "k-means", G_CALLBACK (k_means_dialog)); + connect_action (de, "chi-square", G_CALLBACK (chisquare_dialog)); connect_action (de, "binomial", G_CALLBACK (binomial_dialog)); - + connect_action (de, "runs", G_CALLBACK (runs_dialog)); + connect_action (de, "ks-one-sample", G_CALLBACK (ks_one_sample_dialog)); connect_action (de, "k-related-samples", G_CALLBACK (k_related_dialog)); + connect_action (de, "two-related-samples", G_CALLBACK (two_related_dialog)); { @@ -1082,13 +1148,14 @@ psppire_data_window_finish_init (PsppireDataWindow *de, GtkWidget *menu_files = gtk_recent_chooser_menu_new_for_manager ( gtk_recent_manager_get_default ()); + g_object_set (menu_data, "show-tips", TRUE, NULL); + g_object_set (menu_files, "show-tips", TRUE, NULL); + { GtkRecentFilter *filter = gtk_recent_filter_new (); - gtk_recent_filter_add_pattern (filter, "*.sav"); - gtk_recent_filter_add_pattern (filter, "*.SAV"); - gtk_recent_filter_add_pattern (filter, "*.por"); - gtk_recent_filter_add_pattern (filter, "*.POR"); + gtk_recent_filter_add_mime_type (filter, "application/x-spss-sav"); + gtk_recent_filter_add_mime_type (filter, "application/x-spss-por"); gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (menu_data), GTK_RECENT_SORT_MRU);