X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fgui%2Fdata-editor.c;h=d4cbae1e6716640ea5d2f85c878c91422c410e9f;hb=67ab7839678c0f8aa12459ce5a585a5636f20196;hp=fd5e491f1676294879bdf1047ac23761ff0b281b;hpb=a7fb79e81f6e2a0dfddc61e91f207609e31a4632;p=pspp
diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c
index fd5e491f16..d4cbae1e67 100644
--- a/src/ui/gui/data-editor.c
+++ b/src/ui/gui/data-editor.c
@@ -1,21 +1,18 @@
-/*
- PSPPIRE --- A Graphical User Interface for PSPP
- Copyright (C) 2006, 2007 Free Software Foundation
+/* PSPPIRE - a graphical user interface for PSPP.
+ Copyright (C) 2006, 2007, 2008 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
#include
#include
@@ -25,15 +22,38 @@
#include
#include "window-manager.h"
-#include
+
+#include "psppire-data-editor.h"
#include "helper.h"
#include "about.h"
+#include
#include "psppire-dialog.h"
#include "psppire-selector.h"
#include "weight-cases-dialog.h"
+#include "split-file-dialog.h"
#include "transpose-dialog.h"
+#include "sort-cases-dialog.h"
+#include "select-cases-dialog.h"
+#include "compute-dialog.h"
+#include "goto-case-dialog.h"
+#include "find-dialog.h"
+#include "rank-dialog.h"
+#include "recode-dialog.h"
+#include "comments-dialog.h"
+#include "variable-info-dialog.h"
+#include "descriptives-dialog.h"
+#include "crosstabs-dialog.h"
+#include "frequencies-dialog.h"
+#include "examine-dialog.h"
#include "dict-display.h"
+#include "regression-dialog.h"
+#include "text-data-import-dialog.h"
+
+#include "oneway-anova-dialog.h"
+#include "t-test-independent-samples-dialog.h"
+#include "t-test-one-sample.h"
+#include "t-test-paired-samples.h"
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
@@ -41,25 +61,27 @@
#include "data-editor.h"
#include "syntax-editor.h"
#include
+#include
+#include
#include "window-manager.h"
#include "psppire-data-store.h"
#include "psppire-var-store.h"
-static void register_data_editor_actions (struct data_editor *de);
-
-static void insert_variable (GtkCheckMenuItem *m, gpointer data);
-
+static void on_edit_copy (GtkMenuItem *, gpointer);
+static void on_edit_cut (GtkMenuItem *, gpointer);
+static void on_edit_paste (GtkAction *a, gpointer data);
-/* Switch between the VAR SHEET and the DATA SHEET */
-enum {PAGE_DATA_SHEET = 0, PAGE_VAR_SHEET};
-static gboolean click2column (GtkWidget *w, gint col, gpointer data);
-
-static gboolean click2row (GtkWidget *w, gint row, gpointer data);
+static GtkWidget * create_data_sheet_variable_popup_menu (struct data_editor *);
+static GtkWidget * create_data_sheet_cases_popup_menu (struct data_editor *);
+static void register_data_editor_actions (struct data_editor *de);
+static void on_insert_variable (GtkAction *, gpointer data);
+static void insert_case (GtkAction *a, gpointer data);
-static void select_sheet (struct data_editor *de, guint page_num);
+static void toggle_value_labels (GtkToggleAction *a, gpointer data);
+static void toggle_split_window (GtkToggleAction *ta, gpointer data);
/* Callback for when the dictionary changes properties*/
@@ -67,7 +89,7 @@ static void on_weight_change (GObject *, gint, gpointer);
static void on_filter_change (GObject *, gint, gpointer);
static void on_split_change (PsppireDict *, gpointer);
-static void data_var_select (GtkNotebook *notebook,
+static void on_switch_sheet (GtkNotebook *notebook,
GtkNotebookPage *page,
guint page_num,
gpointer user_data);
@@ -76,42 +98,159 @@ static void status_bar_activate (GtkCheckMenuItem *, gpointer);
static void grid_lines_activate (GtkCheckMenuItem *, gpointer);
-static void data_sheet_activate (GtkCheckMenuItem *, gpointer);
+static void data_view_activate (GtkCheckMenuItem *, gpointer);
-static void variable_sheet_activate (GtkCheckMenuItem *, gpointer );
+static void variable_view_activate (GtkCheckMenuItem *, gpointer );
static void fonts_activate (GtkMenuItem *, gpointer);
-static void value_labels_activate (GtkCheckMenuItem *, gpointer);
-static void value_labels_toggled (GtkToggleToolButton *, gpointer);
+static void file_quit (GtkCheckMenuItem *, gpointer );
+static void
+enable_delete_cases (GtkWidget *w, gint case_num, gpointer data)
+{
+ struct data_editor *de = data;
-static void file_quit (GtkCheckMenuItem *, gpointer );
+ gtk_action_set_visible (de->delete_cases, case_num != -1);
+}
-static void on_clear_activate (GtkMenuItem *, gpointer);
static void
-enable_edit_clear (GtkWidget *w, gint row, gpointer data)
+enable_delete_variables (GtkWidget *w, gint var, gpointer data)
{
struct data_editor *de = data;
- GtkWidget *menuitem = get_widget_assert (de->xml, "edit_clear");
+ gtk_action_set_visible (de->delete_variables, var != -1);
+}
- gtk_widget_set_sensitive (menuitem, TRUE);
+
+
+/* Run the EXECUTE command. */
+static void
+execute (GtkMenuItem *mi, gpointer data)
+{
+ struct getl_interface *sss = create_syntax_string_source ("EXECUTE.");
+
+ execute_syntax (sss);
}
-static gboolean
-disable_edit_clear (GtkWidget *w, gint x, gint y, gpointer data)
+static void
+transformation_change_callback (bool transformations_pending,
+ gpointer data)
{
struct data_editor *de = data;
+ GtkWidget *menuitem =
+ get_widget_assert (de->xml, "transform_run-pending");
+ GtkWidget *status_label =
+ get_widget_assert (de->xml, "case-counter-area");
- GtkWidget *menuitem = get_widget_assert (de->xml, "edit_clear");
+ gtk_widget_set_sensitive (menuitem, transformations_pending);
- gtk_widget_set_sensitive (menuitem, FALSE);
- return FALSE;
+ if ( transformations_pending)
+ gtk_label_set_text (GTK_LABEL (status_label),
+ _("Transformations Pending"));
+ else
+ gtk_label_set_text (GTK_LABEL (status_label), "");
+}
+
+
+static void open_data_file (const gchar *, struct data_editor *);
+
+
+/* Puts FILE_NAME into the recent list.
+ If it's already in the list, it moves it to the top
+*/
+static void
+add_most_recent (const char *file_name)
+{
+#if RECENT_LISTS_AVAILABLE
+
+ GtkRecentManager *manager = gtk_recent_manager_get_default();
+ gchar *uri = g_filename_to_uri (file_name, NULL, NULL);
+
+ gtk_recent_manager_remove_item (manager, uri, NULL);
+
+ if ( ! gtk_recent_manager_add_item (manager, uri))
+ g_warning ("Could not add item %s to recent list\n",uri);
+
+ g_free (uri);
+#endif
+}
+
+
+
+#if RECENT_LISTS_AVAILABLE
+
+static void
+on_recent_data_select (GtkMenuShell *menushell, gpointer user_data)
+{
+ gchar *file;
+ struct data_editor *de = user_data;
+
+ gchar *uri =
+ gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell));
+
+ file = g_filename_from_uri (uri, NULL, NULL);
+
+ g_free (uri);
+
+ open_data_file (file, de);
+
+ g_free (file);
+}
+
+static void
+on_recent_files_select (GtkMenuShell *menushell, gpointer user_data)
+{
+ gchar *file;
+
+ struct syntax_editor *se ;
+
+ gchar *uri =
+ gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell));
+
+ file = g_filename_from_uri (uri, NULL, NULL);
+
+ g_free (uri);
+
+ se = (struct syntax_editor *)
+ window_create (WINDOW_SYNTAX, file);
+
+ load_editor_from_file (se, file, NULL);
+
+ g_free (file);
}
+#endif
+
+
+static void
+update_paste_menuitems (GtkWidget *w, gboolean x, gpointer data)
+{
+ struct data_editor *de = data;
+
+ GtkWidget * edit_paste = get_widget_assert (de->xml, "edit_paste");
+
+ gtk_widget_set_sensitive (edit_paste, x);
+}
+
+static void
+update_cut_copy_menuitems (GtkWidget *w, gboolean x, gpointer data)
+{
+ struct data_editor *de = data;
+
+ GtkWidget * edit_copy = get_widget_assert (de->xml, "edit_copy");
+ GtkWidget * edit_cut = get_widget_assert (de->xml, "edit_cut");
+
+ gtk_widget_set_sensitive (edit_copy, x);
+ gtk_widget_set_sensitive (edit_cut, x);
+}
+
+extern PsppireVarStore *the_var_store;
+extern struct dataset *the_dataset;
+extern PsppireDataStore *the_data_store ;
+
/*
Create a new data editor.
@@ -121,21 +260,38 @@ new_data_editor (void)
{
struct data_editor *de ;
struct editor_window *e;
- GtkSheet *var_sheet ;
PsppireVarStore *vs;
+ GtkWidget *vbox ;
de = g_malloc0 (sizeof (*de));
e = (struct editor_window *) de;
- de->xml = glade_xml_new (PKGDATADIR "/data-editor.glade", NULL, NULL);
+ de->xml = XML_NEW ("data-editor.glade");
- var_sheet = GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+ vbox = get_widget_assert (de->xml, "vbox1");
- vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
+ de->data_editor = PSPPIRE_DATA_EDITOR (psppire_data_editor_new (the_var_store, the_data_store));
- g_assert(vs); /* Traps a possible bug in win32 build */
+ g_signal_connect (de->data_editor, "data-selection-changed",
+ G_CALLBACK (update_cut_copy_menuitems), de);
+
+ g_signal_connect (de->data_editor, "data-available-changed",
+ G_CALLBACK (update_paste_menuitems), de);
+
+
+ gtk_widget_show (GTK_WIDGET (de->data_editor));
+
+ gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (de->data_editor));
+ gtk_box_reorder_child (GTK_BOX (vbox) , GTK_WIDGET (de->data_editor), 2);
+ dataset_add_transform_change_callback (the_dataset,
+ transformation_change_callback,
+ de);
+
+ vs = the_var_store;
+
+ g_assert(vs); /* Traps a possible bug in w32 build */
g_signal_connect (vs->dict, "weight-changed",
G_CALLBACK (on_weight_change),
@@ -152,11 +308,135 @@ new_data_editor (void)
connect_help (de->xml);
+
+ g_signal_connect (get_widget_assert (de->xml, "edit_copy"),
+ "activate",
+ G_CALLBACK (on_edit_copy), de);
+
+ g_signal_connect (get_widget_assert (de->xml, "edit_cut"),
+ "activate",
+ G_CALLBACK (on_edit_cut), de);
+
+
register_data_editor_actions (de);
+ de->toggle_value_labels =
+ gtk_toggle_action_new ("toggle-value-labels",
+ _("_Labels"),
+ _("Show/hide value labels"),
+ "pspp-value-labels");
+
+ g_signal_connect (de->toggle_value_labels, "toggled",
+ G_CALLBACK (toggle_value_labels), de);
+
+
+ gtk_action_connect_proxy (GTK_ACTION (de->toggle_value_labels),
+ get_widget_assert (de->xml,
+ "togglebutton-value-labels"));
+
+
+ gtk_action_connect_proxy (GTK_ACTION (de->toggle_value_labels),
+ get_widget_assert (de->xml,
+ "view_value-labels"));
+
+ de->delete_cases =
+ gtk_action_new ("clear-cases",
+ _("Clear"),
+ _("Delete the cases at the selected position(s)"),
+ "pspp-clear-cases");
+
+ g_signal_connect_swapped (de->delete_cases, "activate",
+ G_CALLBACK (psppire_data_editor_delete_cases),
+ de->data_editor);
+
+ gtk_action_connect_proxy (de->delete_cases,
+ get_widget_assert (de->xml, "edit_clear-cases"));
+
+ g_signal_connect (get_widget_assert (de->xml, "edit_paste"), "activate",
+ G_CALLBACK (on_edit_paste),
+ de);
+
+ gtk_action_set_visible (de->delete_cases, FALSE);
+
+ de->delete_variables =
+ gtk_action_new ("clear-variables",
+ _("Clear"),
+ _("Delete the variables at the selected position(s)"),
+ "pspp-clear-variables");
+
+ g_signal_connect_swapped (de->delete_variables, "activate",
+ G_CALLBACK (psppire_data_editor_delete_variables),
+ de->data_editor);
+
+ gtk_action_connect_proxy (de->delete_variables,
+ get_widget_assert (de->xml, "edit_clear-variables")
+ );
+
+ gtk_action_set_visible (de->delete_variables, FALSE);
+
+ de->insert_variable =
+ gtk_action_new ("insert-variable",
+ _("Insert _Variable"),
+ _("Create a new variable at the current position"),
+ "pspp-insert-variable");
+
+ g_signal_connect (de->insert_variable, "activate",
+ G_CALLBACK (on_insert_variable), de->data_editor);
+
+
+ gtk_action_connect_proxy (de->insert_variable,
+ get_widget_assert (de->xml, "button-insert-variable")
+ );
+
+ gtk_action_connect_proxy (de->insert_variable,
+ get_widget_assert (de->xml, "edit_insert-variable")
+ );
+
+
+ de->insert_case =
+ gtk_action_new ("insert-case",
+ _("Insert Ca_se"),
+ _("Create a new case at the current position"),
+ "pspp-insert-case");
+
+ g_signal_connect (de->insert_case, "activate",
+ G_CALLBACK (insert_case), de);
+
+
+ gtk_action_connect_proxy (de->insert_case,
+ get_widget_assert (de->xml, "button-insert-case")
+ );
+
+
+ gtk_action_connect_proxy (de->insert_case,
+ get_widget_assert (de->xml, "edit_insert-case")
+ );
+
+
+
+ de->invoke_goto_dialog =
+ gtk_action_new ("goto-case-dialog",
+ _("_Goto Case"),
+ _("Jump to a Case in the Data Sheet"),
+ "gtk-jump-to");
+
+
+ gtk_action_connect_proxy (de->invoke_goto_dialog,
+ get_widget_assert (de->xml, "button-goto-case")
+ );
+
+ gtk_action_connect_proxy (de->invoke_goto_dialog,
+ get_widget_assert (de->xml, "edit_goto-case")
+ );
+
+
+ g_signal_connect (de->invoke_goto_dialog, "activate",
+ G_CALLBACK (goto_case_dialog), de);
+
+
de->invoke_weight_cases_dialog =
gtk_action_new ("weight-cases-dialog",
- _("Weights"),
+ _("_Weights"),
_("Weight cases by variable"),
"pspp-weight-cases");
@@ -166,7 +446,7 @@ new_data_editor (void)
de->invoke_transpose_dialog =
gtk_action_new ("transpose-dialog",
- _("Transpose"),
+ _("_Transpose"),
_("Transpose the cases with the variables"),
NULL);
@@ -175,6 +455,191 @@ new_data_editor (void)
G_CALLBACK (transpose_dialog), de);
+
+ de->invoke_split_file_dialog =
+ gtk_action_new ("split-file-dialog",
+ _("S_plit"),
+ _("Split the active file"),
+ "pspp-split-file");
+
+ g_signal_connect (de->invoke_split_file_dialog, "activate",
+ G_CALLBACK (split_file_dialog), de);
+
+
+
+ de->invoke_sort_cases_dialog =
+ gtk_action_new ("sort-cases-dialog",
+ _("_Sort"),
+ _("Sort cases in the active file"),
+ "pspp-sort-cases");
+
+ g_signal_connect (de->invoke_sort_cases_dialog, "activate",
+ G_CALLBACK (sort_cases_dialog), de);
+
+ de->invoke_select_cases_dialog =
+ gtk_action_new ("select-cases-dialog",
+ _("Select _Cases"),
+ _("Select cases from the active file"),
+ "pspp-select-cases");
+
+ g_signal_connect (de->invoke_select_cases_dialog, "activate",
+ G_CALLBACK (select_cases_dialog), de);
+
+
+ de->invoke_compute_dialog =
+ gtk_action_new ("compute-dialog",
+ _("_Compute"),
+ _("Compute new values for a variable"),
+ "pspp-compute");
+
+ g_signal_connect (de->invoke_compute_dialog, "activate",
+ G_CALLBACK (compute_dialog), de);
+
+ de->invoke_oneway_anova_dialog =
+ gtk_action_new ("oneway-anova",
+ _("Oneway _ANOVA"),
+ _("Perform one way analysis of variance"),
+ NULL);
+
+ g_signal_connect (de->invoke_oneway_anova_dialog, "activate",
+ G_CALLBACK (oneway_anova_dialog), de);
+
+ de->invoke_t_test_independent_samples_dialog =
+ gtk_action_new ("t-test-independent-samples",
+ _("_Independent Samples T Test"),
+ _("Calculate T Test for samples from independent groups"),
+ NULL);
+
+ g_signal_connect (de->invoke_t_test_independent_samples_dialog, "activate",
+ G_CALLBACK (t_test_independent_samples_dialog), de);
+
+
+ de->invoke_t_test_paired_samples_dialog =
+ gtk_action_new ("t-test-paired-samples",
+ _("_Paired Samples T Test"),
+ _("Calculate T Test for paired samples"),
+ NULL);
+
+ g_signal_connect (de->invoke_t_test_paired_samples_dialog, "activate",
+ G_CALLBACK (t_test_paired_samples_dialog), de);
+
+
+ de->invoke_t_test_one_sample_dialog =
+ gtk_action_new ("t-test-one-sample",
+ _("One _Sample T Test"),
+ _("Calculate T Test for sample from a single distribution"),
+ NULL);
+
+ g_signal_connect (de->invoke_t_test_one_sample_dialog, "activate",
+ G_CALLBACK (t_test_one_sample_dialog), de);
+
+
+ de->invoke_comments_dialog =
+ gtk_action_new ("commments-dialog",
+ _("Data File _Comments"),
+ _("Commentary text for the data file"),
+ NULL);
+
+ g_signal_connect (de->invoke_comments_dialog, "activate",
+ G_CALLBACK (comments_dialog), de);
+
+ de->invoke_find_dialog =
+ gtk_action_new ("find-dialog",
+ _("_Find"),
+ _("Find Case"),
+ "gtk-find");
+
+ g_signal_connect (de->invoke_find_dialog, "activate",
+ G_CALLBACK (find_dialog), de);
+
+
+ de->invoke_rank_dialog =
+ gtk_action_new ("rank-dialog",
+ _("Ran_k Cases"),
+ _("Rank Cases"),
+ "pspp-rank-cases");
+
+ g_signal_connect (de->invoke_rank_dialog, "activate",
+ G_CALLBACK (rank_dialog), de);
+
+
+ de->invoke_recode_same_dialog =
+ gtk_action_new ("recode-same-dialog",
+ _("Recode into _Same Variables"),
+ _("Recode values into the same Variables"),
+ "pspp-recode-same");
+
+ g_signal_connect (de->invoke_recode_same_dialog, "activate",
+ G_CALLBACK (recode_same_dialog), de);
+
+
+ de->invoke_recode_different_dialog =
+ gtk_action_new ("recode-different-dialog",
+ _("Recode into _Different Variables"),
+ _("Recode values into different Variables"),
+ "pspp-recode-different");
+
+ g_signal_connect (de->invoke_recode_different_dialog, "activate",
+ G_CALLBACK (recode_different_dialog), de);
+
+
+ de->invoke_variable_info_dialog =
+ gtk_action_new ("variable-info-dialog",
+ _("_Variables"),
+ _("Jump to Variable"),
+ "pspp-goto-variable");
+
+ g_signal_connect (de->invoke_variable_info_dialog, "activate",
+ G_CALLBACK (variable_info_dialog), de);
+
+ de->invoke_descriptives_dialog =
+ gtk_action_new ("descriptives-dialog",
+ _("_Descriptives"),
+ _("Calculate descriptive statistics (mean, variance, ...)"),
+ "pspp-descriptives");
+
+ g_signal_connect (de->invoke_descriptives_dialog, "activate",
+ G_CALLBACK (descriptives_dialog), de);
+
+
+ de->invoke_frequencies_dialog =
+ gtk_action_new ("frequencies-dialog",
+ _("_Frequencies"),
+ _("Generate frequency statistics"),
+ "pspp-frequencies");
+
+ g_signal_connect (de->invoke_frequencies_dialog, "activate",
+ G_CALLBACK (frequencies_dialog), de);
+
+ de->invoke_crosstabs_dialog =
+ gtk_action_new ("crosstabs-dialog",
+ _("_Crosstabs"),
+ _("Generate crosstabulations"),
+ "pspp-crosstabs");
+
+ g_signal_connect (de->invoke_crosstabs_dialog, "activate",
+ G_CALLBACK (crosstabs_dialog), de);
+
+
+ de->invoke_examine_dialog =
+ gtk_action_new ("examine-dialog",
+ _("_Explore"),
+ _("Examine Data by Factors"),
+ "pspp-examine");
+
+ g_signal_connect (de->invoke_examine_dialog, "activate",
+ G_CALLBACK (examine_dialog), de);
+
+
+ de->invoke_regression_dialog =
+ gtk_action_new ("regression-dialog",
+ _("Linear _Regression"),
+ _("Estimate parameters of the linear model"),
+ "pspp-regression");
+
+ g_signal_connect (de->invoke_regression_dialog, "activate",
+ G_CALLBACK (regression_dialog), de);
+
e->window = GTK_WINDOW (get_widget_assert (de->xml, "data_editor"));
g_signal_connect_swapped (get_widget_assert (de->xml,"file_new_data"),
@@ -187,6 +652,49 @@ new_data_editor (void)
G_CALLBACK (gtk_action_activate),
de->action_data_open);
+#if RECENT_LISTS_AVAILABLE
+ {
+ GtkRecentManager *rm = gtk_recent_manager_get_default ();
+ GtkWidget *recent_data = get_widget_assert (de->xml, "file_recent-data");
+ GtkWidget *recent_files = get_widget_assert (de->xml, "file_recent-files");
+ GtkWidget *recent_separator = get_widget_assert (de->xml, "file_separator1");
+
+ GtkWidget *menu = gtk_recent_chooser_menu_new_for_manager (rm);
+
+ GtkRecentFilter *filter = gtk_recent_filter_new ();
+
+ gtk_widget_show (recent_data);
+ gtk_widget_show (recent_files);
+ gtk_widget_show (recent_separator);
+
+ gtk_recent_filter_add_pattern (filter, "*.sav");
+ gtk_recent_filter_add_pattern (filter, "*.SAV");
+
+ gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter);
+
+ gtk_widget_set_sensitive (recent_data, TRUE);
+ g_signal_connect (menu, "selection-done",
+ G_CALLBACK (on_recent_data_select), de);
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (recent_data), menu);
+
+
+ filter = gtk_recent_filter_new ();
+ menu = gtk_recent_chooser_menu_new_for_manager (rm);
+
+ gtk_recent_filter_add_pattern (filter, "*.sps");
+ gtk_recent_filter_add_pattern (filter, "*.SPS");
+
+ gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter);
+
+ gtk_widget_set_sensitive (recent_files, TRUE);
+ g_signal_connect (menu, "selection-done",
+ G_CALLBACK (on_recent_files_select), de);
+
+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (recent_files), menu);
+ }
+#endif
+
g_signal_connect (get_widget_assert (de->xml,"file_new_syntax"),
"activate",
G_CALLBACK (new_syntax_window),
@@ -197,6 +705,11 @@ new_data_editor (void)
G_CALLBACK (open_syntax_window),
e->window);
+ g_signal_connect_swapped (get_widget_assert (de->xml,"file_import-text"),
+ "activate",
+ G_CALLBACK (gtk_action_activate),
+ de->invoke_text_import_assistant);
+
g_signal_connect_swapped (get_widget_assert (de->xml,"file_save"),
"activate",
G_CALLBACK (gtk_action_activate),
@@ -207,17 +720,27 @@ new_data_editor (void)
G_CALLBACK (gtk_action_activate),
de->action_data_save_as);
+ gtk_action_connect_proxy (de->invoke_find_dialog,
+ get_widget_assert (de->xml, "edit_find")
+ );
- g_signal_connect (get_widget_assert (de->xml,"edit_clear"),
- "activate",
- G_CALLBACK (on_clear_activate),
- de);
+ gtk_action_connect_proxy (de->invoke_find_dialog,
+ get_widget_assert (de->xml, "button-find")
+ );
+ gtk_action_connect_proxy (de->invoke_rank_dialog,
+ get_widget_assert (de->xml, "transform_rank")
+ );
- g_signal_connect (get_widget_assert (de->xml,"data_insert-variable"),
- "activate",
- G_CALLBACK (insert_variable),
- de);
+ gtk_action_connect_proxy (de->invoke_recode_same_dialog,
+ get_widget_assert (de->xml,
+ "transform_recode-same")
+ );
+
+ gtk_action_connect_proxy (de->invoke_recode_different_dialog,
+ get_widget_assert (de->xml,
+ "transform_recode-different")
+ );
gtk_action_connect_proxy (de->invoke_weight_cases_dialog,
get_widget_assert (de->xml, "data_weight-cases")
@@ -227,6 +750,75 @@ new_data_editor (void)
get_widget_assert (de->xml, "data_transpose")
);
+ gtk_action_connect_proxy (de->invoke_split_file_dialog,
+ get_widget_assert (de->xml, "data_split-file")
+ );
+
+ gtk_action_connect_proxy (de->invoke_sort_cases_dialog,
+ get_widget_assert (de->xml, "data_sort-cases")
+ );
+
+ gtk_action_connect_proxy (de->invoke_select_cases_dialog,
+ get_widget_assert (de->xml, "data_select-cases")
+ );
+
+ gtk_action_connect_proxy (de->invoke_compute_dialog,
+ get_widget_assert (de->xml, "transform_compute")
+ );
+
+ gtk_action_connect_proxy (de->invoke_t_test_independent_samples_dialog,
+ get_widget_assert (de->xml,
+ "indep-t-test")
+ );
+
+
+ gtk_action_connect_proxy (de->invoke_t_test_paired_samples_dialog,
+ get_widget_assert (de->xml,
+ "paired-t-test")
+ );
+
+
+ gtk_action_connect_proxy (de->invoke_t_test_one_sample_dialog,
+ get_widget_assert (de->xml,
+ "one-sample-t-test")
+ );
+
+
+ gtk_action_connect_proxy (de->invoke_oneway_anova_dialog,
+ get_widget_assert (de->xml,
+ "oneway-anova")
+ );
+
+
+ gtk_action_connect_proxy (de->invoke_comments_dialog,
+ get_widget_assert (de->xml, "utilities_comments")
+ );
+
+ gtk_action_connect_proxy (de->invoke_variable_info_dialog,
+ get_widget_assert (de->xml, "utilities_variables")
+ );
+
+ gtk_action_connect_proxy (de->invoke_descriptives_dialog,
+ get_widget_assert (de->xml, "analyze_descriptives")
+ );
+
+ gtk_action_connect_proxy (de->invoke_crosstabs_dialog,
+ get_widget_assert (de->xml, "crosstabs")
+ );
+
+ gtk_action_connect_proxy (de->invoke_frequencies_dialog,
+ get_widget_assert (de->xml, "analyze_frequencies")
+ );
+
+
+ gtk_action_connect_proxy (de->invoke_examine_dialog,
+ get_widget_assert (de->xml, "analyze_explore")
+ );
+
+ gtk_action_connect_proxy (de->invoke_regression_dialog,
+ get_widget_assert (de->xml, "linear-regression")
+ );
+
g_signal_connect (get_widget_assert (de->xml,"help_about"),
"activate",
G_CALLBACK (about_new),
@@ -239,35 +831,24 @@ new_data_editor (void)
e->window);
-
- g_signal_connect (get_widget_assert (de->xml,"data_sheet"),
- "double-click-column",
- G_CALLBACK (click2column),
- de);
-
-
- g_signal_connect (get_widget_assert (de->xml, "variable_sheet"),
- "double-click-row",
- GTK_SIGNAL_FUNC (click2row),
+ g_signal_connect (de->data_editor,
+ "cases-selected",
+ G_CALLBACK (enable_delete_cases),
de);
- g_signal_connect (get_widget_assert (de->xml, "variable_sheet"),
- "select-row",
- GTK_SIGNAL_FUNC (enable_edit_clear),
- de);
-
- g_signal_connect (get_widget_assert (de->xml, "variable_sheet"),
- "activate",
- GTK_SIGNAL_FUNC (disable_edit_clear),
+ g_signal_connect (de->data_editor,
+ "variables-selected",
+ G_CALLBACK (enable_delete_variables),
de);
- g_signal_connect (get_widget_assert (de->xml, "notebook"),
+ g_signal_connect (GTK_NOTEBOOK (de->data_editor),
"switch-page",
- G_CALLBACK (data_var_select), de);
-
+ G_CALLBACK (on_switch_sheet), de);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW);
g_signal_connect (get_widget_assert (de->xml, "view_statusbar"),
"activate",
@@ -282,11 +863,11 @@ new_data_editor (void)
g_signal_connect (get_widget_assert (de->xml, "view_data"),
"activate",
- G_CALLBACK (data_sheet_activate), de);
+ G_CALLBACK (data_view_activate), de);
g_signal_connect (get_widget_assert (de->xml, "view_variables"),
"activate",
- G_CALLBACK (variable_sheet_activate), de);
+ G_CALLBACK (variable_view_activate), de);
@@ -296,14 +877,6 @@ new_data_editor (void)
- g_signal_connect (get_widget_assert (de->xml, "view_valuelabels"),
- "activate",
- G_CALLBACK (value_labels_activate), de);
-
-
- g_signal_connect (get_widget_assert (de->xml, "togglebutton-value-labels"),
- "toggled",
- G_CALLBACK (value_labels_toggled), de);
gtk_action_connect_proxy (de->action_data_open,
get_widget_assert (de->xml, "button-open")
@@ -313,67 +886,65 @@ new_data_editor (void)
get_widget_assert (de->xml, "button-save")
);
+ gtk_action_connect_proxy (de->invoke_variable_info_dialog,
+ get_widget_assert (de->xml, "button-goto-variable")
+ );
+
gtk_action_connect_proxy (de->invoke_weight_cases_dialog,
get_widget_assert (de->xml, "button-weight-cases")
);
+ gtk_action_connect_proxy (de->invoke_split_file_dialog,
+ get_widget_assert (de->xml, "button-split-file")
+ );
+
+ gtk_action_connect_proxy (de->invoke_select_cases_dialog,
+ get_widget_assert (de->xml, "button-select-cases")
+ );
+
+
g_signal_connect (get_widget_assert (de->xml, "file_quit"),
"activate",
G_CALLBACK (file_quit), de);
+ g_signal_connect (get_widget_assert (de->xml, "transform_run-pending"),
+ "activate",
+ G_CALLBACK (execute), de);
+
g_signal_connect (get_widget_assert (de->xml, "windows_minimise_all"),
"activate",
G_CALLBACK (minimise_all_windows), NULL);
+ de->toggle_split_window =
+ gtk_toggle_action_new ("toggle-split-window",
+ _("_Split Window"),
+ _("Split the window vertically and horizontally"),
+ "pspp-split-window");
- select_sheet (de, PAGE_DATA_SHEET);
-
- return de;
-}
-
-
-/* Callback which occurs when the var sheet's row title
- button is double clicked */
-static gboolean
-click2row (GtkWidget *w, gint row, gpointer data)
-{
- struct data_editor *de = data;
-
- gint current_row, current_column;
-
- GtkWidget *data_sheet = get_widget_assert (de->xml, "data_sheet");
-
- data_editor_select_sheet (de, PAGE_DATA_SHEET);
-
- gtk_sheet_get_active_cell (GTK_SHEET (data_sheet),
- ¤t_row, ¤t_column);
-
- gtk_sheet_set_active_cell (GTK_SHEET (data_sheet), current_row, row);
+ g_signal_connect (de->toggle_split_window, "toggled",
+ G_CALLBACK (toggle_split_window),
+ de);
- return FALSE;
-}
+ gtk_action_connect_proxy (GTK_ACTION (de->toggle_split_window),
+ get_widget_assert (de->xml,
+ "windows_split"));
+ de->data_sheet_variable_popup_menu =
+ GTK_MENU (create_data_sheet_variable_popup_menu (de));
-/* Callback which occurs when the data sheet's column title
- is double clicked */
-static gboolean
-click2column (GtkWidget *w, gint col, gpointer data)
-{
- struct data_editor *de = data;
+ de->data_sheet_cases_popup_menu =
+ GTK_MENU (create_data_sheet_cases_popup_menu (de));
- gint current_row, current_column;
- GtkWidget *var_sheet = get_widget_assert (de->xml, "variable_sheet");
+ g_object_set (de->data_editor,
+ "column-menu", de->data_sheet_variable_popup_menu, NULL);
- data_editor_select_sheet (de, PAGE_VAR_SHEET);
- gtk_sheet_get_active_cell (GTK_SHEET (var_sheet),
- ¤t_row, ¤t_column);
+ g_object_set (de->data_editor,
+ "row-menu", de->data_sheet_cases_popup_menu, NULL);
- gtk_sheet_set_active_cell (GTK_SHEET (var_sheet), col, current_column);
-
- return FALSE;
+ return de;
}
@@ -383,59 +954,41 @@ new_data_window (GtkMenuItem *menuitem, gpointer parent)
window_create (WINDOW_DATA, NULL);
}
-
+/* Callback for when the datasheet/varsheet is selected */
static void
-select_sheet (struct data_editor *de, guint page_num)
+on_switch_sheet (GtkNotebook *notebook,
+ GtkNotebookPage *page,
+ guint page_num,
+ gpointer user_data)
{
- GtkWidget *insert_variable = get_widget_assert (de->xml, "data_insert-variable");
- GtkWidget *insert_cases = get_widget_assert (de->xml, "insert-cases");
+ struct data_editor *de = user_data;
GtkWidget *view_data = get_widget_assert (de->xml, "view_data");
GtkWidget *view_variables = get_widget_assert (de->xml, "view_variables");
switch (page_num)
{
- case PAGE_VAR_SHEET:
+ case PSPPIRE_DATA_EDITOR_VARIABLE_VIEW:
gtk_widget_hide (view_variables);
gtk_widget_show (view_data);
- gtk_widget_set_sensitive (insert_variable, TRUE);
- gtk_widget_set_sensitive (insert_cases, FALSE);
+ gtk_action_set_sensitive (de->insert_variable, TRUE);
+ gtk_action_set_sensitive (de->insert_case, FALSE);
+ gtk_action_set_sensitive (de->invoke_goto_dialog, FALSE);
break;
- case PAGE_DATA_SHEET:
+ case PSPPIRE_DATA_EDITOR_DATA_VIEW:
gtk_widget_show (view_variables);
gtk_widget_hide (view_data);
-#if 0
- gtk_widget_set_sensitive (insert_cases, TRUE);
-#endif
+ gtk_action_set_sensitive (de->invoke_goto_dialog, TRUE);
+ gtk_action_set_sensitive (de->insert_case, TRUE);
break;
default:
g_assert_not_reached ();
break;
}
-}
-
-
-static void
-data_var_select (GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- gpointer user_data)
-{
- struct data_editor *de = user_data;
-
- select_sheet (de, page_num);
-}
-
-
-
-void
-data_editor_select_sheet (struct data_editor *de, gint page)
-{
- gtk_notebook_set_current_page
- (
- GTK_NOTEBOOK (get_widget_assert (de->xml,"notebook")), page
- );
+#if 0
+ update_paste_menuitem (de, page_num);
+#endif
}
@@ -456,33 +1009,28 @@ static void
grid_lines_activate (GtkCheckMenuItem *menuitem, gpointer data)
{
struct data_editor *de = data;
- const bool grid_visible = gtk_check_menu_item_get_active (menuitem);
-
- gtk_sheet_show_grid (GTK_SHEET (get_widget_assert (de->xml,
- "variable_sheet")),
- grid_visible);
+ const gboolean grid_visible = gtk_check_menu_item_get_active (menuitem);
- gtk_sheet_show_grid (GTK_SHEET (get_widget_assert (de->xml, "data_sheet")),
- grid_visible);
+ psppire_data_editor_show_grid (de->data_editor, grid_visible);
}
static void
-data_sheet_activate (GtkCheckMenuItem *menuitem, gpointer data)
+data_view_activate (GtkCheckMenuItem *menuitem, gpointer data)
{
struct data_editor *de = data;
- data_editor_select_sheet (de, PAGE_DATA_SHEET);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW);
}
static void
-variable_sheet_activate (GtkCheckMenuItem *menuitem, gpointer data)
+variable_view_activate (GtkCheckMenuItem *menuitem, gpointer data)
{
struct data_editor *de = data;
- data_editor_select_sheet (de, PAGE_VAR_SHEET);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW);
}
@@ -498,74 +1046,41 @@ fonts_activate (GtkMenuItem *menuitem, gpointer data)
"data_editor")));
if ( GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (dialog)) )
{
- GtkSheet *data_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
-
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
-
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet));
- PsppireVarStore *vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
-
const gchar *font = gtk_font_selection_dialog_get_font_name
(GTK_FONT_SELECTION_DIALOG (dialog));
PangoFontDescription* font_desc =
pango_font_description_from_string (font);
- psppire_var_store_set_font (vs, font_desc);
- psppire_data_store_set_font (ds, font_desc);
+ psppire_data_editor_set_font (de->data_editor, font_desc);
}
gtk_widget_hide (dialog);
}
-/* The next two callbacks are mutually co-operative */
-/* Callback for the value labels menu item */
+/* Callback for the value labels action */
static void
-value_labels_activate (GtkCheckMenuItem *menuitem, gpointer data)
+toggle_value_labels (GtkToggleAction *ta, gpointer data)
{
struct data_editor *de = data;
- GtkSheet *data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
-
- GtkToggleToolButton *tb =
- GTK_TOGGLE_TOOL_BUTTON (get_widget_assert (de->xml,
- "togglebutton-value-labels"));
-
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet));
-
- gboolean show_value_labels = gtk_check_menu_item_get_active (menuitem);
-
- gtk_toggle_tool_button_set_active (tb, show_value_labels);
-
- psppire_data_store_show_labels (ds, show_value_labels);
+ g_object_set (de->data_editor, "value-labels", gtk_toggle_action_get_active (ta), NULL);
}
-/* Callback for the value labels tooglebutton */
+
static void
-value_labels_toggled (GtkToggleToolButton *toggle_tool_button,
- gpointer data)
+toggle_split_window (GtkToggleAction *ta, gpointer data)
{
struct data_editor *de = data;
- GtkSheet *data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
-
- GtkCheckMenuItem *item =
- GTK_CHECK_MENU_ITEM (get_widget_assert (de->xml, "view_valuelabels"));
-
- PsppireDataStore *ds = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet));
-
- gboolean show_value_labels =
- gtk_toggle_tool_button_get_active (toggle_tool_button);
+ psppire_data_editor_split_window (de->data_editor,
+ gtk_toggle_action_get_active (ta));
+}
- gtk_check_menu_item_set_active (item, show_value_labels);
- psppire_data_store_show_labels (ds, show_value_labels);
-}
static void
@@ -574,88 +1089,27 @@ file_quit (GtkCheckMenuItem *menuitem, gpointer data)
/* FIXME: Need to be more intelligent here.
Give the user the opportunity to save any unsaved data.
*/
+ g_object_unref (the_data_store);
gtk_main_quit ();
}
-
-/* Callback for when the Clear item in the edit menu is activated */
static void
-on_clear_activate (GtkMenuItem *menuitem, gpointer data)
+insert_case (GtkAction *action, gpointer data)
{
struct data_editor *de = data;
- GtkNotebook *notebook = GTK_NOTEBOOK (get_widget_assert (de->xml,
- "notebook"));
-
- switch ( gtk_notebook_get_current_page (notebook) )
- {
- case PAGE_VAR_SHEET:
- {
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
-
- PsppireVarStore *vs = PSPPIRE_VAR_STORE
- (gtk_sheet_get_model (var_sheet) );
-
- /* This shouldn't be able to happen, because the menuitem
- should be disabled */
- g_return_if_fail (var_sheet->state == GTK_SHEET_ROW_SELECTED );
-
- psppire_dict_delete_variables (vs->dict,
- var_sheet->range.row0,
- 1 +
- var_sheet->range.rowi -
- var_sheet->range.row0 );
- }
- break;
- case PAGE_DATA_SHEET:
- break;
- default:
- g_assert_not_reached ();
- }
+ psppire_data_editor_insert_case (de->data_editor);
}
-
-/* Insert a new variable before the current row in the variable sheet,
- or before the current column in the data sheet, whichever is selected */
static void
-insert_variable (GtkCheckMenuItem *m, gpointer data)
+on_insert_variable (GtkAction *action, gpointer data)
{
- struct data_editor *de = data;
- gint posn;
-
- GtkWidget *notebook = get_widget_assert (de->xml, "notebook");
-
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
-
- PsppireVarStore *vs = PSPPIRE_VAR_STORE
- (gtk_sheet_get_model (var_sheet) );
-
- switch ( gtk_notebook_get_current_page ( GTK_NOTEBOOK (notebook)) )
- {
- case PAGE_VAR_SHEET:
- posn = var_sheet->active_cell.row;
- break;
- case PAGE_DATA_SHEET:
- {
- GtkSheet *data_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
-
- if ( data_sheet->state == GTK_SHEET_COLUMN_SELECTED )
- posn = data_sheet->range.col0;
- else
- posn = data_sheet->active_cell.col;
- }
- break;
- default:
- g_assert_not_reached ();
- }
-
- psppire_dict_insert_variable (vs->dict, posn, NULL);
+ PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data);
+ psppire_data_editor_insert_variable (de);
}
+
/* Callback for when the dictionary changes its split variables */
static void
on_split_change (PsppireDict *dict, gpointer data)
@@ -675,7 +1129,8 @@ on_split_change (PsppireDict *dict, gpointer data)
{
gint i;
GString *text;
- struct variable *const * split_vars = dict_get_split_vars (dict->dict);
+ const struct variable *const * split_vars =
+ dict_get_split_vars (dict->dict);
text = g_string_new (_("Split by "));
@@ -706,16 +1161,15 @@ on_filter_change (GObject *o, gint filter_index, gpointer data)
}
else
{
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+ PsppireVarStore *vs = NULL;
+ struct variable *var ;
+ gchar *text ;
- PsppireVarStore *vs = PSPPIRE_VAR_STORE
- (gtk_sheet_get_model (var_sheet) );
+ g_object_get (de->data_editor, "var-store", &vs, NULL);
- struct variable *var = psppire_dict_get_variable (vs->dict,
- filter_index);
+ var = psppire_dict_get_variable (vs->dict, filter_index);
- gchar *text = g_strdup_printf (_("Filter by %s"), var_get_name (var));
+ text = g_strdup_printf (_("Filter by %s"), var_get_name (var));
gtk_label_set_text (GTK_LABEL (filter_status_area), text);
@@ -737,16 +1191,15 @@ on_weight_change (GObject *o, gint weight_index, gpointer data)
}
else
{
- GtkSheet *var_sheet =
- GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
+ struct variable *var ;
+ PsppireVarStore *vs = NULL;
+ gchar *text;
- PsppireVarStore *vs = PSPPIRE_VAR_STORE
- (gtk_sheet_get_model (var_sheet) );
+ g_object_get (de->data_editor, "var-store", &vs, NULL);
- struct variable *var = psppire_dict_get_variable (vs->dict,
- weight_index);
+ var = psppire_dict_get_variable (vs->dict, weight_index);
- gchar *text = g_strdup_printf (_("Weight by %s"), var_get_name (var));
+ text = g_strdup_printf (_("Weight by %s"), var_get_name (var));
gtk_label_set_text (GTK_LABEL (weight_status_area), text);
@@ -803,6 +1256,15 @@ register_data_editor_actions (struct data_editor *de)
g_signal_connect (de->action_data_new, "activate",
G_CALLBACK (new_file), de);
+
+ de->invoke_text_import_assistant =
+ gtk_action_new ("file_import-text",
+ _("_Import Text Data"),
+ _("Import text data file"),
+ "");
+
+ g_signal_connect (de->invoke_text_import_assistant, "activate",
+ G_CALLBACK (text_data_import_assistant), de);
}
/* Returns true if NAME has a suffix which might denote a PSPP file */
@@ -838,22 +1300,28 @@ static void
save_file (struct data_editor *de)
{
struct getl_interface *sss;
+ struct string file_name ;
g_assert (de->file_name);
+ ds_init_empty (&file_name);
+ syntax_gen_string (&file_name, ss_cstr (de->file_name));
+
if ( de->save_as_portable )
{
append_filename_suffix (de, ".por");
- sss = create_syntax_string_source ("EXPORT OUTFILE='%s'.",
- de->file_name);
+ sss = create_syntax_string_source ("EXPORT OUTFILE=%s.",
+ ds_cstr (&file_name));
}
else
{
append_filename_suffix (de, ".sav");
- sss = create_syntax_string_source ("SAVE OUTFILE='%s'.",
- de->file_name);
+ sss = create_syntax_string_source ("SAVE OUTFILE=%s.",
+ ds_cstr (&file_name));
}
+ ds_destroy (&file_name);
+
execute_syntax (sss);
}
@@ -934,6 +1402,11 @@ data_save_as_dialog (GtkAction *action, struct data_editor *de)
de->save_as_portable =
! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_sys));
+ if ( de->save_as_portable)
+ append_filename_suffix (de, ".por");
+ else
+ append_filename_suffix (de, ".sav");
+
save_file (de);
window_set_name_from_filename (e, de->file_name);
@@ -966,6 +1439,28 @@ new_file (GtkAction *action, struct editor_window *e)
}
+static void
+open_data_file (const gchar *file_name, struct data_editor *de)
+{
+ struct getl_interface *sss;
+ struct string filename;
+
+ ds_init_empty (&filename);
+ syntax_gen_string (&filename, ss_cstr (file_name));
+
+ sss = create_syntax_string_source ("GET FILE=%s.",
+ ds_cstr (&filename));
+ ds_destroy (&filename);
+
+ if (execute_syntax (sss) )
+ {
+ window_set_name_from_filename ((struct editor_window *) de, file_name);
+ add_most_recent (file_name);
+ }
+}
+
+
+
/* Callback for the data_open action.
Prompts for a filename and opens it */
static void
@@ -998,20 +1493,24 @@ open_data_dialog (GtkAction *action, struct data_editor *de)
gtk_file_filter_add_pattern (filter, "*");
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ if ( de->file_name)
+ {
+ gchar *dir_name = g_path_get_dirname (de->file_name);
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
+ dir_name);
+ free (dir_name);
+ }
+
switch (gtk_dialog_run (GTK_DIALOG (dialog)))
{
case GTK_RESPONSE_ACCEPT:
{
- struct getl_interface *sss;
g_free (de->file_name);
de->file_name =
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- sss = create_syntax_string_source ("GET FILE='%s'.", de->file_name);
-
- execute_syntax (sss);
-
- window_set_name_from_filename (e, de->file_name);
+ open_data_file (de->file_name, de);
}
break;
default:
@@ -1022,5 +1521,126 @@ open_data_dialog (GtkAction *action, struct data_editor *de)
}
+static GtkWidget *
+create_data_sheet_variable_popup_menu (struct data_editor *de)
+{
+ GtkWidget *menu = gtk_menu_new ();
+
+ GtkWidget *sort_ascending =
+ gtk_menu_item_new_with_label (_("Sort Ascending"));
+
+ GtkWidget *sort_descending =
+ gtk_menu_item_new_with_label (_("Sort Descending"));
+
+ GtkWidget *insert_variable =
+ gtk_menu_item_new_with_label (_("Insert Variable"));
+
+ GtkWidget *clear_variable =
+ gtk_menu_item_new_with_label (_("Clear"));
+
+
+ gtk_action_connect_proxy (de->delete_variables,
+ clear_variable );
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+ gtk_separator_menu_item_new ());
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), clear_variable);
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+ gtk_separator_menu_item_new ());
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_ascending);
+
+
+ g_signal_connect_swapped (G_OBJECT (sort_ascending), "activate",
+ G_CALLBACK (psppire_data_editor_sort_ascending),
+ de->data_editor);
+
+ g_signal_connect_swapped (G_OBJECT (sort_descending), "activate",
+ G_CALLBACK (psppire_data_editor_sort_descending),
+ de->data_editor);
+
+ g_signal_connect_swapped (G_OBJECT (insert_variable), "activate",
+ G_CALLBACK (gtk_action_activate),
+ de->insert_variable);
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_descending);
+
+ gtk_widget_show_all (menu);
+
+ return menu;
+}
+
+
+static GtkWidget *
+create_data_sheet_cases_popup_menu (struct data_editor *de)
+{
+ GtkWidget *menu = gtk_menu_new ();
+
+ GtkWidget *insert_case =
+ gtk_menu_item_new_with_label (_("Insert Case"));
+
+ GtkWidget *delete_case =
+ gtk_menu_item_new_with_label (_("Clear"));
+
+
+ gtk_action_connect_proxy (de->delete_cases,
+ delete_case);
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_case);
+
+ g_signal_connect_swapped (G_OBJECT (insert_case), "activate",
+ G_CALLBACK (gtk_action_activate),
+ de->insert_case);
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+ gtk_separator_menu_item_new ());
+
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_case);
+
+
+ gtk_widget_show_all (menu);
+
+ return menu;
+}
+
+
+
+
+static void
+on_edit_paste (GtkAction *a, gpointer data)
+{
+ struct data_editor *de = data;
+
+ psppire_data_editor_clip_paste (de->data_editor);
+}
+
+static void
+on_edit_copy (GtkMenuItem *m, gpointer data)
+{
+ struct data_editor *de = data;
+
+ psppire_data_editor_clip_copy (de->data_editor);
+}
+
+
+
+static void
+on_edit_cut (GtkMenuItem *m, gpointer data)
+{
+ struct data_editor *de = data;
+
+ psppire_data_editor_clip_cut (de->data_editor);
+}