X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fui%2Fgui%2Fdata-editor.c;h=9ca7511e17d8eaf1dde47ab63b1cdd403fbf35b3;hb=5e2c79af8a242eb36e62291277805933d5ad5903;hp=63a19a63a1ce2a8c19b8e8b338885136f95bb927;hpb=22569d5574031cc9e128b7ca7d8b266a367f081b;p=pspp-builds.git
diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c
index 63a19a63..9ca7511e 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,20 +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
@@ -46,38 +61,33 @@
#include "data-editor.h"
#include "syntax-editor.h"
#include
-#include
+#include
+#include
#include "window-manager.h"
#include "psppire-data-store.h"
#include "psppire-var-store.h"
+static void on_edit_copy (GtkMenuItem *, gpointer);
+static void on_edit_cut (GtkMenuItem *, gpointer);
+static void on_edit_paste (GtkAction *a, gpointer data);
-/* Update the data_ref_entry with the reference of the active cell */
-static gint update_data_ref_entry (const GtkSheet *sheet,
- gint row, gint col, gpointer data);
-
-static void register_data_editor_actions (struct data_editor *de);
-
-static void insert_variable (GtkAction *, gpointer data);
-
-
-/* Switch between the VAR SHEET and the DATA 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);
/* Callback for when the dictionary changes properties*/
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);
@@ -86,45 +96,87 @@ 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);
+}
+
+
+
+/* Run the EXECUTE command. */
+static void
+execute (GtkMenuItem *mi, gpointer data)
+{
+ struct getl_interface *sss = create_syntax_string_source ("EXECUTE.");
- gtk_widget_set_sensitive (menuitem, TRUE);
+ 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
@@ -132,7 +184,6 @@ static void
on_recent_data_select (GtkMenuShell *menushell, gpointer user_data)
{
gchar *file;
-
struct data_editor *de = user_data;
gchar *uri =
@@ -171,23 +222,34 @@ on_recent_files_select (GtkMenuShell *menushell, gpointer user_data)
#endif
+
static void
-datum_entry_activate (GtkEntry *entry, gpointer data)
+update_paste_menuitems (GtkWidget *w, gboolean x, gpointer data)
{
- gint row, column;
- GtkSheet *data_sheet = GTK_SHEET (data);
- PsppireDataStore *store = PSPPIRE_DATA_STORE (gtk_sheet_get_model (data_sheet));
+ struct data_editor *de = data;
- const char *text = gtk_entry_get_text (entry);
+ GtkWidget * edit_paste = get_widget_assert (de->xml, "edit_paste");
+
+ gtk_widget_set_sensitive (edit_paste, x);
+}
- gtk_sheet_get_active_cell (data_sheet, &row, &column);
+static void
+update_cut_copy_menuitems (GtkWidget *w, gboolean x, gpointer data)
+{
+ struct data_editor *de = data;
- if ( row == -1 || column == -1)
- return;
+ GtkWidget * edit_copy = get_widget_assert (de->xml, "edit_copy");
+ GtkWidget * edit_cut = get_widget_assert (de->xml, "edit_cut");
- psppire_data_store_set_string (store, text, row, column);
+ 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.
*/
@@ -196,10 +258,8 @@ new_data_editor (void)
{
struct data_editor *de ;
struct editor_window *e;
- GtkSheet *var_sheet ;
- GtkSheet *data_sheet ;
PsppireVarStore *vs;
- GtkWidget *datum_entry;
+ GtkWidget *vbox ;
de = g_malloc0 (sizeof (*de));
@@ -207,22 +267,29 @@ new_data_editor (void)
de->xml = XML_NEW ("data-editor.glade");
- var_sheet = GTK_SHEET (get_widget_assert (de->xml, "variable_sheet"));
- data_sheet = GTK_SHEET (get_widget_assert (de->xml, "data_sheet"));
- vs = PSPPIRE_VAR_STORE (gtk_sheet_get_model (var_sheet));
+ vbox = get_widget_assert (de->xml, "vbox1");
+
+ 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 (G_OBJECT (data_sheet), "activate",
- G_CALLBACK (update_data_ref_entry),
- de->xml);
+ g_signal_connect (de->data_editor, "data-available-changed",
+ G_CALLBACK (update_paste_menuitems), de);
- datum_entry = get_widget_assert (de->xml, "datum_entry");
- g_signal_connect (G_OBJECT (datum_entry), "activate",
- G_CALLBACK (datum_entry_activate),
- data_sheet);
+ 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),
@@ -239,16 +306,80 @@ 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"),
+ _("Insert _Variable"),
_("Create a new variable at the current position"),
"pspp-insert-variable");
g_signal_connect (de->insert_variable, "activate",
- G_CALLBACK (insert_variable), de);
+ G_CALLBACK (on_insert_variable), de->data_editor);
gtk_action_connect_proxy (de->insert_variable,
@@ -256,12 +387,54 @@ new_data_editor (void)
);
gtk_action_connect_proxy (de->insert_variable,
- get_widget_assert (de->xml, "data_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");
@@ -271,7 +444,7 @@ new_data_editor (void)
de->invoke_transpose_dialog =
gtk_action_new ("transpose-dialog",
- _("Transpose"),
+ _("_Transpose"),
_("Transpose the cases with the variables"),
NULL);
@@ -283,7 +456,7 @@ new_data_editor (void)
de->invoke_split_file_dialog =
gtk_action_new ("split-file-dialog",
- _("Split"),
+ _("S_plit"),
_("Split the active file"),
"pspp-split-file");
@@ -294,41 +467,177 @@ new_data_editor (void)
de->invoke_sort_cases_dialog =
gtk_action_new ("sort-cases-dialog",
- _("Sort"),
+ _("_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"),
_("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"),
+ _("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"),
+ _("_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"),
@@ -341,17 +650,21 @@ 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");
@@ -390,6 +703,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),
@@ -400,13 +718,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")
+ );
+ 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")
@@ -424,10 +756,38 @@ new_data_editor (void)
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")
);
@@ -436,6 +796,27 @@ new_data_editor (void)
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),
@@ -447,32 +828,25 @@ new_data_editor (void)
G_CALLBACK (reference_manual),
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",
@@ -487,11 +861,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);
@@ -501,14 +875,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")
@@ -530,72 +896,40 @@ new_data_editor (void)
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);
- 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;
- GtkSheetRange visible_range;
-
- gint current_row, current_column;
-
- GtkWidget *data_sheet = get_widget_assert (de->xml, "data_sheet");
+ de->data_sheet_variable_popup_menu =
+ GTK_MENU (create_data_sheet_variable_popup_menu (de));
- data_editor_select_sheet (de, PAGE_DATA_SHEET);
+ de->data_sheet_cases_popup_menu =
+ GTK_MENU (create_data_sheet_cases_popup_menu (de));
- 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);
-
- gtk_sheet_get_visible_range (GTK_SHEET (data_sheet), &visible_range);
-
- if ( row < visible_range.col0 || row > visible_range.coli)
- {
- gtk_sheet_moveto (GTK_SHEET (data_sheet),
- current_row, row, 0, 0);
- }
+ g_object_set (de->data_editor,
+ "column-menu", de->data_sheet_variable_popup_menu, NULL);
- return FALSE;
-}
+ g_object_set (de->data_editor,
+ "row-menu", de->data_sheet_cases_popup_menu, NULL);
-/* 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;
-
- gint current_row, current_column;
-
- GtkWidget *var_sheet = get_widget_assert (de->xml, "variable_sheet");
-
- data_editor_select_sheet (de, PAGE_VAR_SHEET);
-
- gtk_sheet_get_active_cell (GTK_SHEET (var_sheet),
- ¤t_row, ¤t_column);
-
- gtk_sheet_set_active_cell (GTK_SHEET (var_sheet), col, current_column);
-
- return FALSE;
+ return de;
}
@@ -605,59 +939,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
}
@@ -678,33 +994,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);
}
@@ -720,75 +1031,30 @@ 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)
-{
- 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);
-
- gtk_check_menu_item_set_active (item, show_value_labels);
-
- psppire_data_store_show_labels (ds, show_value_labels);
-}
-
static void
file_quit (GtkCheckMenuItem *menuitem, gpointer data)
@@ -796,90 +1062,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 (GtkAction *action, gpointer data)
+on_insert_variable (GtkAction *action, gpointer data)
{
- struct data_editor *de = data;
- gint posn = -1;
-
- 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 ();
- }
-
- if ( posn == -1 ) posn = 0;
-
- 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)
@@ -899,7 +1102,8 @@ on_split_change (PsppireDict *dict, gpointer data)
{
gint i;
GString *text;
- const 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 "));
@@ -930,16 +1134,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);
@@ -961,16 +1164,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);
@@ -1027,6 +1229,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 */
@@ -1066,8 +1277,8 @@ save_file (struct data_editor *de)
g_assert (de->file_name);
- ds_init_cstr (&file_name, de->file_name);
- gen_quoted_string (&file_name);
+ ds_init_empty (&file_name);
+ syntax_gen_string (&file_name, ss_cstr (de->file_name));
if ( de->save_as_portable )
{
@@ -1202,20 +1413,22 @@ open_data_file (const gchar *file_name, struct data_editor *de)
struct getl_interface *sss;
struct string filename;
- ds_init_cstr (&filename, file_name);
-
- gen_quoted_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));
-
- execute_syntax (sss);
ds_destroy (&filename);
- window_set_name_from_filename ((struct editor_window *) de, file_name);
+ 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
@@ -1248,6 +1461,15 @@ 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:
@@ -1257,19 +1479,6 @@ open_data_dialog (GtkAction *action, struct data_editor *de)
gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
open_data_file (de->file_name, de);
-
-#if RECENT_LISTS_AVAILABLE
- {
- GtkRecentManager *manager = gtk_recent_manager_get_default();
- gchar *uri = g_filename_to_uri (de->file_name, NULL, 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
-
}
break;
default:
@@ -1280,55 +1489,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);
-/* Update the data_ref_entry with the reference of the active cell */
-static gint
-update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data)
+
+ 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)
{
- GladeXML *data_editor_xml = data;
+ GtkWidget *menu = gtk_menu_new ();
- PsppireDataStore *data_store = PSPPIRE_DATA_STORE (gtk_sheet_get_model (sheet));
+ GtkWidget *insert_case =
+ gtk_menu_item_new_with_label (_("Insert Case"));
- g_return_val_if_fail (data_editor_xml, FALSE);
+ GtkWidget *delete_case =
+ gtk_menu_item_new_with_label (_("Clear"));
- if (data_store)
- {
- const struct variable *var =
- psppire_dict_get_variable (data_store->dict, col);
- {
- /* The entry where the reference to the current cell is displayed */
- GtkEntry *cell_ref_entry =
- GTK_ENTRY (get_widget_assert (data_editor_xml,
- "cell_ref_entry"));
+ gtk_action_connect_proxy (de->delete_cases,
+ delete_case);
- gchar *text = g_strdup_printf ("%d: %s", row,
- var ? var_get_name (var) : "");
- gchar *s = pspp_locale_to_utf8 (text, -1, 0);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_case);
- g_free (text);
+ g_signal_connect_swapped (G_OBJECT (insert_case), "activate",
+ G_CALLBACK (gtk_action_activate),
+ de->insert_case);
- gtk_entry_set_text (cell_ref_entry, s);
- g_free (s);
- }
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu),
+ gtk_separator_menu_item_new ());
- {
- GtkEntry *datum_entry =
- GTK_ENTRY (get_widget_assert (data_editor_xml,
- "datum_entry"));
- gchar *text =
- psppire_data_store_get_string (data_store, row,
- var_get_dict_index(var));
- g_strchug (text);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_case);
- gtk_entry_set_text (datum_entry, text);
- free (text);
- }
- }
+ gtk_widget_show_all (menu);
- return FALSE;
+ 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);
}