Post by Ben PfaffPost by Hugo AlejandroAre there plans to integrate it into psppire?, My students would appreciate.
I'm working on that.
I came up with the patch below, but I'm too sleepy to verify that it
works and commit it tonight.
--8<--------------------------cut here-------------------------->8--
diff --git a/src/ui/gui/aggregate-dialog.c b/src/ui/gui/aggregate-dialog.c
index 5d477d3..60a8d9f 100644
--- a/src/ui/gui/aggregate-dialog.c
+++ b/src/ui/gui/aggregate-dialog.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2010, 2011, 2012 Free Software Foundation
+ Copyright (C) 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
@@ -168,6 +168,11 @@ choose_filename (struct aggregate *fd)
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_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
diff --git a/src/ui/gui/main.c b/src/ui/gui/main.c
index eb44e81..6bd6d1b 100644
--- a/src/ui/gui/main.c
+++ b/src/ui/gui/main.c
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2004, 2005, 2006, 2010, 2011, 2012 Free Software Foundation
+ Copyright (C) 2004, 2005, 2006, 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
@@ -113,8 +113,8 @@ Informative output:\n\
-h, --help display this help and exit\n\
-V, --version output version information and exit\n\
\n\
-A non-option argument is interpreted as a .sav file, a .por file or a syntax\n\
-file to load.\n"),
+A non-option argument is interpreted as a data file in .sav or .zsav or .por\n\
+format or a syntax file to load.\n"),
program_name, gtk_help, inc_path);
free (inc_path);
diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c
index e820e9d..f3e85d0 100644
--- a/src/ui/gui/psppire-data-window.c
+++ b/src/ui/gui/psppire-data-window.c
@@ -368,6 +368,17 @@ load_file (PsppireWindow *de, const gchar *file_name, gpointer syn)
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)
@@ -384,12 +395,7 @@ 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);
@@ -400,9 +406,13 @@ save_file (PsppireWindow *w)
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);
@@ -450,9 +460,11 @@ sysfile_info (PsppireDataWindow *de)
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),
@@ -463,11 +475,17 @@ data_pick_filename (PsppireWindow *window)
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_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
@@ -478,22 +496,46 @@ data_pick_filename (PsppireWindow *window)
gtk_file_chooser_add_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),
@@ -509,16 +551,16 @@ data_pick_filename (PsppireWindow *window)
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);
+ 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);
diff --git a/src/ui/gui/psppire-data-window.h b/src/ui/gui/psppire-data-window.h
index 63510b3..a0e80fc 100644
--- a/src/ui/gui/psppire-data-window.h
+++ b/src/ui/gui/psppire-data-window.h
@@ -1,5 +1,5 @@
/* PSPPIRE - a graphical user interface for PSPP.
- Copyright (C) 2008, 2010, 2011, 2012 Free Software Foundation
+ Copyright (C) 2008, 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
@@ -52,6 +52,12 @@ typedef struct _PsppireDataWindow PsppireDataWindow;
typedef struct _PsppireDataWindowClass PsppireDataWindowClass;
+enum PsppireDataWindowFormat {
+ PSPPIRE_DATA_WINDOW_SAV,
+ PSPPIRE_DATA_WINDOW_ZSAV,
+ PSPPIRE_DATA_WINDOW_POR
+};
+
struct _PsppireDataWindow
{
PsppireWindow parent;
@@ -65,7 +71,7 @@ struct _PsppireDataWindow
struct dataset *dataset;
PsppireDataStore *data_store;
- gboolean save_as_portable;
+ enum PsppireDataWindowFormat format;
struct ll ll; /* In global 'all_data_windows' list. */
unsigned long int lazy_serial;