X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fdata-editor.c;h=038b9685f7242be8fc26bf052e33f618c6b2bfb4;hb=06e6e50200bcf8d954dcda70b9c48c326eaec4a3;hp=722ac2e851a9772a528408d8f5db230f6bec6828;hpb=c24e23657fdb65d4565b85d3d05396531618d8df;p=pspp diff --git a/src/ui/gui/data-editor.c b/src/ui/gui/data-editor.c index 722ac2e851..038b9685f7 100644 --- a/src/ui/gui/data-editor.c +++ b/src/ui/gui/data-editor.c @@ -36,17 +36,30 @@ #include "select-cases-dialog.h" #include "compute-dialog.h" #include "goto-case-dialog.h" +#include "find-dialog.h" +#include "rank-dialog.h" +#include "recode-dialog.h" #include "comments-dialog.h" #include "variable-info-dialog.h" +#include "descriptives-dialog.h" +#include "crosstabs-dialog.h" +#include "frequencies-dialog.h" +#include "examine-dialog.h" #include "dict-display.h" #include "clipboard.h" +#include "oneway-anova-dialog.h" +#include "t-test-independent-samples-dialog.h" +#include "t-test-one-sample.h" +#include "t-test-paired-samples.h" + #define _(msgid) gettext (msgid) #define N_(msgid) msgid #include "data-editor.h" #include "syntax-editor.h" #include +#include #include #include "window-manager.h" @@ -160,6 +173,27 @@ transformation_change_callback (bool transformations_pending, static void open_data_file (const gchar *, struct data_editor *); +/* Puts FILE_NAME into the recent list. + If it's already in the list, it moves it to the top +*/ +static void +add_most_recent (const char *file_name) +{ +#if RECENT_LISTS_AVAILABLE + + GtkRecentManager *manager = gtk_recent_manager_get_default(); + gchar *uri = g_filename_to_uri (file_name, NULL, NULL); + + gtk_recent_manager_remove_item (manager, uri, NULL); + + if ( ! gtk_recent_manager_add_item (manager, uri)) + g_warning ("Could not add item %s to recent list\n",uri); + + g_free (uri); +#endif +} + + #if RECENT_LISTS_AVAILABLE @@ -562,6 +596,45 @@ new_data_editor (void) g_signal_connect (de->invoke_compute_dialog, "activate", G_CALLBACK (compute_dialog), de); + de->invoke_oneway_anova_dialog = + gtk_action_new ("oneway-anova", + _("Oneway _ANOVA"), + _("Perform one way analysis of variance"), + NULL); + + g_signal_connect (de->invoke_oneway_anova_dialog, "activate", + G_CALLBACK (oneway_anova_dialog), de); + + de->invoke_t_test_independent_samples_dialog = + gtk_action_new ("t-test-independent-samples", + _("_Independent Samples T Test"), + _("Calculate T Test for samples from independent groups"), + NULL); + + g_signal_connect (de->invoke_t_test_independent_samples_dialog, "activate", + G_CALLBACK (t_test_independent_samples_dialog), de); + + + de->invoke_t_test_paired_samples_dialog = + gtk_action_new ("t-test-paired-samples", + _("_Paired Samples T Test"), + _("Calculate T Test for paired samples"), + NULL); + + g_signal_connect (de->invoke_t_test_paired_samples_dialog, "activate", + G_CALLBACK (t_test_paired_samples_dialog), de); + + + de->invoke_t_test_one_sample_dialog = + gtk_action_new ("t-test-one-sample", + _("One _Sample T Test"), + _("Calculate T Test for sample from a single distribution"), + NULL); + + g_signal_connect (de->invoke_t_test_one_sample_dialog, "activate", + G_CALLBACK (t_test_one_sample_dialog), de); + + de->invoke_comments_dialog = gtk_action_new ("commments-dialog", _("Data File Comments"), @@ -571,6 +644,46 @@ new_data_editor (void) g_signal_connect (de->invoke_comments_dialog, "activate", G_CALLBACK (comments_dialog), de); + de->invoke_find_dialog = + gtk_action_new ("find-dialog", + _("Find"), + _("Find Case"), + "gtk-find"); + + g_signal_connect (de->invoke_find_dialog, "activate", + G_CALLBACK (find_dialog), de); + + + de->invoke_rank_dialog = + gtk_action_new ("rank-dialog", + _("Ran_k Cases"), + _("Rank Cases"), + "pspp-rank-cases"); + + g_signal_connect (de->invoke_rank_dialog, "activate", + G_CALLBACK (rank_dialog), de); + + + de->invoke_recode_same_dialog = + gtk_action_new ("recode-same-dialog", + _("Recode into _Same Variables"), + _("Recode values into the same Variables"), + "pspp-recode-same"); + + g_signal_connect (de->invoke_recode_same_dialog, "activate", + G_CALLBACK (recode_same_dialog), de); + + + de->invoke_recode_different_dialog = + gtk_action_new ("recode-different-dialog", + _("Recode into _Different Variables"), + _("Recode values into different Variables"), + "pspp-recode-different"); + + g_signal_connect (de->invoke_recode_different_dialog, "activate", + G_CALLBACK (recode_different_dialog), de); + + de->invoke_variable_info_dialog = gtk_action_new ("variable-info-dialog", _("Variables"), @@ -580,6 +693,46 @@ new_data_editor (void) g_signal_connect (de->invoke_variable_info_dialog, "activate", G_CALLBACK (variable_info_dialog), de); + de->invoke_descriptives_dialog = + gtk_action_new ("descriptives-dialog", + _("_Descriptives"), + _("Calculate descriptive statistics (mean, variance, ...)"), + "pspp-descriptives"); + + g_signal_connect (de->invoke_descriptives_dialog, "activate", + G_CALLBACK (descriptives_dialog), de); + + + de->invoke_frequencies_dialog = + gtk_action_new ("frequencies-dialog", + _("_Frequencies"), + _("Generate frequency statistics"), + "pspp-frequencies"); + + g_signal_connect (de->invoke_frequencies_dialog, "activate", + G_CALLBACK (frequencies_dialog), de); + + de->invoke_crosstabs_dialog = + gtk_action_new ("crosstabs-dialog", + _("_Crosstabs"), + _("Generate crosstabulations"), + "pspp-crosstabs"); + + g_signal_connect (de->invoke_crosstabs_dialog, "activate", + G_CALLBACK (crosstabs_dialog), de); + + + de->invoke_examine_dialog = + gtk_action_new ("examine-dialog", + _("_Explore"), + _("Examine Data by Factors"), + "pspp-examine"); + + g_signal_connect (de->invoke_examine_dialog, "activate", + G_CALLBACK (examine_dialog), de); + + + e->window = GTK_WINDOW (get_widget_assert (de->xml, "data_editor")); g_signal_connect_swapped (get_widget_assert (de->xml,"file_new_data"), @@ -592,7 +745,6 @@ new_data_editor (void) G_CALLBACK (gtk_action_activate), de->action_data_open); - #if RECENT_LISTS_AVAILABLE { GtkRecentManager *rm = gtk_recent_manager_get_default (); @@ -656,6 +808,28 @@ new_data_editor (void) G_CALLBACK (gtk_action_activate), de->action_data_save_as); + gtk_action_connect_proxy (de->invoke_find_dialog, + get_widget_assert (de->xml, "edit_find") + ); + + gtk_action_connect_proxy (de->invoke_find_dialog, + get_widget_assert (de->xml, "button-find") + ); + + gtk_action_connect_proxy (de->invoke_rank_dialog, + get_widget_assert (de->xml, "transform_rank") + ); + + gtk_action_connect_proxy (de->invoke_recode_same_dialog, + get_widget_assert (de->xml, + "transform_recode-same") + ); + + gtk_action_connect_proxy (de->invoke_recode_different_dialog, + get_widget_assert (de->xml, + "transform_recode-different") + ); + gtk_action_connect_proxy (de->invoke_weight_cases_dialog, get_widget_assert (de->xml, "data_weight-cases") ); @@ -680,6 +854,30 @@ new_data_editor (void) get_widget_assert (de->xml, "transform_compute") ); + gtk_action_connect_proxy (de->invoke_t_test_independent_samples_dialog, + get_widget_assert (de->xml, + "indep-t-test") + ); + + + gtk_action_connect_proxy (de->invoke_t_test_paired_samples_dialog, + get_widget_assert (de->xml, + "paired-t-test") + ); + + + gtk_action_connect_proxy (de->invoke_t_test_one_sample_dialog, + get_widget_assert (de->xml, + "one-sample-t-test") + ); + + + gtk_action_connect_proxy (de->invoke_oneway_anova_dialog, + get_widget_assert (de->xml, + "oneway-anova") + ); + + gtk_action_connect_proxy (de->invoke_comments_dialog, get_widget_assert (de->xml, "utilities_comments") ); @@ -688,6 +886,24 @@ new_data_editor (void) get_widget_assert (de->xml, "utilities_variables") ); + gtk_action_connect_proxy (de->invoke_descriptives_dialog, + get_widget_assert (de->xml, "analyze_descriptives") + ); + + gtk_action_connect_proxy (de->invoke_crosstabs_dialog, + get_widget_assert (de->xml, "crosstabs") + ); + + gtk_action_connect_proxy (de->invoke_frequencies_dialog, + get_widget_assert (de->xml, "analyze_frequencies") + ); + + + gtk_action_connect_proxy (de->invoke_examine_dialog, + get_widget_assert (de->xml, "analyze_explore") + ); + + g_signal_connect (get_widget_assert (de->xml,"help_about"), "activate", G_CALLBACK (about_new), @@ -1015,6 +1231,7 @@ toggle_value_labels (GtkToggleAction *ta, gpointer data) gtk_toggle_action_get_active (ta)); } +extern PsppireDataStore *the_data_store ; static void file_quit (GtkCheckMenuItem *menuitem, gpointer data) @@ -1022,6 +1239,7 @@ 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 (); } @@ -1492,14 +1710,17 @@ open_data_file (const gchar *file_name, struct data_editor *de) sss = create_syntax_string_source ("GET FILE=%s.", ds_cstr (&filename)); - - execute_syntax (sss); ds_destroy (&filename); - window_set_name_from_filename ((struct editor_window *) de, file_name); + if (execute_syntax (sss) ) + { + window_set_name_from_filename ((struct editor_window *) de, file_name); + add_most_recent (file_name); + } } + /* Callback for the data_open action. Prompts for a filename and opens it */ static void @@ -1550,19 +1771,6 @@ open_data_dialog (GtkAction *action, struct data_editor *de) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); open_data_file (de->file_name, de); - -#if RECENT_LISTS_AVAILABLE - { - GtkRecentManager *manager = gtk_recent_manager_get_default(); - gchar *uri = g_filename_to_uri (de->file_name, NULL, NULL); - - if ( ! gtk_recent_manager_add_item (manager, uri)) - g_warning ("Could not add item %s to recent list\n",uri); - - g_free (uri); - } -#endif - } break; default: @@ -1578,6 +1786,7 @@ open_data_dialog (GtkAction *action, struct data_editor *de) static gint update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data) { + GtkEntry *datum_entry; GladeXML *data_editor_xml = data; PsppireDataStore *data_store = @@ -1585,6 +1794,11 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data) g_return_val_if_fail (data_editor_xml, FALSE); + + datum_entry = + GTK_ENTRY (get_widget_assert (data_editor_xml, + "datum_entry")); + if (data_store) { const struct variable *var = @@ -1594,10 +1808,6 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data) GtkEntry *cell_ref_entry = GTK_ENTRY (get_widget_assert (data_editor_xml, "cell_ref_entry")); - GtkEntry *datum_entry = - GTK_ENTRY (get_widget_assert (data_editor_xml, - "datum_entry")); - if ( var ) { gchar *text = g_strdup_printf ("%d: %s", row + FIRST_CASE_NUMBER, @@ -1612,14 +1822,17 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data) g_free (s); } else - gtk_entry_set_text (cell_ref_entry, ""); - + goto blank_entry; if ( var ) { gchar *text = psppire_data_store_get_string (data_store, row, var_get_dict_index(var)); + + if ( ! text ) + goto blank_entry; + g_strchug (text); gtk_entry_set_text (datum_entry, text); @@ -1627,10 +1840,16 @@ update_data_ref_entry (const GtkSheet *sheet, gint row, gint col, gpointer data) free (text); } else - gtk_entry_set_text (datum_entry, ""); + goto blank_entry; + } return FALSE; + + blank_entry: + gtk_entry_set_text (datum_entry, ""); + + return FALSE; }