/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation
+ Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 2014 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 "ui/gui/aggregate-dialog.h"
#include "ui/gui/autorecode-dialog.h"
#include "ui/gui/builder-wrapper.h"
-#include "ui/gui/chi-square-dialog.h"
#include "ui/gui/comments-dialog.h"
-#include "ui/gui/compute-dialog.h"
-#include "ui/gui/count-dialog.h"
#include "ui/gui/entry-dialog.h"
#include "ui/gui/executor.h"
#include "ui/gui/help-menu.h"
#include "ui/gui/helper.h"
#include "ui/gui/helper.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-dialog-action.h"
+#include "ui/gui/psppire-encoding-selector.h"
#include "ui/gui/psppire-syntax-window.h"
#include "ui/gui/psppire-window.h"
#include "ui/gui/psppire.h"
-#include "ui/gui/ks-one-sample-dialog.h"
#include "ui/gui/recode-dialog.h"
#include "ui/gui/select-cases-dialog.h"
#include "ui/gui/split-file-dialog.h"
-#include "ui/gui/t-test-one-sample.h"
-#include "ui/gui/t-test-paired-samples.h"
#include "ui/gui/text-data-import-dialog.h"
-#include "ui/gui/transpose-dialog.h"
-#include "ui/gui/univariate-dialog.h"
#include "ui/gui/weight-cases-dialog.h"
#include "ui/syntax-gen.h"
}
#endif
+static gboolean
+has_suffix (const gchar *name, const gchar *suffix)
+{
+ size_t name_len = strlen (name);
+ size_t suffix_len = strlen (suffix);
+ return (name_len > suffix_len
+ && !c_strcasecmp (&name[name_len - suffix_len], suffix));
+}
+
static gboolean
name_has_por_suffix (const gchar *name)
{
- size_t length = strlen (name);
- return length > 4 && !c_strcasecmp (&name[length - 4], ".por");
+ return has_suffix (name, ".por");
}
static gboolean
name_has_sav_suffix (const gchar *name)
{
- size_t length = strlen (name);
- return length > 4 && !c_strcasecmp (&name[length - 4], ".sav");
+ return has_suffix (name, ".sav") || has_suffix (name, ".zsav");
}
/* Returns true if NAME has a suffix which might denote a PSPP file */
{
gchar *utf8_file_name;
struct string filename;
- ds_init_empty (&filename);
utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL);
-
+
+ if (NULL == utf8_file_name)
+ return FALSE;
+
+ ds_init_empty (&filename);
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);
-
}
else
{
return ok;
}
+static const char *
+psppire_data_window_format_to_string (enum PsppireDataWindowFormat format)
+{
+ if (format == PSPPIRE_DATA_WINDOW_SAV)
+ return ".sav";
+ else if (format == PSPPIRE_DATA_WINDOW_ZSAV)
+ return ".zsav";
+ else
+ return ".por";
+}
+
/* Save DE to file */
static void
save_file (PsppireWindow *w)
fnx = g_string_new (file_name);
if ( ! name_has_suffix (fnx->str))
- {
- if ( de->save_as_portable)
- g_string_append (fnx, ".por");
- else
- g_string_append (fnx, ".sav");
- }
+ g_string_append (fnx, psppire_data_window_format_to_string (de->format));
ds_init_empty (&filename);
syntax_gen_string (&filename, ss_cstr (utf8_file_name));
g_free (utf8_file_name);
- syntax = g_strdup_printf ("%s OUTFILE=%s.",
- de->save_as_portable ? "EXPORT" : "SAVE",
- ds_cstr (&filename));
+ if (de->format == PSPPIRE_DATA_WINDOW_SAV)
+ syntax = g_strdup_printf ("SAVE OUTFILE=%s.", ds_cstr (&filename));
+ else if (de->format == PSPPIRE_DATA_WINDOW_ZSAV)
+ syntax = g_strdup_printf ("SAVE /ZCOMPRESSED /OUTFILE=%s.",
+ ds_cstr (&filename));
+ else
+ syntax = g_strdup_printf ("EXPORT OUTFILE=%s.", ds_cstr (&filename));
ds_destroy (&filename);
struct string filename;
gchar *file_name =
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
-
gchar *utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL,
NULL);
+ const gchar *encoding = psppire_encoding_selector_get_encoding (
+ gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (dialog)));
+
gchar *syntax;
ds_init_empty (&filename);
g_free (utf8_file_name);
- syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename));
+ if (encoding)
+ syntax = g_strdup_printf ("SYSFILE INFO %s ENCODING='%s'.",
+ ds_cstr (&filename), encoding);
+ else
+ syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename));
g_free (execute_syntax_string (de, syntax));
}
static void
data_pick_filename (PsppireWindow *window)
{
+ GtkListStore *list_store;
+ GtkWidget *combo_box;
+
PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (window);
- GtkFileFilter *filter = gtk_file_filter_new ();
- GtkWidget *button_sys;
+ GtkFileFilter *filter;
GtkWidget *dialog =
gtk_file_chooser_dialog_new (_("Save"),
GTK_WINDOW (de),
g_object_set (dialog, "local-only", FALSE, NULL);
+ filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("System Files (*.sav)"));
gtk_file_filter_add_mime_type (filter, "application/x-spss-sav");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_set_name (filter, _("Compressed System Files (*.zsav)"));
+ gtk_file_filter_add_pattern (filter, "*.zsav");
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Portable Files (*.por) "));
gtk_file_filter_add_mime_type (filter, "application/x-spss-por");
gtk_file_filter_set_name (filter, _("All Files"));
gtk_file_filter_add_pattern (filter, "*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
{
- GtkWidget *button_por;
- GtkWidget *vbox = gtk_vbox_new (TRUE, 5);
- button_sys =
- gtk_radio_button_new_with_label (NULL, _("System File"));
-
- button_por =
- gtk_radio_button_new_with_label
- (gtk_radio_button_get_group (GTK_RADIO_BUTTON(button_sys)),
- _("Portable File"));
-
- psppire_box_pack_start_defaults (GTK_BOX (vbox), button_sys);
- psppire_box_pack_start_defaults (GTK_BOX (vbox), button_por);
-
- gtk_widget_show_all (vbox);
-
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(dialog), vbox);
+ GtkCellRenderer *cell;
+ GtkWidget *label;
+ GtkTreeIter iter;
+ GtkWidget *hbox;
+
+ list_store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING);
+ combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
+
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter,
+ 0, PSPPIRE_DATA_WINDOW_SAV,
+ 1, _("System File"),
+ -1);
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
+
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter,
+ 0, PSPPIRE_DATA_WINDOW_ZSAV,
+ 1, _("Compressed System File"),
+ -1);
+
+ gtk_list_store_append (list_store, &iter);
+ gtk_list_store_set (list_store, &iter,
+ 0, PSPPIRE_DATA_WINDOW_POR,
+ 1, _("Portable File"),
+ -1);
+
+ label = gtk_label_new (_("Format:"));
+
+ cell = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell, FALSE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (combo_box), cell,
+ "text", 1);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), combo_box, FALSE, FALSE, 0);
+ gtk_widget_show_all (hbox);
+
+ gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (dialog), hbox);
}
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog))
);
- de->save_as_portable =
- ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_sys));
+ GtkTreeIter iter;
+ int format;
+
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo_box), &iter);
+ gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter,
+ 0, &format,
+ -1);
+ de->format = format;
if ( ! name_has_suffix (filename->str))
- {
- if ( de->save_as_portable)
- g_string_append (filename, ".por");
- else
- g_string_append (filename, ".sav");
- }
+ g_string_append (filename,
+ psppire_data_window_format_to_string (format));
psppire_window_set_filename (PSPPIRE_WINDOW (de), filename->str);
enable_save (de);
connect_action (de, "file_new_data", G_CALLBACK (create_data_window));
-
connect_action (de, "file_import", G_CALLBACK (text_data_import_assistant));
-
connect_action (de, "file_save", G_CALLBACK (psppire_window_save));
-
connect_action (de, "file_open", G_CALLBACK (psppire_window_open));
-
connect_action (de, "file_save_as", G_CALLBACK (psppire_window_save_as));
-
connect_action (de, "rename_dataset", G_CALLBACK (on_rename_dataset));
-
connect_action (de, "file_information_working-file", G_CALLBACK (display_dict));
-
connect_action (de, "file_information_external-file", G_CALLBACK (sysfile_info));
g_signal_connect_swapped (get_action_assert (de->builder, "view_value-labels"), "toggled", G_CALLBACK (toggle_value_labels), de);
- connect_action (de, "data_transpose", G_CALLBACK (transpose_dialog));
connect_action (de, "data_select-cases", G_CALLBACK (select_cases_dialog));
connect_action (de, "data_aggregate", G_CALLBACK (aggregate_dialog));
- connect_action (de, "transform_compute", G_CALLBACK (compute_dialog));
connect_action (de, "transform_autorecode", G_CALLBACK (autorecode_dialog));
connect_action (de, "data_split-file", G_CALLBACK (split_file_dialog));
connect_action (de, "data_weight-cases", G_CALLBACK (weight_cases_dialog));
- connect_action (de, "oneway-anova", G_CALLBACK (oneway_anova_dialog));
- connect_action (de, "paired-t-test", G_CALLBACK (t_test_paired_samples_dialog));
- connect_action (de, "one-sample-t-test", G_CALLBACK (t_test_one_sample_dialog));
connect_action (de, "utilities_comments", G_CALLBACK (comments_dialog));
- connect_action (de, "transform_count", G_CALLBACK (count_dialog));
connect_action (de, "transform_recode-same", G_CALLBACK (recode_same_dialog));
connect_action (de, "transform_recode-different", G_CALLBACK (recode_different_dialog));
- connect_action (de, "univariate", G_CALLBACK (univariate_dialog));
- connect_action (de, "chi-square", G_CALLBACK (chisquare_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));
{
GtkWidget *recent_data =