From c7b5e2dcfaeb0221b801dc3cc9fa1ab9a4ec5861 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Tue, 30 Dec 2008 21:08:07 +0900 Subject: [PATCH] Move data-editor.c to psppire-data-window.c Made data-editor.c into a widget (derived from GtkWindow), called PsppireDataWindow. Removed window-manager.c and window-manager.h --- src/ui/gui/automake.mk | 5 +- src/ui/gui/comments-dialog.c | 7 +- src/ui/gui/compute-dialog.c | 6 +- src/ui/gui/crosstabs-dialog.c | 16 +- src/ui/gui/descriptives-dialog.c | 6 +- src/ui/gui/examine-dialog.c | 10 +- src/ui/gui/find-dialog.c | 8 +- src/ui/gui/frequencies-dialog.c | 8 +- src/ui/gui/goto-case-dialog.c | 8 +- src/ui/gui/oneway-anova-dialog.c | 8 +- .../{data-editor.c => psppire-data-window.c} | 2282 +++++++++-------- .../{data-editor.h => psppire-data-window.h} | 59 +- src/ui/gui/psppire-output-window.c | 4 +- src/ui/gui/psppire-syntax-window.c | 8 +- src/ui/gui/psppire-window.c | 2 +- src/ui/gui/psppire.c | 4 +- src/ui/gui/rank-dialog.c | 6 +- src/ui/gui/recode-dialog.c | 14 +- src/ui/gui/regression-dialog.c | 12 +- src/ui/gui/select-cases-dialog.c | 6 +- src/ui/gui/sort-cases-dialog.c | 6 +- src/ui/gui/split-file-dialog.c | 6 +- .../gui/t-test-independent-samples-dialog.c | 10 +- src/ui/gui/t-test-one-sample.c | 8 +- src/ui/gui/t-test-paired-samples.c | 8 +- src/ui/gui/text-data-import-dialog.c | 8 +- src/ui/gui/transpose-dialog.c | 6 +- src/ui/gui/variable-info-dialog.c | 6 +- src/ui/gui/weight-cases-dialog.c | 6 +- src/ui/gui/window-manager.c | 198 -- src/ui/gui/window-manager.h | 53 - 31 files changed, 1295 insertions(+), 1499 deletions(-) rename src/ui/gui/{data-editor.c => psppire-data-window.c} (88%) rename src/ui/gui/{data-editor.h => psppire-data-window.h} (66%) delete mode 100644 src/ui/gui/window-manager.c delete mode 100644 src/ui/gui/window-manager.h diff --git a/src/ui/gui/automake.mk b/src/ui/gui/automake.mk index 52bd049b..a458c0f4 100644 --- a/src/ui/gui/automake.mk +++ b/src/ui/gui/automake.mk @@ -115,8 +115,6 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/frequencies-dialog.h \ src/ui/gui/goto-case-dialog.c \ src/ui/gui/goto-case-dialog.h \ - src/ui/gui/data-editor.c \ - src/ui/gui/data-editor.h \ src/ui/gui/descriptives-dialog.c \ src/ui/gui/descriptives-dialog.h \ src/ui/gui/examine-dialog.c \ @@ -196,13 +194,14 @@ src_ui_gui_psppire_SOURCES = \ src/ui/gui/weight-cases-dialog.h \ src/ui/gui/widget-io.c \ src/ui/gui/widget-io.h \ + src/ui/gui/psppire-data-window.c \ + src/ui/gui/psppire-data-window.h \ src/ui/gui/psppire-output-window.c \ src/ui/gui/psppire-output-window.h \ src/ui/gui/psppire-window.c \ src/ui/gui/psppire-window.h \ src/ui/gui/psppire-syntax-window.c \ src/ui/gui/psppire-syntax-window.h \ - src/ui/gui/window-manager.c \ src/ui/gui/window-manager.h nodist_src_ui_gui_psppire_SOURCES = \ diff --git a/src/ui/gui/comments-dialog.c b/src/ui/gui/comments-dialog.c index 6b2e8007..9b521a76 100644 --- a/src/ui/gui/comments-dialog.c +++ b/src/ui/gui/comments-dialog.c @@ -18,7 +18,8 @@ #include "psppire-dialog.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" +#include "psppire-data-editor.h" #include #include "psppire-syntax-window.h" #include "psppire-var-store.h" @@ -95,7 +96,7 @@ comments_dialog (GObject *o, gpointer data) { GtkTextIter iter; gint response ; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct comment_dialog cd; GladeXML *xml = XML_NEW ("psppire.glade"); @@ -109,7 +110,7 @@ comments_dialog (GObject *o, gpointer data) g_object_get (de->data_editor, "var-store", &vs, NULL); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); { PangoContext * context ; diff --git a/src/ui/gui/compute-dialog.c b/src/ui/gui/compute-dialog.c index a887876f..17611ac8 100644 --- a/src/ui/gui/compute-dialog.c +++ b/src/ui/gui/compute-dialog.c @@ -20,7 +20,7 @@ #include "helper.h" #include "psppire-dialog.h" #include "psppire-keypad.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-var-store.h" #include "dialog-common.h" #include "dict-display.h" @@ -365,7 +365,7 @@ void compute_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = data; PsppireVarStore *vs = NULL; struct compute_dialog scd; @@ -394,7 +394,7 @@ compute_dialog (GObject *o, gpointer data) g_signal_connect (expression, "toggled", G_CALLBACK(on_expression_toggle), &scd); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view), diff --git a/src/ui/gui/crosstabs-dialog.c b/src/ui/gui/crosstabs-dialog.c index 3c3bd9f4..dfe03e3c 100644 --- a/src/ui/gui/crosstabs-dialog.c +++ b/src/ui/gui/crosstabs-dialog.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -385,13 +385,15 @@ void crosstabs_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; - struct crosstabs_dialog cd; GladeXML *xml = XML_NEW ("crosstabs.glade"); + PsppireVarStore *vs = NULL; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + + GtkWidget *dialog = get_widget_assert (xml, "crosstabs-dialog"); GtkWidget *source = get_widget_assert (xml, "dict-treeview"); GtkWidget *dest_rows = get_widget_assert (xml, "rows"); @@ -419,7 +421,7 @@ crosstabs_dialog (GObject *o, gpointer data) cells ); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (source), vs->dict, @@ -461,9 +463,9 @@ crosstabs_dialog (GObject *o, gpointer data) cd.current_opts.table = TRUE; cd.current_opts.pivot = TRUE; - gtk_window_set_transient_for (GTK_WINDOW (cd.format_dialog), de->parent.window); - gtk_window_set_transient_for (GTK_WINDOW (cd.cell_dialog), de->parent.window); - gtk_window_set_transient_for (GTK_WINDOW (cd.stat_dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (cd.format_dialog), GTK_WINDOW (de)); + gtk_window_set_transient_for (GTK_WINDOW (cd.cell_dialog), GTK_WINDOW (de)); + gtk_window_set_transient_for (GTK_WINDOW (cd.stat_dialog), GTK_WINDOW (de)); g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &cd); diff --git a/src/ui/gui/descriptives-dialog.c b/src/ui/gui/descriptives-dialog.c index 93746221..f909ed02 100644 --- a/src/ui/gui/descriptives-dialog.c +++ b/src/ui/gui/descriptives-dialog.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -202,7 +202,7 @@ void descriptives_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct descriptives_dialog scd; @@ -221,7 +221,7 @@ descriptives_dialog (GObject *o, gpointer data) g_object_get (de->data_editor, "var-store", &vs, NULL); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (source), vs->dict, diff --git a/src/ui/gui/examine-dialog.c b/src/ui/gui/examine-dialog.c index 5f6a9bb8..33f8b129 100644 --- a/src/ui/gui/examine-dialog.c +++ b/src/ui/gui/examine-dialog.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -236,7 +236,7 @@ void examine_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct examine_dialog ex_d; @@ -277,9 +277,9 @@ examine_dialog (GObject *o, gpointer data) ex_d.percentiles_button = GTK_TOGGLE_BUTTON (get_widget_assert (xml, "percentiles-button")); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); - gtk_window_set_transient_for (GTK_WINDOW (ex_d.stats_dialog), de->parent.window); - gtk_window_set_transient_for (GTK_WINDOW (ex_d.opts_dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); + gtk_window_set_transient_for (GTK_WINDOW (ex_d.stats_dialog), GTK_WINDOW (de)); + gtk_window_set_transient_for (GTK_WINDOW (ex_d.opts_dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (source), vs->dict, diff --git a/src/ui/gui/find-dialog.c b/src/ui/gui/find-dialog.c index 332e2d8e..ad9bf842 100644 --- a/src/ui/gui/find-dialog.c +++ b/src/ui/gui/find-dialog.c @@ -24,7 +24,7 @@ which match particular strings */ #include "psppire-selector.h" #include "psppire-dialog.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "dict-display.h" #include #include @@ -55,7 +55,7 @@ struct find_dialog GladeXML *xml; PsppireDict *dict; struct datasheet *data; - struct data_editor *de; + PsppireDataWindow *de; GtkWidget *variable_entry; GtkWidget *value_entry; GtkWidget *value_labels_checkbox; @@ -186,7 +186,7 @@ value_labels_toggled (GtkToggleButton *tb, gpointer data) void find_dialog (GObject *o, gpointer data) { - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct find_dialog fd; @@ -239,7 +239,7 @@ find_dialog (GObject *o, gpointer data) - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (source), diff --git a/src/ui/gui/frequencies-dialog.c b/src/ui/gui/frequencies-dialog.c index 9d1215c4..cba8573d 100644 --- a/src/ui/gui/frequencies-dialog.c +++ b/src/ui/gui/frequencies-dialog.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -307,7 +307,7 @@ void frequencies_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct frequencies_dialog fd; @@ -331,7 +331,7 @@ frequencies_dialog (GObject *o, gpointer data) ); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (source), vs->dict, @@ -369,7 +369,7 @@ frequencies_dialog (GObject *o, gpointer data) fd.current_opts.limit = 50; - gtk_window_set_transient_for (GTK_WINDOW (fd.format_dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (fd.format_dialog), GTK_WINDOW (de)); g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &fd); diff --git a/src/ui/gui/goto-case-dialog.c b/src/ui/gui/goto-case-dialog.c index 86e80c5d..57db5865 100644 --- a/src/ui/gui/goto-case-dialog.c +++ b/src/ui/gui/goto-case-dialog.c @@ -19,12 +19,12 @@ #include "goto-case-dialog.h" #include "helper.h" #include "psppire-dialog.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-data-store.h" static void -refresh (const struct data_editor *de, GladeXML *xml) +refresh (const PsppireDataWindow *de, GladeXML *xml) { PsppireDataStore *ds = NULL; casenumber case_count ; @@ -44,12 +44,12 @@ goto_case_dialog (GObject *o, gpointer data) { gint response; GladeXML *xml = XML_NEW ("psppire.glade"); - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); GtkWidget *dialog = get_widget_assert (xml, "goto-case-dialog"); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); refresh (de, xml); diff --git a/src/ui/gui/oneway-anova-dialog.c b/src/ui/gui/oneway-anova-dialog.c index 4db1e5ff..505d9039 100644 --- a/src/ui/gui/oneway-anova-dialog.c +++ b/src/ui/gui/oneway-anova-dialog.c @@ -23,7 +23,7 @@ #include "psppire-dict.h" #include "psppire-var-store.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-dialog.h" #include "dialog-common.h" #include "dict-display.h" @@ -126,7 +126,7 @@ void oneway_anova_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); PsppireVarStore *vs = NULL; @@ -168,7 +168,7 @@ oneway_anova_dialog (GObject *o, gpointer data) ow.dialog = GTK_WINDOW (get_widget_assert (xml, "oneway-anova-dialog")); - gtk_window_set_transient_for (ow.dialog, de->parent.window); + gtk_window_set_transient_for (ow.dialog, GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view), vs->dict, @@ -222,7 +222,7 @@ oneway_anova_dialog (GObject *o, gpointer data) psppire_acr_set_entry (cd->acr, entry); gtk_window_set_transient_for (GTK_WINDOW (cd->contrasts_dialog), - de->parent.window); + GTK_WINDOW (de)); } response = psppire_dialog_run (PSPPIRE_DIALOG (ow.dialog)); diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/psppire-data-window.c similarity index 88% rename from src/ui/gui/data-editor.c rename to src/ui/gui/psppire-data-window.c index f540592d..5facbbd2 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/psppire-data-window.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2006, 2007, 2008 Free Software Foundation + Copyright (C) 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 @@ -15,28 +15,34 @@ along with this program. If not, see . */ #include -#include -#include +#include +#include #include -#include +#include "helper.h" -#include "window-manager.h" +#include "text-data-import-dialog.h" -#include "psppire-data-editor.h" -#include "helper.h" -#include "about.h" +#include +#include +#include +#include + #include -#include "psppire-dialog.h" -#include "psppire-selector.h" + +#include "psppire-data-window.h" +#include "psppire-syntax-window.h" + +#include "about.h" + +#include "goto-case-dialog.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" @@ -48,85 +54,122 @@ #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" + +#include #define _(msgid) gettext (msgid) #define N_(msgid) msgid -#include "data-editor.h" -#include "psppire-syntax-window.h" -#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); +static void psppire_data_window_base_finalize (PsppireDataWindowClass *, gpointer); +static void psppire_data_window_base_init (PsppireDataWindowClass *class); +static void psppire_data_window_class_init (PsppireDataWindowClass *class); +static void psppire_data_window_init (PsppireDataWindow *data_editor); -static GtkWidget * create_data_sheet_variable_popup_menu (struct data_editor *); -static GtkWidget * create_var_sheet_variable_popup_menu (struct data_editor *); +GType +psppire_data_window_get_type (void) +{ + static GType psppire_data_window_type = 0; -static GtkWidget * create_data_sheet_cases_popup_menu (struct data_editor *); + if (!psppire_data_window_type) + { + static const GTypeInfo psppire_data_window_info = + { + sizeof (PsppireDataWindowClass), + (GBaseInitFunc) psppire_data_window_base_init, + (GBaseFinalizeFunc) psppire_data_window_base_finalize, + (GClassInitFunc)psppire_data_window_class_init, + (GClassFinalizeFunc) NULL, + NULL, + sizeof (PsppireDataWindow), + 0, + (GInstanceInitFunc) psppire_data_window_init, + }; + + psppire_data_window_type = + g_type_register_static (PSPPIRE_WINDOW_TYPE, "PsppireDataWindow", + &psppire_data_window_info, 0); + } -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); + return psppire_data_window_type; +} -static void toggle_value_labels (GtkToggleAction *a, gpointer data); -static void toggle_split_window (GtkToggleAction *ta, gpointer data); +static void +psppire_data_window_finalize (GObject *object) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (object); -/* 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); + GObjectClass *class = G_OBJECT_GET_CLASS (object); -static void on_switch_sheet (GtkNotebook *notebook, - GtkNotebookPage *page, - guint page_num, - gpointer user_data); + GObjectClass *parent_class = g_type_class_peek_parent (class); -static void status_bar_activate (GtkCheckMenuItem *, gpointer); + g_object_unref (de->xml); -static void grid_lines_activate (GtkCheckMenuItem *, gpointer); -static void data_view_activate (GtkCheckMenuItem *, gpointer); + if (G_OBJECT_CLASS (parent_class)->finalize) + (*G_OBJECT_CLASS (parent_class)->finalize) (object); +} -static void variable_view_activate (GtkCheckMenuItem *, gpointer ); -static void fonts_activate (GtkMenuItem *, gpointer); +static void +psppire_data_window_class_init (PsppireDataWindowClass *class) +{ +} -static void file_quit (GtkCheckMenuItem *, gpointer ); static void -enable_delete_cases (GtkWidget *w, gint case_num, gpointer data) +psppire_data_window_base_init (PsppireDataWindowClass *class) { - struct data_editor *de = data; + GObjectClass *object_class = G_OBJECT_CLASS (class); - gtk_action_set_visible (de->delete_cases, case_num != -1); + object_class->finalize = psppire_data_window_finalize; } + static void -enable_delete_variables (GtkWidget *w, gint var, gpointer data) +psppire_data_window_base_finalize (PsppireDataWindowClass *class, + gpointer class_data) { - struct data_editor *de = data; +} - gtk_action_set_visible (de->delete_variables, var != -1); + + + + +extern PsppireVarStore *the_var_store; +extern struct dataset *the_dataset; +extern PsppireDataStore *the_data_store ; + + +static void +update_paste_menuitems (GtkWidget *w, gboolean x, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (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) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (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); +} /* Run the EXECUTE command. */ static void @@ -141,7 +184,8 @@ static void transformation_change_callback (bool transformations_pending, gpointer data) { - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + GtkWidget *menuitem = get_widget_assert (de->xml, "transform_run-pending"); GtkWidget *status_label = @@ -157,807 +201,768 @@ transformation_change_callback (bool transformations_pending, 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 -*/ +/* Callback for when the dictionary changes its filter variable */ static void -add_most_recent (const char *file_name) +on_filter_change (GObject *o, gint filter_index, gpointer data) { -#if RECENT_LISTS_AVAILABLE + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - GtkRecentManager *manager = gtk_recent_manager_get_default(); - gchar *uri = g_filename_to_uri (file_name, NULL, NULL); + GtkWidget *filter_status_area = + get_widget_assert (de->xml, "filter-use-status-area"); - gtk_recent_manager_remove_item (manager, uri, NULL); + if ( filter_index == -1 ) + { + gtk_label_set_text (GTK_LABEL (filter_status_area), _("Filter off")); + } + else + { + PsppireVarStore *vs = NULL; + struct variable *var ; + gchar *text ; - if ( ! gtk_recent_manager_add_item (manager, uri)) - g_warning ("Could not add item %s to recent list\n",uri); + g_object_get (de->data_editor, "var-store", &vs, NULL); - g_free (uri); -#endif -} + var = psppire_dict_get_variable (vs->dict, filter_index); + text = g_strdup_printf (_("Filter by %s"), var_get_name (var)); + gtk_label_set_text (GTK_LABEL (filter_status_area), text); -#if RECENT_LISTS_AVAILABLE + g_free (text); + } +} +/* Callback for when the dictionary changes its split variables */ static void -on_recent_data_select (GtkMenuShell *menushell, gpointer user_data) +on_split_change (PsppireDict *dict, gpointer data) { - gchar *file; - struct data_editor *de = user_data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - gchar *uri = - gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell)); + size_t n_split_vars = dict_get_split_cnt (dict->dict); - file = g_filename_from_uri (uri, NULL, NULL); + GtkWidget *split_status_area = + get_widget_assert (de->xml, "split-file-status-area"); - g_free (uri); + if ( n_split_vars == 0 ) + { + gtk_label_set_text (GTK_LABEL (split_status_area), _("No Split")); + } + else + { + gint i; + GString *text; + const struct variable *const * split_vars = + dict_get_split_vars (dict->dict); - open_data_file (file, de); + text = g_string_new (_("Split by ")); - g_free (file); -} + for (i = 0 ; i < n_split_vars - 1; ++i ) + { + g_string_append_printf (text, "%s, ", var_get_name (split_vars[i])); + } + g_string_append (text, var_get_name (split_vars[i])); -static void -on_recent_files_select (GtkMenuShell *menushell, gpointer user_data) -{ - gchar *file; + gtk_label_set_text (GTK_LABEL (split_status_area), text->str); - GtkWidget *se ; + g_string_free (text, TRUE); + } +} - gchar *uri = - gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell)); - file = g_filename_from_uri (uri, NULL, NULL); - g_free (uri); - se = psppire_syntax_window_new (); +/* Callback for when the dictionary changes its weights */ +static void +on_weight_change (GObject *o, gint weight_index, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - psppire_syntax_window_load_from_file (PSPPIRE_SYNTAX_WINDOW (se), file, NULL); - gtk_widget_show (se); + GtkWidget *weight_status_area = + get_widget_assert (de->xml, "weight-status-area"); - g_free (file); -} + if ( weight_index == -1 ) + { + gtk_label_set_text (GTK_LABEL (weight_status_area), _("Weights off")); + } + else + { + struct variable *var ; + PsppireVarStore *vs = NULL; + gchar *text; -#endif + g_object_get (de->data_editor, "var-store", &vs, NULL); + var = psppire_dict_get_variable (vs->dict, weight_index); -static void -update_paste_menuitems (GtkWidget *w, gboolean x, gpointer data) -{ - struct data_editor *de = data; + text = g_strdup_printf (_("Weight by %s"), var_get_name (var)); - GtkWidget * edit_paste = get_widget_assert (de->xml, "edit_paste"); + gtk_label_set_text (GTK_LABEL (weight_status_area), text); - gtk_widget_set_sensitive (edit_paste, x); + g_free (text); + } } +/* Puts FILE_NAME into the recent list. + If it's already in the list, it moves it to the top +*/ static void -update_cut_copy_menuitems (GtkWidget *w, gboolean x, gpointer data) +add_most_recent (const char *file_name) { - struct data_editor *de = data; +#if RECENT_LISTS_AVAILABLE - GtkWidget * edit_copy = get_widget_assert (de->xml, "edit_copy"); - GtkWidget * edit_cut = get_widget_assert (de->xml, "edit_cut"); + GtkRecentManager *manager = gtk_recent_manager_get_default(); + gchar *uri = g_filename_to_uri (file_name, NULL, NULL); - gtk_widget_set_sensitive (edit_copy, x); - gtk_widget_set_sensitive (edit_cut, x); -} + gtk_recent_manager_remove_item (manager, uri, NULL); -extern PsppireVarStore *the_var_store; -extern struct dataset *the_dataset; -extern PsppireDataStore *the_data_store ; + if ( ! gtk_recent_manager_add_item (manager, uri)) + g_warning ("Could not add item %s to recent list\n",uri); + g_free (uri); +#endif +} -/* - Create a new data editor. -*/ -struct data_editor * -new_data_editor (void) +static void +open_data_file (const gchar *file_name, PsppireDataWindow *de) { - struct data_editor *de ; - struct editor_window *e; - PsppireVarStore *vs; - GtkWidget *vbox ; - - de = g_malloc0 (sizeof (*de)); + struct getl_interface *sss; + struct string filename; - e = (struct editor_window *) de; + ds_init_empty (&filename); + syntax_gen_string (&filename, ss_cstr (file_name)); - de->xml = XML_NEW ("data-editor.glade"); + 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); + } +} - vbox = get_widget_assert (de->xml, "vbox1"); - de->data_editor = PSPPIRE_DATA_EDITOR (psppire_data_editor_new (the_var_store, the_data_store)); +/* Callback for the data_open action. + Prompts for a filename and opens it */ +static void +open_data_dialog (GtkAction *action, PsppireDataWindow *de) +{ + GtkWidget *dialog = + gtk_file_chooser_dialog_new (_("Open"), + GTK_WINDOW (de), + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); - g_signal_connect (de->data_editor, "data-selection-changed", - G_CALLBACK (update_cut_copy_menuitems), de); + GtkFileFilter *filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("System Files (*.sav)")); + gtk_file_filter_add_pattern (filter, "*.sav"); + gtk_file_filter_add_pattern (filter, "*.SAV"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - g_signal_connect (de->data_editor, "data-available-changed", - G_CALLBACK (update_paste_menuitems), de); + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Portable Files (*.por) ")); + gtk_file_filter_add_pattern (filter, "*.por"); + gtk_file_filter_add_pattern (filter, "*.POR"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("All Files")); + gtk_file_filter_add_pattern (filter, "*"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - gtk_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); + 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); + } - vs = the_var_store; + switch (gtk_dialog_run (GTK_DIALOG (dialog))) + { + case GTK_RESPONSE_ACCEPT: + { + g_free (de->file_name); + de->file_name = + gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - g_assert(vs); /* Traps a possible bug in w32 build */ + open_data_file (de->file_name, de); + } + break; + default: + break; + } - g_signal_connect (vs->dict, "weight-changed", - G_CALLBACK (on_weight_change), - de); + gtk_widget_destroy (dialog); +} - g_signal_connect (vs->dict, "filter-changed", - G_CALLBACK (on_filter_change), - de); +/* Returns true if NAME has a suffix which might denote a PSPP file */ +static gboolean +name_has_suffix (const gchar *name) +{ + if ( g_str_has_suffix (name, ".sav")) + return TRUE; + if ( g_str_has_suffix (name, ".SAV")) + return TRUE; + if ( g_str_has_suffix (name, ".por")) + return TRUE; + if ( g_str_has_suffix (name, ".POR")) + return TRUE; - g_signal_connect (vs->dict, "split-changed", - G_CALLBACK (on_split_change), - de); + return FALSE; +} - connect_help (de->xml); +/* Append SUFFIX to the filename of DE */ +static void +append_filename_suffix (PsppireDataWindow *de, const gchar *suffix) +{ + if ( ! name_has_suffix (de->file_name)) + { + gchar *s = de->file_name; + de->file_name = g_strconcat (de->file_name, suffix, NULL); + g_free (s); + } +} +/* Save DE to file */ +static void +save_file (PsppireDataWindow *de) +{ + struct getl_interface *sss; + struct string file_name ; - g_signal_connect (get_widget_assert (de->xml, "edit_copy"), - "activate", - G_CALLBACK (on_edit_copy), de); + g_assert (de->file_name); - g_signal_connect (get_widget_assert (de->xml, "edit_cut"), - "activate", - G_CALLBACK (on_edit_cut), de); + 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.", + ds_cstr (&file_name)); + } + else + { + append_filename_suffix (de, ".sav"); + sss = create_syntax_string_source ("SAVE OUTFILE=%s.", + ds_cstr (&file_name)); + } - register_data_editor_actions (de); + ds_destroy (&file_name); - de->toggle_value_labels = - gtk_toggle_action_new ("toggle-value-labels", - _("_Labels"), - _("Show/hide value labels"), - "pspp-value-labels"); + execute_syntax (sss); +} - g_signal_connect (de->toggle_value_labels, "toggled", - G_CALLBACK (toggle_value_labels), de); +static void +insert_case (GtkAction *action, gpointer data) +{ + PsppireDataWindow *dw = PSPPIRE_DATA_WINDOW (data); - gtk_action_connect_proxy (GTK_ACTION (de->toggle_value_labels), - get_widget_assert (de->xml, - "togglebutton-value-labels")); + psppire_data_editor_insert_case (dw->data_editor); +} +static void +on_insert_variable (GtkAction *action, gpointer data) +{ + PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data); + psppire_data_editor_insert_variable (de); +} - 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"); +/* Callback for data_save_as action. Prompt for a filename and save */ +static void +data_save_as_dialog (GtkAction *action, PsppireDataWindow *de) +{ + GtkWidget *button_sys; + GtkWidget *dialog = + gtk_file_chooser_dialog_new (_("Save"), + GTK_WINDOW (de), + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, + NULL); - g_signal_connect_swapped (de->delete_cases, "activate", - G_CALLBACK (psppire_data_editor_delete_cases), - de->data_editor); + GtkFileFilter *filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("System Files (*.sav)")); + gtk_file_filter_add_pattern (filter, "*.sav"); + gtk_file_filter_add_pattern (filter, "*.SAV"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - gtk_action_connect_proxy (de->delete_cases, - get_widget_assert (de->xml, "edit_clear-cases")); + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("Portable Files (*.por) ")); + gtk_file_filter_add_pattern (filter, "*.por"); + gtk_file_filter_add_pattern (filter, "*.POR"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - g_signal_connect (get_widget_assert (de->xml, "edit_paste"), "activate", - G_CALLBACK (on_edit_paste), - de); + filter = gtk_file_filter_new (); + gtk_file_filter_set_name (filter, _("All Files")); + gtk_file_filter_add_pattern (filter, "*"); + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - gtk_action_set_visible (de->delete_cases, FALSE); + { + GtkWidget *button_por; + GtkWidget *vbox = gtk_vbox_new (TRUE, 5); + button_sys = + gtk_radio_button_new_with_label (NULL, _("System File")); - de->delete_variables = - gtk_action_new ("clear-variables", - _("Clear"), - _("Delete the variables at the selected position(s)"), - "pspp-clear-variables"); + button_por = + gtk_radio_button_new_with_label + (gtk_radio_button_get_group (GTK_RADIO_BUTTON(button_sys)), + _("Portable File")); - g_signal_connect_swapped (de->delete_variables, "activate", - G_CALLBACK (psppire_data_editor_delete_variables), - de->data_editor); + gtk_box_pack_start_defaults (GTK_BOX (vbox), button_sys); + gtk_box_pack_start_defaults (GTK_BOX (vbox), button_por); - gtk_action_connect_proxy (de->delete_variables, - get_widget_assert (de->xml, "edit_clear-variables") - ); + gtk_widget_show_all (vbox); - gtk_action_set_visible (de->delete_variables, FALSE); + gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(dialog), vbox); + } - de->insert_variable = - gtk_action_new ("insert-variable", - _("Insert _Variable"), - _("Create a new variable at the current position"), - "pspp-insert-variable"); + switch (gtk_dialog_run (GTK_DIALOG (dialog))) + { + case GTK_RESPONSE_ACCEPT: + { + g_free (de->file_name); - g_signal_connect (de->insert_variable, "activate", - G_CALLBACK (on_insert_variable), de->data_editor); + de->file_name = + gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + de->save_as_portable = + ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_sys)); - gtk_action_connect_proxy (de->insert_variable, - get_widget_assert (de->xml, "button-insert-variable") - ); + if ( de->save_as_portable) + append_filename_suffix (de, ".por"); + else + append_filename_suffix (de, ".sav"); - gtk_action_connect_proxy (de->insert_variable, - get_widget_assert (de->xml, "edit_insert-variable") - ); + save_file (de); + // window_set_name_from_filename (e, de->file_name); + } + break; + default: + break; + } - de->insert_case = - gtk_action_new ("insert-case", - _("Insert Ca_se"), - _("Create a new case at the current position"), - "pspp-insert-case"); + gtk_widget_destroy (dialog); +} - g_signal_connect (de->insert_case, "activate", - G_CALLBACK (insert_case), de); +/* Callback for data_save action. + If there's an existing file name, then just save, + otherwise prompt for a file name, then save */ +static void +data_save (GtkAction *action, PsppireDataWindow *de) +{ + if ( de->file_name) + save_file (de); + else + data_save_as_dialog (action, de); +} - gtk_action_connect_proxy (de->insert_case, - get_widget_assert (de->xml, "button-insert-case") - ); +/* Callback for data_new action. + Performs the NEW FILE command */ +static void +new_file (GtkAction *action, PsppireDataWindow *de) +{ + struct getl_interface *sss = + create_syntax_string_source ("NEW FILE."); - gtk_action_connect_proxy (de->insert_case, - get_widget_assert (de->xml, "edit_insert-case") - ); + execute_syntax (sss); + g_free (de->file_name); + de->file_name = NULL; + // default_window_name (de); +} - 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") - ); +/* Create the GtkActions and connect to their signals */ +static void +register_data_editor_actions (PsppireDataWindow *de) +{ + de->action_data_open = + gtk_action_new ("data-open-dialog", + _("Open"), + _("Open a data file"), + "gtk-open"); - gtk_action_connect_proxy (de->invoke_goto_dialog, - get_widget_assert (de->xml, "edit_goto-case") - ); + g_signal_connect (de->action_data_open, "activate", + G_CALLBACK (open_data_dialog), de); - g_signal_connect (de->invoke_goto_dialog, "activate", - G_CALLBACK (goto_case_dialog), de); + de->action_data_save = gtk_action_new ("data-save", + _("Save"), + _("Save data to file"), + "gtk-save"); + g_signal_connect (de->action_data_save, "activate", + G_CALLBACK (data_save), de); - de->invoke_weight_cases_dialog = - gtk_action_new ("weight-cases-dialog", - _("_Weights"), - _("Weight cases by variable"), - "pspp-weight-cases"); - g_signal_connect (de->invoke_weight_cases_dialog, "activate", - G_CALLBACK (weight_cases_dialog), de); + de->action_data_save_as = gtk_action_new ("data-save-as-dialog", + _("Save As"), + _("Save data to file"), + "gtk-save"); + g_signal_connect (de->action_data_save_as, "activate", + G_CALLBACK (data_save_as_dialog), de); - de->invoke_transpose_dialog = - gtk_action_new ("transpose-dialog", - _("_Transpose"), - _("Transpose the cases with the variables"), + de->action_data_new = + gtk_action_new ("data-new", + _("New"), + _("New data file"), NULL); + g_signal_connect (de->action_data_new, "activate", + G_CALLBACK (new_file), de); - g_signal_connect (de->invoke_transpose_dialog, "activate", - G_CALLBACK (transpose_dialog), 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); +} +static void +on_edit_paste (GtkAction *a, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - de->invoke_split_file_dialog = - gtk_action_new ("split-file-dialog", - _("S_plit"), - _("Split the active file"), - "pspp-split-file"); + psppire_data_editor_clip_paste (de->data_editor); +} - g_signal_connect (de->invoke_split_file_dialog, "activate", - G_CALLBACK (split_file_dialog), de); +static void +on_edit_copy (GtkMenuItem *m, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + psppire_data_editor_clip_copy (de->data_editor); +} - 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); +static void +on_edit_cut (GtkMenuItem *m, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - de->invoke_select_cases_dialog = - gtk_action_new ("select-cases-dialog", - _("Select _Cases"), - _("Select cases from the active file"), - "pspp-select-cases"); + psppire_data_editor_clip_cut (de->data_editor); +} - g_signal_connect (de->invoke_select_cases_dialog, "activate", - G_CALLBACK (select_cases_dialog), de); +static void +status_bar_activate (GtkCheckMenuItem *menuitem, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + GtkWidget *statusbar = get_widget_assert (de->xml, "status-bar"); - de->invoke_compute_dialog = - gtk_action_new ("compute-dialog", - _("_Compute"), - _("Compute new values for a variable"), - "pspp-compute"); + if ( gtk_check_menu_item_get_active (menuitem) ) + gtk_widget_show (statusbar); + else + gtk_widget_hide (statusbar); +} - 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); +static void +grid_lines_activate (GtkCheckMenuItem *menuitem, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + const gboolean grid_visible = gtk_check_menu_item_get_active (menuitem); - g_signal_connect (de->invoke_oneway_anova_dialog, "activate", - G_CALLBACK (oneway_anova_dialog), de); + psppire_data_editor_show_grid (de->data_editor, grid_visible); +} - 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); +static void +data_view_activate (GtkCheckMenuItem *menuitem, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - 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); + gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW); +} - g_signal_connect (de->invoke_t_test_paired_samples_dialog, "activate", - G_CALLBACK (t_test_paired_samples_dialog), de); +static void +variable_view_activate (GtkCheckMenuItem *menuitem, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - 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); + gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW); +} - g_signal_connect (de->invoke_t_test_one_sample_dialog, "activate", - G_CALLBACK (t_test_one_sample_dialog), de); +static void +fonts_activate (GtkMenuItem *menuitem, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + PangoFontDescription *current_font; + gchar *font_name; + GtkWidget *dialog = + gtk_font_selection_dialog_new (_("Font Selection")); - 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); + current_font = GTK_WIDGET(de->data_editor)->style->font_desc; + font_name = pango_font_description_to_string (current_font); - de->invoke_find_dialog = - gtk_action_new ("find-dialog", - _("_Find"), - _("Find Case"), - "gtk-find"); + gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (dialog), font_name); - g_signal_connect (de->invoke_find_dialog, "activate", - G_CALLBACK (find_dialog), de); + g_free (font_name); + gtk_window_set_transient_for (GTK_WINDOW (dialog), + GTK_WINDOW (get_widget_assert (de->xml, + "data_editor"))); + if ( GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (dialog)) ) + { + const gchar *font = gtk_font_selection_dialog_get_font_name + (GTK_FONT_SELECTION_DIALOG (dialog)); - de->invoke_rank_dialog = - gtk_action_new ("rank-dialog", - _("Ran_k Cases"), - _("Rank Cases"), - "pspp-rank-cases"); + PangoFontDescription* font_desc = + pango_font_description_from_string (font); - g_signal_connect (de->invoke_rank_dialog, "activate", - G_CALLBACK (rank_dialog), de); + psppire_data_editor_set_font (de->data_editor, font_desc); + } + gtk_widget_hide (dialog); +} - 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); +/* Callback for the value labels action */ +static void +toggle_value_labels (GtkToggleAction *ta, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - de->invoke_recode_different_dialog = - gtk_action_new ("recode-different-dialog", - _("Recode into _Different Variables"), - _("Recode values into different Variables"), - "pspp-recode-different"); + g_object_set (de->data_editor, "value-labels", gtk_toggle_action_get_active (ta), NULL); +} - g_signal_connect (de->invoke_recode_different_dialog, "activate", - G_CALLBACK (recode_different_dialog), de); +static void +toggle_split_window (GtkToggleAction *ta, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + psppire_data_editor_split_window (de->data_editor, + gtk_toggle_action_get_active (ta)); +} - 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); +static void +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 (); +} - 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); +static GtkWidget * +create_data_sheet_variable_popup_menu (PsppireDataWindow *de) +{ + GtkWidget *menu = gtk_menu_new (); - de->invoke_frequencies_dialog = - gtk_action_new ("frequencies-dialog", - _("_Frequencies"), - _("Generate frequency statistics"), - "pspp-frequencies"); + GtkWidget *sort_ascending = + gtk_menu_item_new_with_label (_("Sort Ascending")); - g_signal_connect (de->invoke_frequencies_dialog, "activate", - G_CALLBACK (frequencies_dialog), de); + GtkWidget *sort_descending = + gtk_menu_item_new_with_label (_("Sort Descending")); - de->invoke_crosstabs_dialog = - gtk_action_new ("crosstabs-dialog", - _("_Crosstabs"), - _("Generate crosstabulations"), - "pspp-crosstabs"); + GtkWidget *insert_variable = + gtk_menu_item_new_with_label (_("Insert Variable")); - g_signal_connect (de->invoke_crosstabs_dialog, "activate", - G_CALLBACK (crosstabs_dialog), de); + GtkWidget *clear_variable = + gtk_menu_item_new_with_label (_("Clear")); - de->invoke_examine_dialog = - gtk_action_new ("examine-dialog", - _("_Explore"), - _("Examine Data by Factors"), - "pspp-examine"); + gtk_action_connect_proxy (de->delete_variables, + clear_variable ); - g_signal_connect (de->invoke_examine_dialog, "activate", - G_CALLBACK (examine_dialog), de); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable); - 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); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + gtk_separator_menu_item_new ()); - e->window = GTK_WINDOW (get_widget_assert (de->xml, "data_editor")); - g_signal_connect_swapped (get_widget_assert (de->xml,"file_new_data"), - "activate", - G_CALLBACK (gtk_action_activate), - de->action_data_new); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), clear_variable); - g_signal_connect_swapped (get_widget_assert (de->xml,"file_open_data"), - "activate", - 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"); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + gtk_separator_menu_item_new ()); - GtkWidget *menu = gtk_recent_chooser_menu_new_for_manager (rm); - GtkRecentFilter *filter = gtk_recent_filter_new (); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_ascending); - 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"); + g_signal_connect_swapped (G_OBJECT (sort_ascending), "activate", + G_CALLBACK (psppire_data_editor_sort_ascending), + de->data_editor); - gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter); + g_signal_connect_swapped (G_OBJECT (sort_descending), "activate", + G_CALLBACK (psppire_data_editor_sort_descending), + de->data_editor); - gtk_widget_set_sensitive (recent_data, TRUE); - g_signal_connect (menu, "selection-done", - G_CALLBACK (on_recent_data_select), de); + g_signal_connect_swapped (G_OBJECT (insert_variable), "activate", + G_CALLBACK (gtk_action_activate), + de->insert_variable); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (recent_data), menu); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_descending); - filter = gtk_recent_filter_new (); - menu = gtk_recent_chooser_menu_new_for_manager (rm); + gtk_widget_show_all (menu); - gtk_recent_filter_add_pattern (filter, "*.sps"); - gtk_recent_filter_add_pattern (filter, "*.SPS"); + return menu; +} - 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); +static GtkWidget * +create_data_sheet_cases_popup_menu (PsppireDataWindow *de) +{ + GtkWidget *menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (recent_files), menu); - } -#endif + GtkWidget *insert_case = + gtk_menu_item_new_with_label (_("Insert Case")); - g_signal_connect (get_widget_assert (de->xml,"file_new_syntax"), - "activate", - G_CALLBACK (create_syntax_window), - NULL); + GtkWidget *delete_case = + gtk_menu_item_new_with_label (_("Clear")); - g_signal_connect (get_widget_assert (de->xml,"file_open_syntax"), - "activate", - 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); + gtk_action_connect_proxy (de->delete_cases, + delete_case); - g_signal_connect_swapped (get_widget_assert (de->xml,"file_save"), - "activate", - G_CALLBACK (gtk_action_activate), - de->action_data_save); - g_signal_connect_swapped (get_widget_assert (de->xml,"file_save_as"), - "activate", + 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->action_data_save_as); + de->insert_case); - gtk_action_connect_proxy (de->invoke_find_dialog, - get_widget_assert (de->xml, "edit_find") - ); - gtk_action_connect_proxy (de->invoke_find_dialog, - get_widget_assert (de->xml, "button-find") - ); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + gtk_separator_menu_item_new ()); - 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_menu_shell_append (GTK_MENU_SHELL (menu), delete_case); - 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") - ); + gtk_widget_show_all (menu); - gtk_action_connect_proxy (de->invoke_transpose_dialog, - get_widget_assert (de->xml, "data_transpose") - ); + return menu; +} - 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") - ); +static GtkWidget * +create_var_sheet_variable_popup_menu (PsppireDataWindow *de) +{ + GtkWidget *menu = gtk_menu_new (); - gtk_action_connect_proxy (de->invoke_select_cases_dialog, - get_widget_assert (de->xml, "data_select-cases") - ); + GtkWidget *insert_variable = + gtk_menu_item_new_with_label (_("Insert Variable")); - gtk_action_connect_proxy (de->invoke_compute_dialog, - get_widget_assert (de->xml, "transform_compute") - ); + GtkWidget *delete_variable = + gtk_menu_item_new_with_label (_("Clear")); - gtk_action_connect_proxy (de->invoke_t_test_independent_samples_dialog, - get_widget_assert (de->xml, - "indep-t-test") - ); + gtk_action_connect_proxy (de->delete_variables, + delete_variable); - gtk_action_connect_proxy (de->invoke_t_test_paired_samples_dialog, - get_widget_assert (de->xml, - "paired-t-test") - ); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable); - gtk_action_connect_proxy (de->invoke_t_test_one_sample_dialog, - get_widget_assert (de->xml, - "one-sample-t-test") - ); + g_signal_connect_swapped (G_OBJECT (insert_variable), "activate", + G_CALLBACK (gtk_action_activate), + de->insert_variable); - gtk_action_connect_proxy (de->invoke_oneway_anova_dialog, - get_widget_assert (de->xml, - "oneway-anova") - ); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), + gtk_separator_menu_item_new ()); - gtk_action_connect_proxy (de->invoke_comments_dialog, - get_widget_assert (de->xml, "utilities_comments") - ); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_variable); - 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_widget_show_all (menu); - gtk_action_connect_proxy (de->invoke_crosstabs_dialog, - get_widget_assert (de->xml, "crosstabs") - ); + return menu; +} - gtk_action_connect_proxy (de->invoke_frequencies_dialog, - get_widget_assert (de->xml, "analyze_frequencies") - ); +#if RECENT_LISTS_AVAILABLE - gtk_action_connect_proxy (de->invoke_examine_dialog, - get_widget_assert (de->xml, "analyze_explore") - ); +static void +on_recent_data_select (GtkMenuShell *menushell, gpointer user_data) +{ + gchar *file; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (user_data); - gtk_action_connect_proxy (de->invoke_regression_dialog, - get_widget_assert (de->xml, "linear-regression") - ); + gchar *uri = + gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell)); - g_signal_connect (get_widget_assert (de->xml,"help_about"), - "activate", - G_CALLBACK (about_new), - e->window); + file = g_filename_from_uri (uri, NULL, NULL); + g_free (uri); - g_signal_connect (get_widget_assert (de->xml,"help_reference"), - "activate", - G_CALLBACK (reference_manual), - e->window); + open_data_file (file, de); + g_free (file); +} - g_signal_connect (de->data_editor, - "cases-selected", - G_CALLBACK (enable_delete_cases), - de); +static void +on_recent_files_select (GtkMenuShell *menushell, gpointer user_data) +{ + gchar *file; + GtkWidget *se ; - g_signal_connect (de->data_editor, - "variables-selected", - G_CALLBACK (enable_delete_variables), - de); + gchar *uri = + gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (menushell)); + file = g_filename_from_uri (uri, NULL, NULL); - g_signal_connect (GTK_NOTEBOOK (de->data_editor), - "switch-page", - G_CALLBACK (on_switch_sheet), de); + g_free (uri); - 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); + se = psppire_syntax_window_new (); - g_signal_connect (get_widget_assert (de->xml, "view_statusbar"), - "activate", - G_CALLBACK (status_bar_activate), de); + psppire_syntax_window_load_from_file (PSPPIRE_SYNTAX_WINDOW (se), file, NULL); + gtk_widget_show (se); + g_free (file); +} - g_signal_connect (get_widget_assert (de->xml, "view_gridlines"), - "activate", - G_CALLBACK (grid_lines_activate), de); +#endif +static void +enable_delete_cases (GtkWidget *w, gint case_num, gpointer data) +{ + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); - - g_signal_connect (get_widget_assert (de->xml, "view_data"), - "activate", - G_CALLBACK (data_view_activate), de); - - g_signal_connect (get_widget_assert (de->xml, "view_variables"), - "activate", - G_CALLBACK (variable_view_activate), de); - - - - g_signal_connect (get_widget_assert (de->xml, "view_fonts"), - "activate", - G_CALLBACK (fonts_activate), de); - - - - - gtk_action_connect_proxy (de->action_data_open, - get_widget_assert (de->xml, "button-open") - ); - - gtk_action_connect_proxy (de->action_data_save, - 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"); - - g_signal_connect (de->toggle_split_window, "toggled", - G_CALLBACK (toggle_split_window), - de); - - 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)); - - de->var_sheet_variable_popup_menu = - GTK_MENU (create_var_sheet_variable_popup_menu (de)); - - de->data_sheet_cases_popup_menu = - GTK_MENU (create_data_sheet_cases_popup_menu (de)); - - - g_object_set (de->data_editor, - "datasheet-column-menu", de->data_sheet_variable_popup_menu, - "datasheet-row-menu", de->data_sheet_cases_popup_menu, - "varsheet-row-menu", de->var_sheet_variable_popup_menu, - NULL); - - - return de; + gtk_action_set_visible (de->delete_cases, case_num != -1); } -void -new_data_window (GtkMenuItem *menuitem, gpointer parent) +static void +enable_delete_variables (GtkWidget *w, gint var, gpointer data) { - window_create (WINDOW_DATA, NULL); + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + + gtk_action_set_visible (de->delete_variables, var != -1); } /* Callback for when the datasheet/varsheet is selected */ @@ -967,7 +972,7 @@ on_switch_sheet (GtkNotebook *notebook, guint page_num, gpointer user_data) { - struct data_editor *de = user_data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (user_data); GtkWidget *view_data = get_widget_assert (de->xml, "view_data"); GtkWidget *view_variables = get_widget_assert (de->xml, "view_variables"); @@ -998,702 +1003,725 @@ on_switch_sheet (GtkNotebook *notebook, } -static void -status_bar_activate (GtkCheckMenuItem *menuitem, gpointer data) -{ - struct data_editor *de = data; - GtkWidget *statusbar = get_widget_assert (de->xml, "status-bar"); - - if ( gtk_check_menu_item_get_active (menuitem) ) - gtk_widget_show (statusbar); - else - gtk_widget_hide (statusbar); -} -static void -grid_lines_activate (GtkCheckMenuItem *menuitem, gpointer data) +void +create_data_window (void) { - struct data_editor *de = data; - const gboolean grid_visible = gtk_check_menu_item_get_active (menuitem); - - psppire_data_editor_show_grid (de->data_editor, grid_visible); + GtkWidget *w = psppire_data_window_new (); + gtk_widget_show (w); } - static void -data_view_activate (GtkCheckMenuItem *menuitem, gpointer data) +psppire_data_window_init (PsppireDataWindow *de) { - struct data_editor *de = data; + PsppireVarStore *vs; - gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_DATA_VIEW); -} + GtkWidget *menubar; + GtkWidget *hb ; + GtkWidget *sb ; + GtkWidget *box = gtk_vbox_new (FALSE, 0); + de->xml = XML_NEW ("data-editor.glade"); -static void -variable_view_activate (GtkCheckMenuItem *menuitem, gpointer data) -{ - struct data_editor *de = data; + menubar = get_widget_assert (de->xml, "menubar"); + hb = get_widget_assert (de->xml, "handlebox1"); + sb = get_widget_assert (de->xml, "status-bar"); - gtk_notebook_set_current_page (GTK_NOTEBOOK (de->data_editor), PSPPIRE_DATA_EDITOR_VARIABLE_VIEW); -} + de->data_editor = + PSPPIRE_DATA_EDITOR (psppire_data_editor_new (the_var_store, the_data_store)); + connect_help (de->xml); -static void -fonts_activate (GtkMenuItem *menuitem, gpointer data) -{ - struct data_editor *de = data; - PangoFontDescription *current_font; - gchar *font_name; - GtkWidget *dialog = - gtk_font_selection_dialog_new (_("Font Selection")); + g_object_ref (menubar); + gtk_widget_unparent (menubar); + g_object_ref (hb); + gtk_widget_unparent (hb); - current_font = GTK_WIDGET(de->data_editor)->style->font_desc; - font_name = pango_font_description_to_string (current_font); + g_object_ref (sb); + gtk_widget_unparent (sb); - gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (dialog), font_name); + gtk_box_pack_start (GTK_BOX (box), menubar, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (box), hb, FALSE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET (de->data_editor), TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (box), sb, FALSE, TRUE, 0); - g_free (font_name); + gtk_container_add (GTK_CONTAINER (de), box); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (get_widget_assert (de->xml, - "data_editor"))); - if ( GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (dialog)) ) - { - const gchar *font = gtk_font_selection_dialog_get_font_name - (GTK_FONT_SELECTION_DIALOG (dialog)); + g_signal_connect (de->data_editor, "data-selection-changed", + G_CALLBACK (update_cut_copy_menuitems), de); - PangoFontDescription* font_desc = - pango_font_description_from_string (font); + g_signal_connect (de->data_editor, "data-available-changed", + G_CALLBACK (update_paste_menuitems), de); - psppire_data_editor_set_font (de->data_editor, font_desc); - } + dataset_add_transform_change_callback (the_dataset, + transformation_change_callback, + de); - gtk_widget_hide (dialog); -} + vs = the_var_store; + g_assert(vs); /* Traps a possible bug in w32 build */ -/* Callback for the value labels action */ -static void -toggle_value_labels (GtkToggleAction *ta, gpointer data) -{ - struct data_editor *de = data; + g_signal_connect (vs->dict, "weight-changed", + G_CALLBACK (on_weight_change), + de); - g_object_set (de->data_editor, "value-labels", gtk_toggle_action_get_active (ta), NULL); -} + g_signal_connect (vs->dict, "filter-changed", + G_CALLBACK (on_filter_change), + de); + g_signal_connect (vs->dict, "split-changed", + G_CALLBACK (on_split_change), + de); -static void -toggle_split_window (GtkToggleAction *ta, gpointer data) -{ - struct data_editor *de = data; + g_signal_connect (get_widget_assert (de->xml, "edit_copy"), + "activate", + G_CALLBACK (on_edit_copy), de); - psppire_data_editor_split_window (de->data_editor, - gtk_toggle_action_get_active (ta)); -} + 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"); -static void -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 (); -} + g_signal_connect (de->toggle_value_labels, "toggled", + G_CALLBACK (toggle_value_labels), de); -static void -insert_case (GtkAction *action, gpointer data) -{ - struct data_editor *de = data; + gtk_action_connect_proxy (GTK_ACTION (de->toggle_value_labels), + get_widget_assert (de->xml, + "togglebutton-value-labels")); - psppire_data_editor_insert_case (de->data_editor); -} -static void -on_insert_variable (GtkAction *action, gpointer data) -{ - PsppireDataEditor *de = PSPPIRE_DATA_EDITOR (data); - psppire_data_editor_insert_variable (de); -} + gtk_action_connect_proxy (GTK_ACTION (de->toggle_value_labels), + get_widget_assert (de->xml, + "view_value-labels")); -/* Callback for when the dictionary changes its split variables */ -static void -on_split_change (PsppireDict *dict, gpointer data) -{ - struct data_editor *de = data; - size_t n_split_vars = dict_get_split_cnt (dict->dict); + de->delete_cases = + gtk_action_new ("clear-cases", + _("Clear"), + _("Delete the cases at the selected position(s)"), + "pspp-clear-cases"); - GtkWidget *split_status_area = - get_widget_assert (de->xml, "split-file-status-area"); + g_signal_connect_swapped (de->delete_cases, "activate", + G_CALLBACK (psppire_data_editor_delete_cases), + de->data_editor); - if ( n_split_vars == 0 ) - { - gtk_label_set_text (GTK_LABEL (split_status_area), _("No Split")); - } - else - { - gint i; - GString *text; - const struct variable *const * split_vars = - dict_get_split_vars (dict->dict); + gtk_action_connect_proxy (de->delete_cases, + get_widget_assert (de->xml, "edit_clear-cases")); - text = g_string_new (_("Split by ")); + g_signal_connect (get_widget_assert (de->xml, "edit_paste"), "activate", + G_CALLBACK (on_edit_paste), + de); - for (i = 0 ; i < n_split_vars - 1; ++i ) - { - g_string_append_printf (text, "%s, ", var_get_name (split_vars[i])); - } - g_string_append (text, var_get_name (split_vars[i])); + gtk_action_set_visible (de->delete_cases, FALSE); - gtk_label_set_text (GTK_LABEL (split_status_area), text->str); - - g_string_free (text, TRUE); - } -} + 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); -/* Callback for when the dictionary changes its filter variable */ -static void -on_filter_change (GObject *o, gint filter_index, gpointer data) -{ - struct data_editor *de = data; - GtkWidget *filter_status_area = - get_widget_assert (de->xml, "filter-use-status-area"); + gtk_action_connect_proxy (de->delete_variables, + get_widget_assert (de->xml, "edit_clear-variables") + ); - if ( filter_index == -1 ) - { - gtk_label_set_text (GTK_LABEL (filter_status_area), _("Filter off")); - } - else - { - PsppireVarStore *vs = NULL; - struct variable *var ; - gchar *text ; + gtk_action_set_visible (de->delete_variables, FALSE); - g_object_get (de->data_editor, "var-store", &vs, NULL); + de->insert_variable = + gtk_action_new ("insert-variable", + _("Insert _Variable"), + _("Create a new variable at the current position"), + "pspp-insert-variable"); - var = psppire_dict_get_variable (vs->dict, filter_index); + g_signal_connect (de->insert_variable, "activate", + G_CALLBACK (on_insert_variable), de->data_editor); - text = g_strdup_printf (_("Filter by %s"), var_get_name (var)); - gtk_label_set_text (GTK_LABEL (filter_status_area), text); + gtk_action_connect_proxy (de->insert_variable, + get_widget_assert (de->xml, "button-insert-variable") + ); - g_free (text); - } -} + gtk_action_connect_proxy (de->insert_variable, + get_widget_assert (de->xml, "edit_insert-variable") + ); -/* Callback for when the dictionary changes its weights */ -static void -on_weight_change (GObject *o, gint weight_index, gpointer data) -{ - struct data_editor *de = data; - GtkWidget *weight_status_area = - get_widget_assert (de->xml, "weight-status-area"); - if ( weight_index == -1 ) - { - gtk_label_set_text (GTK_LABEL (weight_status_area), _("Weights off")); - } - else - { - struct variable *var ; - PsppireVarStore *vs = NULL; - gchar *text; + de->insert_case = + gtk_action_new ("insert-case", + _("Insert Ca_se"), + _("Create a new case at the current position"), + "pspp-insert-case"); - g_object_get (de->data_editor, "var-store", &vs, NULL); + g_signal_connect (de->insert_case, "activate", + G_CALLBACK (insert_case), de); - var = psppire_dict_get_variable (vs->dict, weight_index); - text = g_strdup_printf (_("Weight by %s"), var_get_name (var)); + gtk_action_connect_proxy (de->insert_case, + get_widget_assert (de->xml, "button-insert-case") + ); - gtk_label_set_text (GTK_LABEL (weight_status_area), text); - g_free (text); - } -} + 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"); - -static void data_save_as_dialog (GtkAction *, struct data_editor *de); -static void new_file (GtkAction *, struct editor_window *de); -static void open_data_dialog (GtkAction *, struct data_editor *de); -static void data_save (GtkAction *action, struct data_editor *e); + gtk_action_connect_proxy (de->invoke_goto_dialog, + get_widget_assert (de->xml, "button-goto-case") + ); -/* Create the GtkActions and connect to their signals */ -static void -register_data_editor_actions (struct data_editor *de) -{ - de->action_data_open = - gtk_action_new ("data-open-dialog", - _("Open"), - _("Open a data file"), - "gtk-open"); + gtk_action_connect_proxy (de->invoke_goto_dialog, + get_widget_assert (de->xml, "edit_goto-case") + ); - g_signal_connect (de->action_data_open, "activate", - G_CALLBACK (open_data_dialog), de); + g_signal_connect (de->invoke_goto_dialog, "activate", + G_CALLBACK (goto_case_dialog), de); - de->action_data_save = gtk_action_new ("data-save", - _("Save"), - _("Save data to file"), - "gtk-save"); + de->invoke_weight_cases_dialog = + gtk_action_new ("weight-cases-dialog", + _("_Weights"), + _("Weight cases by variable"), + "pspp-weight-cases"); - g_signal_connect (de->action_data_save, "activate", - G_CALLBACK (data_save), de); + g_signal_connect (de->invoke_weight_cases_dialog, "activate", + G_CALLBACK (weight_cases_dialog), de); + de->invoke_transpose_dialog = + gtk_action_new ("transpose-dialog", + _("_Transpose"), + _("Transpose the cases with the variables"), + NULL); - de->action_data_save_as = gtk_action_new ("data-save-as-dialog", - _("Save As"), - _("Save data to file"), - "gtk-save"); - g_signal_connect (de->action_data_save_as, "activate", - G_CALLBACK (data_save_as_dialog), de); + g_signal_connect (de->invoke_transpose_dialog, "activate", + G_CALLBACK (transpose_dialog), de); - de->action_data_new = - gtk_action_new ("data-new", - _("New"), - _("New data file"), - NULL); - 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"), - ""); + 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_text_import_assistant, "activate", - G_CALLBACK (text_data_import_assistant), de); -} + g_signal_connect (de->invoke_split_file_dialog, "activate", + G_CALLBACK (split_file_dialog), de); -/* Returns true if NAME has a suffix which might denote a PSPP file */ -static gboolean -name_has_suffix (const gchar *name) -{ - if ( g_str_has_suffix (name, ".sav")) - return TRUE; - if ( g_str_has_suffix (name, ".SAV")) - return TRUE; - if ( g_str_has_suffix (name, ".por")) - return TRUE; - if ( g_str_has_suffix (name, ".POR")) - return TRUE; - return FALSE; -} -/* Append SUFFIX to the filename of DE */ -static void -append_filename_suffix (struct data_editor *de, const gchar *suffix) -{ - if ( ! name_has_suffix (de->file_name)) - { - gchar *s = de->file_name; - de->file_name = g_strconcat (de->file_name, suffix, NULL); - g_free (s); - } -} + de->invoke_sort_cases_dialog = + gtk_action_new ("sort-cases-dialog", + _("_Sort"), + _("Sort cases in the active file"), + "pspp-sort-cases"); -/* Save DE to file */ -static void -save_file (struct data_editor *de) -{ - struct getl_interface *sss; - struct string file_name ; + g_signal_connect (de->invoke_sort_cases_dialog, "activate", + G_CALLBACK (sort_cases_dialog), de); - g_assert (de->file_name); + de->invoke_select_cases_dialog = + gtk_action_new ("select-cases-dialog", + _("Select _Cases"), + _("Select cases from the active file"), + "pspp-select-cases"); - ds_init_empty (&file_name); - syntax_gen_string (&file_name, ss_cstr (de->file_name)); + g_signal_connect (de->invoke_select_cases_dialog, "activate", + G_CALLBACK (select_cases_dialog), de); - if ( de->save_as_portable ) - { - append_filename_suffix (de, ".por"); - 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.", - ds_cstr (&file_name)); - } - ds_destroy (&file_name); + de->invoke_compute_dialog = + gtk_action_new ("compute-dialog", + _("_Compute"), + _("Compute new values for a variable"), + "pspp-compute"); - execute_syntax (sss); -} + 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); -/* Callback for data_save action. - If there's an existing file name, then just save, - otherwise prompt for a file name, then save */ -static void -data_save (GtkAction *action, struct data_editor *de) -{ - if ( de->file_name) - save_file (de); - else - data_save_as_dialog (action, de); -} + 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); -/* Callback for data_save_as action. Prompt for a filename and save */ -static void -data_save_as_dialog (GtkAction *action, struct data_editor *de) -{ - struct editor_window *e = (struct editor_window *) de; + g_signal_connect (de->invoke_t_test_independent_samples_dialog, "activate", + G_CALLBACK (t_test_independent_samples_dialog), de); - GtkWidget *button_sys; - GtkWidget *dialog = - gtk_file_chooser_dialog_new (_("Save"), - GTK_WINDOW (e->window), - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); - GtkFileFilter *filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("System Files (*.sav)")); - gtk_file_filter_add_pattern (filter, "*.sav"); - gtk_file_filter_add_pattern (filter, "*.SAV"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + 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); - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("Portable Files (*.por) ")); - gtk_file_filter_add_pattern (filter, "*.por"); - gtk_file_filter_add_pattern (filter, "*.POR"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + g_signal_connect (de->invoke_t_test_paired_samples_dialog, "activate", + G_CALLBACK (t_test_paired_samples_dialog), de); - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("All Files")); - gtk_file_filter_add_pattern (filter, "*"); - 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")); + 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); - button_por = - gtk_radio_button_new_with_label - (gtk_radio_button_get_group (GTK_RADIO_BUTTON(button_sys)), - _("Portable File")); + g_signal_connect (de->invoke_t_test_one_sample_dialog, "activate", + G_CALLBACK (t_test_one_sample_dialog), de); - gtk_box_pack_start_defaults (GTK_BOX (vbox), button_sys); - gtk_box_pack_start_defaults (GTK_BOX (vbox), button_por); - gtk_widget_show_all (vbox); + de->invoke_comments_dialog = + gtk_action_new ("commments-dialog", + _("Data File _Comments"), + _("Commentary text for the data file"), + NULL); - gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER(dialog), vbox); - } + g_signal_connect (de->invoke_comments_dialog, "activate", + G_CALLBACK (comments_dialog), de); - switch (gtk_dialog_run (GTK_DIALOG (dialog))) - { - case GTK_RESPONSE_ACCEPT: - { - g_free (de->file_name); + de->invoke_find_dialog = + gtk_action_new ("find-dialog", + _("_Find"), + _("Find Case"), + "gtk-find"); - de->file_name = - gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + g_signal_connect (de->invoke_find_dialog, "activate", + G_CALLBACK (find_dialog), 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"); + de->invoke_rank_dialog = + gtk_action_new ("rank-dialog", + _("Ran_k Cases"), + _("Rank Cases"), + "pspp-rank-cases"); - save_file (de); + g_signal_connect (de->invoke_rank_dialog, "activate", + G_CALLBACK (rank_dialog), de); - window_set_name_from_filename (e, de->file_name); - } - break; - default: - break; - } - gtk_widget_destroy (dialog); -} + 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); -/* Callback for data_new action. - Performs the NEW FILE command */ -static void -new_file (GtkAction *action, struct editor_window *e) -{ - struct data_editor *de = (struct data_editor *) e; - struct getl_interface *sss = - create_syntax_string_source ("NEW FILE."); + de->invoke_recode_different_dialog = + gtk_action_new ("recode-different-dialog", + _("Recode into _Different Variables"), + _("Recode values into different Variables"), + "pspp-recode-different"); - execute_syntax (sss); + g_signal_connect (de->invoke_recode_different_dialog, "activate", + G_CALLBACK (recode_different_dialog), de); - g_free (de->file_name); - de->file_name = NULL; - default_window_name (e); -} + 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); -static void -open_data_file (const gchar *file_name, struct data_editor *de) -{ - struct getl_interface *sss; - struct string filename; + de->invoke_descriptives_dialog = + gtk_action_new ("descriptives-dialog", + _("_Descriptives"), + _("Calculate descriptive statistics (mean, variance, ...)"), + "pspp-descriptives"); - ds_init_empty (&filename); - syntax_gen_string (&filename, ss_cstr (file_name)); + g_signal_connect (de->invoke_descriptives_dialog, "activate", + G_CALLBACK (descriptives_dialog), de); - sss = create_syntax_string_source ("GET FILE=%s.", - ds_cstr (&filename)); - ds_destroy (&filename); - if (execute_syntax (sss) ) + 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); + + g_signal_connect_swapped (get_widget_assert (de->xml,"file_new_data"), + "activate", + G_CALLBACK (gtk_action_activate), + de->action_data_new); + + g_signal_connect_swapped (get_widget_assert (de->xml,"file_open_data"), + "activate", + G_CALLBACK (gtk_action_activate), + de->action_data_open); + +#if RECENT_LISTS_AVAILABLE { - window_set_name_from_filename ((struct editor_window *) de, file_name); - add_most_recent (file_name); - } -} + 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 (); -/* Callback for the data_open action. - Prompts for a filename and opens it */ -static void -open_data_dialog (GtkAction *action, struct data_editor *de) -{ - struct editor_window *e = (struct editor_window *) de; + gtk_widget_show (recent_data); + gtk_widget_show (recent_files); + gtk_widget_show (recent_separator); - GtkWidget *dialog = - gtk_file_chooser_dialog_new (_("Open"), - GTK_WINDOW (e->window), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); + gtk_recent_filter_add_pattern (filter, "*.sav"); + gtk_recent_filter_add_pattern (filter, "*.SAV"); - GtkFileFilter *filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("System Files (*.sav)")); - gtk_file_filter_add_pattern (filter, "*.sav"); - gtk_file_filter_add_pattern (filter, "*.SAV"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + gtk_recent_chooser_add_filter (GTK_RECENT_CHOOSER (menu), filter); - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("Portable Files (*.por) ")); - gtk_file_filter_add_pattern (filter, "*.por"); - gtk_file_filter_add_pattern (filter, "*.POR"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + gtk_widget_set_sensitive (recent_data, TRUE); + g_signal_connect (menu, "selection-done", + G_CALLBACK (on_recent_data_select), de); - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("All Files")); - gtk_file_filter_add_pattern (filter, "*"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (recent_data), menu); - 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); - } + 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 (create_syntax_window), + NULL); + + g_signal_connect (get_widget_assert (de->xml,"file_open_syntax"), + "activate", + G_CALLBACK (open_syntax_window), + de); + + 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), + de->action_data_save); + + g_signal_connect_swapped (get_widget_assert (de->xml,"file_save_as"), + "activate", + 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") + ); - switch (gtk_dialog_run (GTK_DIALOG (dialog))) - { - case GTK_RESPONSE_ACCEPT: - { - g_free (de->file_name); - de->file_name = - gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + gtk_action_connect_proxy (de->invoke_find_dialog, + get_widget_assert (de->xml, "button-find") + ); - open_data_file (de->file_name, de); - } - break; - default: - break; - } + gtk_action_connect_proxy (de->invoke_rank_dialog, + get_widget_assert (de->xml, "transform_rank") + ); - gtk_widget_destroy (dialog); -} + 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") + ); -static GtkWidget * -create_data_sheet_variable_popup_menu (struct data_editor *de) -{ - GtkWidget *menu = gtk_menu_new (); + gtk_action_connect_proxy (de->invoke_weight_cases_dialog, + get_widget_assert (de->xml, "data_weight-cases") + ); - GtkWidget *sort_ascending = - gtk_menu_item_new_with_label (_("Sort Ascending")); + gtk_action_connect_proxy (de->invoke_transpose_dialog, + get_widget_assert (de->xml, "data_transpose") + ); - GtkWidget *sort_descending = - gtk_menu_item_new_with_label (_("Sort Descending")); + gtk_action_connect_proxy (de->invoke_split_file_dialog, + get_widget_assert (de->xml, "data_split-file") + ); - GtkWidget *insert_variable = - gtk_menu_item_new_with_label (_("Insert Variable")); + gtk_action_connect_proxy (de->invoke_sort_cases_dialog, + get_widget_assert (de->xml, "data_sort-cases") + ); - GtkWidget *clear_variable = - gtk_menu_item_new_with_label (_("Clear")); + 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->delete_variables, - clear_variable ); + gtk_action_connect_proxy (de->invoke_t_test_independent_samples_dialog, + get_widget_assert (de->xml, + "indep-t-test") + ); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable); + gtk_action_connect_proxy (de->invoke_t_test_paired_samples_dialog, + get_widget_assert (de->xml, + "paired-t-test") + ); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), - gtk_separator_menu_item_new ()); + gtk_action_connect_proxy (de->invoke_t_test_one_sample_dialog, + get_widget_assert (de->xml, + "one-sample-t-test") + ); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), clear_variable); + gtk_action_connect_proxy (de->invoke_oneway_anova_dialog, + get_widget_assert (de->xml, + "oneway-anova") + ); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), - gtk_separator_menu_item_new ()); + 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_menu_shell_append (GTK_MENU_SHELL (menu), sort_ascending); + 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") + ); - g_signal_connect_swapped (G_OBJECT (sort_ascending), "activate", - G_CALLBACK (psppire_data_editor_sort_ascending), - de->data_editor); + gtk_action_connect_proxy (de->invoke_frequencies_dialog, + get_widget_assert (de->xml, "analyze_frequencies") + ); - 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_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") + ); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), sort_descending); + g_signal_connect (get_widget_assert (de->xml,"help_about"), + "activate", + G_CALLBACK (about_new), + de); - gtk_widget_show_all (menu); - return menu; -} + g_signal_connect (get_widget_assert (de->xml,"help_reference"), + "activate", + G_CALLBACK (reference_manual), + de); -static GtkWidget * -create_data_sheet_cases_popup_menu (struct data_editor *de) -{ - GtkWidget *menu = gtk_menu_new (); + g_signal_connect (de->data_editor, + "cases-selected", + G_CALLBACK (enable_delete_cases), + de); - GtkWidget *insert_case = - gtk_menu_item_new_with_label (_("Insert Case")); + g_signal_connect (de->data_editor, + "variables-selected", + G_CALLBACK (enable_delete_variables), + de); - GtkWidget *delete_case = - gtk_menu_item_new_with_label (_("Clear")); + g_signal_connect (GTK_NOTEBOOK (de->data_editor), + "switch-page", + G_CALLBACK (on_switch_sheet), de); - gtk_action_connect_proxy (de->delete_cases, - delete_case); + 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", + G_CALLBACK (status_bar_activate), de); - 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); + g_signal_connect (get_widget_assert (de->xml, "view_gridlines"), + "activate", + G_CALLBACK (grid_lines_activate), de); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), - gtk_separator_menu_item_new ()); + g_signal_connect (get_widget_assert (de->xml, "view_data"), + "activate", + G_CALLBACK (data_view_activate), de); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_case); + g_signal_connect (get_widget_assert (de->xml, "view_variables"), + "activate", + G_CALLBACK (variable_view_activate), de); - gtk_widget_show_all (menu); - return menu; -} + g_signal_connect (get_widget_assert (de->xml, "view_fonts"), + "activate", + G_CALLBACK (fonts_activate), de); -static GtkWidget * -create_var_sheet_variable_popup_menu (struct data_editor *de) -{ - GtkWidget *menu = gtk_menu_new (); - GtkWidget *insert_variable = - gtk_menu_item_new_with_label (_("Insert Variable")); - GtkWidget *delete_variable = - gtk_menu_item_new_with_label (_("Clear")); + gtk_action_connect_proxy (de->action_data_open, + get_widget_assert (de->xml, "button-open") + ); + gtk_action_connect_proxy (de->action_data_save, + get_widget_assert (de->xml, "button-save") + ); - gtk_action_connect_proxy (de->delete_variables, - delete_variable); + 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_menu_shell_append (GTK_MENU_SHELL (menu), insert_variable); + gtk_action_connect_proxy (de->invoke_split_file_dialog, + get_widget_assert (de->xml, "button-split-file") + ); - g_signal_connect_swapped (G_OBJECT (insert_variable), "activate", - G_CALLBACK (gtk_action_activate), - de->insert_variable); + gtk_action_connect_proxy (de->invoke_select_cases_dialog, + get_widget_assert (de->xml, "button-select-cases") + ); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), - gtk_separator_menu_item_new ()); + 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); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), delete_variable); + g_signal_connect (get_widget_assert (de->xml, "windows_minimise_all"), + "activate", + G_CALLBACK (psppire_window_minimise_all), NULL); - gtk_widget_show_all (menu); + de->toggle_split_window = + gtk_toggle_action_new ("toggle-split-window", + _("_Split Window"), + _("Split the window vertically and horizontally"), + "pspp-split-window"); - return menu; -} + g_signal_connect (de->toggle_split_window, "toggled", + G_CALLBACK (toggle_split_window), + de); + 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)); - + de->var_sheet_variable_popup_menu = + GTK_MENU (create_var_sheet_variable_popup_menu (de)); -static void -on_edit_paste (GtkAction *a, gpointer data) -{ - struct data_editor *de = data; + de->data_sheet_cases_popup_menu = + GTK_MENU (create_data_sheet_cases_popup_menu (de)); - psppire_data_editor_clip_paste (de->data_editor); -} -static void -on_edit_copy (GtkMenuItem *m, gpointer data) -{ - struct data_editor *de = data; + g_object_set (de->data_editor, + "datasheet-column-menu", de->data_sheet_variable_popup_menu, + "datasheet-row-menu", de->data_sheet_cases_popup_menu, + "varsheet-row-menu", de->var_sheet_variable_popup_menu, + NULL); - psppire_data_editor_clip_copy (de->data_editor); + gtk_widget_show (de->data_editor); + gtk_widget_show (box); } - -static void -on_edit_cut (GtkMenuItem *m, gpointer data) +GtkWidget* +psppire_data_window_new (void) { - struct data_editor *de = data; - - psppire_data_editor_clip_cut (de->data_editor); + return GTK_WIDGET (g_object_new (psppire_data_window_get_type (), + "usage", PSPPIRE_WINDOW_USAGE_DATA, + NULL)); } + diff --git a/src/ui/gui/data-editor.h b/src/ui/gui/psppire-data-window.h similarity index 66% rename from src/ui/gui/data-editor.h rename to src/ui/gui/psppire-data-window.h index af282e26..13d59a0c 100644 --- a/src/ui/gui/data-editor.h +++ b/src/ui/gui/psppire-data-window.h @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2006, 2007 Free Software Foundation + Copyright (C) 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 @@ -15,24 +15,46 @@ along with this program. If not, see . */ -#ifndef DATA_EDITOR_H -#define DATA_EDITOR_H +#ifndef __PSPPIRE_DATA_WINDOW_H__ +#define __PSPPIRE_DATA_WINDOW_H__ + +#include +#include +#include +#include "psppire-window.h" +#include "psppire-data-editor.h" #include #include -#include "window-manager.h" -#include "psppire-data-editor.h" -struct data_editor +G_BEGIN_DECLS + +#define PSPPIRE_DATA_WINDOW_TYPE (psppire_data_window_get_type ()) +#define PSPPIRE_DATA_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PSPPIRE_DATA_WINDOW_TYPE, PsppireDataWindow)) +#define PSPPIRE_DATA_WINDOW_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \ + PSPPIRE_DATA_WINDOW_TYPE, PsppireData_WindowClass)) +#define PSPPIRE_IS_DATA_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \ + PSPPIRE_DATA_WINDOW_TYPE)) +#define PSPPIRE_IS_DATA_WINDOW_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \ + PSPPIRE_DATA_WINDOW_TYPE)) + + +typedef struct _PsppireDataWindow PsppireDataWindow; +typedef struct _PsppireDataWindowClass PsppireDataWindowClass; + + +struct _PsppireDataWindow { - struct editor_window parent; + PsppireWindow parent; + /* */ + PsppireDataEditor *data_editor; + GladeXML *xml; GtkAction *action_data_new; GtkAction *action_data_open; GtkAction *action_data_save_as; GtkAction *action_data_save; - GtkAction *invoke_text_import_assistant; /* Actions which invoke dialog boxes */ @@ -62,24 +84,19 @@ struct data_editor GtkAction *invoke_t_test_one_sample_dialog; GtkToggleAction *toggle_split_window; + GtkToggleAction *toggle_value_labels; - /* Actions which do things */ GtkAction *insert_variable; GtkAction *insert_case; GtkAction *delete_variables; GtkAction *delete_cases; - GtkToggleAction *toggle_value_labels; - - GladeXML *xml; GtkMenu *data_sheet_variable_popup_menu; GtkMenu *data_sheet_cases_popup_menu; - GtkMenu *var_sheet_variable_popup_menu; - PsppireDataEditor *data_editor; gboolean save_as_portable; @@ -89,11 +106,17 @@ struct data_editor gchar *file_name; }; +struct _PsppireDataWindowClass +{ + PsppireWindowClass parent_class; +}; + +GType psppire_data_window_get_type (void); +GtkWidget* psppire_data_window_new (void); -struct data_editor * new_data_editor (void); +void create_data_window (void); -void new_data_window (GtkMenuItem *, gpointer); -void data_editor_select_sheet (struct data_editor *de, gint page); +G_END_DECLS -#endif +#endif /* __PSPPIRE_DATA_WINDOW_H__ */ diff --git a/src/ui/gui/psppire-output-window.c b/src/ui/gui/psppire-output-window.c index 1bb7a455..4905aba5 100644 --- a/src/ui/gui/psppire-output-window.c +++ b/src/ui/gui/psppire-output-window.c @@ -79,8 +79,6 @@ psppire_output_window_get_type (void) static void psppire_output_window_finalize (GObject *object) { - g_debug ("%s %p", __FUNCTION__, object); - GObjectClass *class = G_OBJECT_GET_CLASS (object); GObjectClass *parent_class = g_type_class_peek_parent (class); @@ -283,7 +281,7 @@ psppire_output_window_reload (void) if ( NULL == the_output_viewer ) { the_output_viewer = PSPPIRE_OUTPUT_WINDOW (psppire_output_window_new ()); - gtk_widget_show (the_output_viewer); + gtk_widget_show (GTK_WIDGET (the_output_viewer)); } reload_viewer (the_output_viewer); diff --git a/src/ui/gui/psppire-syntax-window.c b/src/ui/gui/psppire-syntax-window.c index 56a39b85..5b326744 100644 --- a/src/ui/gui/psppire-syntax-window.c +++ b/src/ui/gui/psppire-syntax-window.c @@ -27,7 +27,7 @@ #include "psppire-syntax-window.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "about.h" #include "psppire-syntax-window.h" #include "syntax-editor-source.h" @@ -77,16 +77,12 @@ psppire_syntax_window_get_type (void) static void psppire_syntax_window_finalize (GObject *object) { - g_debug ("%s %p", __FUNCTION__, object); - GObjectClass *class = G_OBJECT_GET_CLASS (object); GObjectClass *parent_class = g_type_class_peek_parent (class); - if (G_OBJECT_CLASS (parent_class)->finalize) (*G_OBJECT_CLASS (parent_class)->finalize) (object); - } @@ -527,7 +523,7 @@ psppire_syntax_window_init (PsppireSyntaxWindow *window) g_signal_connect (get_widget_assert (xml,"file_new_data"), "activate", - G_CALLBACK (new_data_window), + G_CALLBACK (create_data_window), window); g_signal_connect (get_widget_assert (xml,"help_about"), diff --git a/src/ui/gui/psppire-window.c b/src/ui/gui/psppire-window.c index 909075b0..8405dba7 100644 --- a/src/ui/gui/psppire-window.c +++ b/src/ui/gui/psppire-window.c @@ -301,7 +301,7 @@ minimise_all (gpointer key, { PsppireWindow *w = PSPPIRE_WINDOW (value); - gtk_window_iconify (w); + gtk_window_iconify (GTK_WINDOW (w)); } diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 77d550a1..e50ce2f0 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -26,7 +26,7 @@ #include #include "relocatable.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire.h" #include @@ -141,7 +141,7 @@ initialize (struct command_line_processor *clp, int argc, char **argv) command_line_processor_parse (clp, argc, argv); - new_data_window (NULL, NULL); + create_data_window (); execute_syntax (create_syntax_string_source ("")); } diff --git a/src/ui/gui/rank-dialog.c b/src/ui/gui/rank-dialog.c index 86fabd14..c75f64f2 100644 --- a/src/ui/gui/rank-dialog.c +++ b/src/ui/gui/rank-dialog.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include @@ -220,7 +220,7 @@ void rank_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct rank_dialog rd; @@ -304,7 +304,7 @@ rank_dialog (GObject *o, gpointer data) G_CALLBACK (on_ntiles_toggle), rd.ntiles_entry); - gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (vars), vs->dict, diff --git a/src/ui/gui/recode-dialog.c b/src/ui/gui/recode-dialog.c index af6cbfa0..da32620b 100644 --- a/src/ui/gui/recode-dialog.c +++ b/src/ui/gui/recode-dialog.c @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include @@ -470,14 +470,14 @@ toggle_sensitivity (GtkToggleButton *button, GtkWidget *target) gtk_widget_set_sensitive (target, state); } -static void recode_dialog (struct data_editor *de, gboolean diff); +static void recode_dialog (PsppireDataWindow *de, gboolean diff); /* Pops up the Recode Same version of the dialog box */ void recode_same_dialog (GObject *o, gpointer data) { - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); recode_dialog (de, FALSE); } @@ -486,7 +486,7 @@ recode_same_dialog (GObject *o, gpointer data) void recode_different_dialog (GObject *o, gpointer data) { - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); recode_dialog (de, TRUE); } @@ -836,7 +836,7 @@ set_acr (struct recode_dialog *rd) } static void -recode_dialog (struct data_editor *de, gboolean diff) +recode_dialog (PsppireDataWindow *de, gboolean diff) { gint response; @@ -883,7 +883,7 @@ recode_dialog (struct data_editor *de, gboolean diff) rd.different = diff; - gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (rd.dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (rd.dict_treeview), @@ -994,7 +994,7 @@ recode_dialog (struct data_editor *de, gboolean diff) PSPPIRE_DIALOG (get_widget_assert (xml, "old-new-values-dialog")); gtk_window_set_transient_for (GTK_WINDOW (rd.old_and_new_dialog), - de->parent.window); + GTK_WINDOW (de)); rd.acr = PSPPIRE_ACR (get_widget_assert (xml, "psppire-acr1")); diff --git a/src/ui/gui/regression-dialog.c b/src/ui/gui/regression-dialog.c index a47d7345..4988261a 100644 --- a/src/ui/gui/regression-dialog.c +++ b/src/ui/gui/regression-dialog.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include @@ -223,11 +223,11 @@ void regression_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; - struct regression_dialog rd; GladeXML *xml = XML_NEW ("regression.glade"); + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); + PsppireVarStore *vs; GtkWidget *dialog = get_widget_assert (xml, "regression-dialog"); @@ -251,7 +251,7 @@ regression_dialog (GObject *o, gpointer data) stats ); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (source), vs->dict, @@ -286,8 +286,8 @@ regression_dialog (GObject *o, gpointer data) rd.current_opts.pred = FALSE; rd.current_opts.resid = FALSE; - gtk_window_set_transient_for (GTK_WINDOW (rd.save_dialog), de->parent.window); - gtk_window_set_transient_for (GTK_WINDOW (rd.stat_dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (rd.save_dialog), GTK_WINDOW (de)); + gtk_window_set_transient_for (GTK_WINDOW (rd.stat_dialog), GTK_WINDOW (de)); g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &rd); diff --git a/src/ui/gui/select-cases-dialog.c b/src/ui/gui/select-cases-dialog.c index 0056ca5e..9d711d31 100644 --- a/src/ui/gui/select-cases-dialog.c +++ b/src/ui/gui/select-cases-dialog.c @@ -21,7 +21,7 @@ #include #include "helper.h" #include "psppire-dialog.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "dialog-common.h" #include "dict-display.h" #include "widget-io.h" @@ -241,7 +241,7 @@ select_cases_dialog (GObject *o, gpointer data) gint response; struct select_cases_dialog scd = {0,0,0,0,0,0}; GtkWidget *dialog ; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); GtkWidget *entry = NULL; GtkWidget *selector ; GtkWidget *button_range; @@ -320,7 +320,7 @@ select_cases_dialog (GObject *o, gpointer data) dialog = get_widget_assert (scd.xml, "select-cases-dialog"); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); { GtkWidget *source = get_widget_assert (scd.xml, "select-cases-treeview"); diff --git a/src/ui/gui/sort-cases-dialog.c b/src/ui/gui/sort-cases-dialog.c index 6c3f332d..9e294861 100644 --- a/src/ui/gui/sort-cases-dialog.c +++ b/src/ui/gui/sort-cases-dialog.c @@ -19,7 +19,7 @@ #include "sort-cases-dialog.h" #include "helper.h" #include "psppire-dialog.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-var-store.h" #include "dialog-common.h" #include "dict-display.h" @@ -91,7 +91,7 @@ void sort_cases_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct sort_cases_dialog scd; @@ -108,7 +108,7 @@ sort_cases_dialog (GObject *o, gpointer data) g_object_get (de->data_editor, "var-store", &vs, NULL); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (source), vs->dict, diff --git a/src/ui/gui/split-file-dialog.c b/src/ui/gui/split-file-dialog.c index 96ecf5a6..f548a7aa 100644 --- a/src/ui/gui/split-file-dialog.c +++ b/src/ui/gui/split-file-dialog.c @@ -20,7 +20,7 @@ #include "psppire-selector.h" #include "psppire-dialog.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "dict-display.h" #include #include "psppire-syntax-window.h" @@ -167,7 +167,7 @@ void split_file_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct split_file_dialog sfd; PsppireVarStore *vs ; @@ -211,7 +211,7 @@ split_file_dialog (GObject *o, gpointer data) g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), &sfd); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); response = psppire_dialog_run (PSPPIRE_DIALOG (dialog)); diff --git a/src/ui/gui/t-test-independent-samples-dialog.c b/src/ui/gui/t-test-independent-samples-dialog.c index 03260012..a54a94ad 100644 --- a/src/ui/gui/t-test-independent-samples-dialog.c +++ b/src/ui/gui/t-test-independent-samples-dialog.c @@ -23,7 +23,7 @@ #include "psppire-dict.h" #include "psppire-var-store.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-dialog.h" #include "dialog-common.h" #include "dict-display.h" @@ -392,7 +392,7 @@ t_test_independent_samples_dialog (GObject *o, gpointer data) { struct tt_indep_samples_dialog tt_d; gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); PsppireVarStore *vs = NULL; @@ -421,11 +421,11 @@ t_test_independent_samples_dialog (GObject *o, gpointer data) tt_d.define_groups_button = get_widget_assert (xml, "define-groups-button"); tt_d.groups_entry = get_widget_assert (xml, "indep-samples-t-test-entry"); - tt_d.opts = tt_options_dialog_create (xml, de->parent.window); - tt_d.grps = tt_groups_dialog_create (xml, de->parent.window); + tt_d.opts = tt_options_dialog_create (xml, GTK_WINDOW (de)); + tt_d.grps = tt_groups_dialog_create (xml, GTK_WINDOW (de)); - gtk_window_set_transient_for (GTK_WINDOW (tt_d.dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (tt_d.dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view), vs->dict, diff --git a/src/ui/gui/t-test-one-sample.c b/src/ui/gui/t-test-one-sample.c index db08576f..6ce649b9 100644 --- a/src/ui/gui/t-test-one-sample.c +++ b/src/ui/gui/t-test-one-sample.c @@ -23,7 +23,7 @@ #include "psppire-dict.h" #include "psppire-var-store.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-dialog.h" #include "dialog-common.h" #include "dict-display.h" @@ -124,7 +124,7 @@ t_test_one_sample_dialog (GObject *o, gpointer data) { struct tt_one_sample_dialog tt_d; gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); PsppireVarStore *vs = NULL; @@ -145,9 +145,9 @@ t_test_one_sample_dialog (GObject *o, gpointer data) tt_d.dict = vs->dict; tt_d.vars_treeview = get_widget_assert (xml, "one-sample-t-test-treeview1"); tt_d.test_value_entry = get_widget_assert (xml, "test-value-entry"); - tt_d.opt = tt_options_dialog_create (xml, de->parent.window); + tt_d.opt = tt_options_dialog_create (xml, GTK_WINDOW (de)); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view), vs->dict, diff --git a/src/ui/gui/t-test-paired-samples.c b/src/ui/gui/t-test-paired-samples.c index c0207949..b84bee9b 100644 --- a/src/ui/gui/t-test-paired-samples.c +++ b/src/ui/gui/t-test-paired-samples.c @@ -20,7 +20,7 @@ #include #include -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-dict.h" #include "psppire-var-store.h" @@ -183,7 +183,7 @@ t_test_paired_samples_dialog (GObject *o, gpointer data) { struct tt_paired_samples_dialog tt_d; gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); PsppireVarStore *vs = NULL; @@ -203,9 +203,9 @@ t_test_paired_samples_dialog (GObject *o, gpointer data) tt_d.dict = vs->dict; tt_d.pairs_treeview = get_widget_assert (xml, "paired-samples-t-test-treeview2"); - tt_d.opt = tt_options_dialog_create (xml, de->parent.window); + tt_d.opt = tt_options_dialog_create (xml, GTK_WINDOW (de)); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (dict_view), diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 1cab531b..f749de38 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -63,7 +63,7 @@ text_data_import_assistant (GObject *o, gpointer de_) struct data_editor *de = de_; GtkWidget *dialog = - gtk_message_dialog_new (de->parent.window, + gtk_message_dialog_new (GTK_WINDOW (de), GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, @@ -259,7 +259,7 @@ void text_data_import_assistant (GObject *o, gpointer de_) { struct data_editor *de = de_; - GtkWindow *parent_window = de->parent.window; + GtkWindow *parent_window = GTK_WINDOW (de); struct import_assistant *ia; ia = xzalloc (sizeof *ia); @@ -2309,7 +2309,7 @@ pop_watch_cursor (struct import_assistant *ia) { if (--ia->asst.watch_cursor == 0) { - GtkWidget *widget = GTK_WIDGET (ia->asst.assistant);; + GtkWidget *widget = GTK_WIDGET (ia->asst.assistant); gdk_window_set_cursor (widget->window, NULL); } } diff --git a/src/ui/gui/transpose-dialog.c b/src/ui/gui/transpose-dialog.c index 9945c947..1a98a6a5 100644 --- a/src/ui/gui/transpose-dialog.c +++ b/src/ui/gui/transpose-dialog.c @@ -20,7 +20,7 @@ #include "psppire-selector.h" #include "psppire-dialog.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "dict-display.h" #include #include "psppire-syntax-window.h" @@ -80,7 +80,7 @@ void transpose_dialog (GObject *o, gpointer data) { gint response ; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); GladeXML *xml = XML_NEW ("psppire.glade"); @@ -117,7 +117,7 @@ transpose_dialog (GObject *o, gpointer data) g_signal_connect (dialog, "refresh", G_CALLBACK (refresh), xml); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); psppire_dialog_set_valid_predicate (PSPPIRE_DIALOG (dialog), dialog_state_valid, xml); diff --git a/src/ui/gui/variable-info-dialog.c b/src/ui/gui/variable-info-dialog.c index dcd1b911..09b545bd 100644 --- a/src/ui/gui/variable-info-dialog.c +++ b/src/ui/gui/variable-info-dialog.c @@ -23,7 +23,7 @@ #include #include #include -#include "data-editor.h" +#include "psppire-data-window.h" #include "psppire-dialog.h" #include "psppire-var-store.h" #include "helper.h" @@ -164,7 +164,7 @@ static gchar * generate_syntax (GtkTreeView *treeview); void variable_info_dialog (GObject *o, gpointer data) { - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); gint response ; @@ -178,7 +178,7 @@ variable_info_dialog (GObject *o, gpointer data) g_object_get (de->data_editor, "var-store", &vs, NULL); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); attach_dictionary_to_treeview (GTK_TREE_VIEW (treeview), vs->dict, diff --git a/src/ui/gui/weight-cases-dialog.c b/src/ui/gui/weight-cases-dialog.c index 3b1db1b9..121a523d 100644 --- a/src/ui/gui/weight-cases-dialog.c +++ b/src/ui/gui/weight-cases-dialog.c @@ -20,7 +20,7 @@ #include "psppire-selector.h" #include "psppire-dialog.h" #include "helper.h" -#include "data-editor.h" +#include "psppire-data-window.h" #include "dict-display.h" #include #include "psppire-syntax-window.h" @@ -104,7 +104,7 @@ void weight_cases_dialog (GObject *o, gpointer data) { gint response; - struct data_editor *de = data; + PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (data); struct weight_cases_dialog wcd; GladeXML *xml = XML_NEW ("psppire.glade"); @@ -122,7 +122,7 @@ weight_cases_dialog (GObject *o, gpointer data) g_object_get (de->data_editor, "var-store", &vs, NULL); - gtk_window_set_transient_for (GTK_WINDOW (dialog), de->parent.window); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (de)); g_signal_connect (radiobutton1, "toggled", G_CALLBACK (on_toggle), entry); g_signal_connect (selector, "selected", G_CALLBACK (on_select), diff --git a/src/ui/gui/window-manager.c b/src/ui/gui/window-manager.c deleted file mode 100644 index 065a4db7..00000000 --- a/src/ui/gui/window-manager.c +++ /dev/null @@ -1,198 +0,0 @@ -/* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2006, 2007 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 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. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - - -#include - -#include "relocatable.h" - -#include -#include "psppire-syntax-window.h" -#include "data-editor.h" - - -#include -#define _(msgid) gettext (msgid) -#define N_(msgid) msgid - - -#include "window-manager.h" - - - -/* A list of struct editor_windows */ -static GSList *window_list = NULL; - - -static void -deregister_window (GtkWindow *w, gpointer data) -{ - struct editor_window *e = data; - - window_list = g_slist_remove (window_list, e); - - if ( g_slist_length (window_list) == 0 ) - gtk_main_quit (); -}; - - -static void -register_window (struct editor_window *e) -{ - window_list = g_slist_prepend (window_list, e); -} - - -static gint -next_window_id (void) -{ - return g_slist_length (window_list); -} - -void -minimise_all_windows (void) -{ - const GSList *i = NULL; - - for (i = window_list; i != NULL ; i = i->next) - { - struct editor_window *e = i->data; - gtk_window_iconify (e->window); - } -} - -static void set_window_name (struct editor_window *e, const gchar *name ); - - -struct editor_window * -window_create (enum window_type type, const gchar *name) -{ - struct editor_window *e; - switch (type) - { - case WINDOW_SYNTAX: - //e = (struct editor_window *) new_syntax_editor (); - break; - case WINDOW_DATA: - e = (struct editor_window *) new_data_editor (); - break; - case WINDOW_OUTPUT: - //e = (struct editor_window *) new_output_viewer (); - break; - default: - g_assert_not_reached (); - }; - - e->type = type; - e->name = NULL; - - set_window_name (e, name); - - - gtk_window_set_icon_from_file (GTK_WINDOW (e->window), - relocate (PKGDATADIR "/psppicon.png"), 0); - - g_signal_connect (e->window, "destroy", - G_CALLBACK (deregister_window), e); - - register_window (e); - - gtk_widget_show (GTK_WIDGET (e->window)); - - return e; -} - -void -default_window_name (struct editor_window *w) -{ - set_window_name (w, NULL); -} - -static void -set_window_name (struct editor_window *e, - const gchar *name ) -{ - gchar *title ; - g_free (e->name); - - e->name = NULL; - - if ( name ) - { - e->name = g_strdup (name); - return; - } - - switch (e->type ) - { - case WINDOW_SYNTAX: - e->name = g_strdup_printf (_("Syntax%d"), next_window_id () ); - title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), e->name); - break; - case WINDOW_DATA: - e->name = g_strdup_printf (_("Untitled%d"), next_window_id () ); - title = g_strdup_printf (_("%s --- PSPP Data Editor"), e->name); - break; - case WINDOW_OUTPUT: - e->name = g_strdup_printf (_("Output%d"), next_window_id () ); - title = g_strdup_printf (_("%s --- PSPP Output"), e->name); - break; - default: - g_assert_not_reached (); - } - - gtk_window_set_title (GTK_WINDOW (e->window), title); - - g_free (title); -} - - -/* Set the name of this window based on FILENAME. - FILENAME is in "filename encoding" */ -void -window_set_name_from_filename (struct editor_window *e, - const gchar *fn) -{ - gchar *title; - gchar *filename = g_filename_to_utf8 (fn, -1, NULL, NULL, NULL); - gchar *basename = g_path_get_basename (filename); - - set_window_name (e, filename); - - switch (e->type) - { - case WINDOW_SYNTAX: - title = g_strdup_printf (_("%s --- PSPP Syntax Editor"), basename); - break; - case WINDOW_DATA: - title = g_strdup_printf (_("%s --- PSPP Data Editor"), basename); - break; - default: - g_assert_not_reached (); - } - g_free (basename); - - gtk_window_set_title (GTK_WINDOW (e->window), title); - - g_free (title); - g_free (filename); -} - -const gchar * -window_name (const struct editor_window *e) -{ - return e->name; -} diff --git a/src/ui/gui/window-manager.h b/src/ui/gui/window-manager.h deleted file mode 100644 index 2bb2fd7c..00000000 --- a/src/ui/gui/window-manager.h +++ /dev/null @@ -1,53 +0,0 @@ -/* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 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 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. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - - -#ifndef WINDOW_MANAGER_H -#define WINDOW_MANAGER_H - -#include - -enum window_type - { - WINDOW_DATA, - WINDOW_SYNTAX, - WINDOW_OUTPUT - }; - - -struct editor_window - { - GtkWindow *window; /* The top level window of the editor */ - gchar *name; /* The name of this editor (UTF-8) */ - enum window_type type; - } ; - -struct editor_window * window_create (enum window_type type, - const gchar *name); - -const gchar * window_name (const struct editor_window *); - -/* Set the name of this window based on FILENAME. - FILENAME is in "filename encoding" */ -void window_set_name_from_filename (struct editor_window *e, - const gchar *filename); - -void default_window_name (struct editor_window *w); - -void minimise_all_windows (void); - - -#endif -- 2.30.2