X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpsppire-data-window.c;h=e7506d261d05595ea33bfa569aa8a7900f400787;hb=1a24920c65ada574fceed15768f4b30553c77336;hp=dd87f53f7b92ac47bf5c7026049005d26e5419f8;hpb=c742f5287ac3c40742091c4f37d368f6206e3d3f;p=pspp diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index dd87f53f7b..e7506d261d 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008, 2009, 2010 Free Software Foundation + Copyright (C) 2008, 2009, 2010, 2011 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 @@ -21,15 +21,15 @@ #include #include "data/any-reader.h" -#include "data/procedure.h" -#include "language/syntax-string-source.h" +#include "data/dataset.h" +#include "language/lexer/lexer.h" #include "libpspp/message.h" -#include "ui/gui/help-menu.h" +#include "ui/gui/aggregate-dialog.h" #include "ui/gui/binomial-dialog.h" +#include "ui/gui/chi-square-dialog.h" #include "ui/gui/comments-dialog.h" #include "ui/gui/compute-dialog.h" #include "ui/gui/correlation-dialog.h" -#include "ui/gui/chi-square-dialog.h" #include "ui/gui/crosstabs-dialog.h" #include "ui/gui/descriptives-dialog.h" #include "ui/gui/examine-dialog.h" @@ -38,7 +38,9 @@ #include "ui/gui/find-dialog.h" #include "ui/gui/frequencies-dialog.h" #include "ui/gui/goto-case-dialog.h" +#include "ui/gui/help-menu.h" #include "ui/gui/helper.h" +#include "ui/gui/k-related-dialog.h" #include "ui/gui/oneway-anova-dialog.h" #include "ui/gui/psppire-data-window.h" #include "ui/gui/psppire-syntax-window.h" @@ -57,7 +59,6 @@ #include "ui/gui/t-test-paired-samples.h" #include "ui/gui/text-data-import-dialog.h" #include "ui/gui/transpose-dialog.h" -#include "ui/gui/aggregate-dialog.h" #include "ui/gui/variable-info-dialog.h" #include "ui/gui/weight-cases-dialog.h" #include "ui/syntax-gen.h" @@ -68,7 +69,6 @@ -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); @@ -88,7 +88,7 @@ psppire_data_window_get_type (void) { sizeof (PsppireDataWindowClass), (GBaseInitFunc) psppire_data_window_base_init, - (GBaseFinalizeFunc) psppire_data_window_base_finalize, + NULL, (GClassInitFunc)psppire_data_window_class_init, (GClassFinalizeFunc) NULL, NULL, @@ -145,16 +145,6 @@ psppire_data_window_base_init (PsppireDataWindowClass *class) object_class->finalize = psppire_data_window_finalize; } - - - -static void -psppire_data_window_base_finalize (PsppireDataWindowClass *class, - gpointer class_data) -{ -} - - @@ -186,9 +176,7 @@ set_cut_copy_menuitem_sensitivity (PsppireDataWindow *de, gboolean x) static void execute (void) { - struct getl_interface *sss = create_syntax_string_source ("EXECUTE."); - - execute_syntax (sss); + execute_const_syntax_string ("EXECUTE."); } static void @@ -352,28 +340,25 @@ dump_rm (GtkRecentManager *rm) static gboolean load_file (PsppireWindow *de, const gchar *file_name) { - gchar *native_file_name; - struct getl_interface *sss; + gchar *utf8_file_name; struct string filename; + gchar *syntax; + bool ok; ds_init_empty (&filename); - native_file_name = - convert_glib_filename_to_system_filename (file_name, NULL); + utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL); - syntax_gen_string (&filename, ss_cstr (native_file_name)); + syntax_gen_string (&filename, ss_cstr (utf8_file_name)); - g_free (native_file_name); - - sss = create_syntax_string_source ("GET FILE=%s.", - ds_cstr (&filename)); + g_free (utf8_file_name); + syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename)); ds_destroy (&filename); - if (execute_syntax (sss) ) - return TRUE; - - return FALSE; + ok = execute_syntax (lex_reader_for_string (syntax)); + g_free (syntax); + return ok; } static GtkWidget * @@ -499,12 +484,12 @@ name_has_suffix (const gchar *name) static void save_file (PsppireWindow *w) { - gchar *native_file_name = NULL; + gchar *utf8_file_name = NULL; gchar *file_name = NULL; GString *fnx; - struct getl_interface *sss; struct string filename ; PsppireDataWindow *de = PSPPIRE_DATA_WINDOW (w); + gchar *syntax; g_object_get (w, "filename", &file_name, NULL); @@ -520,28 +505,20 @@ save_file (PsppireWindow *w) ds_init_empty (&filename); - native_file_name = - convert_glib_filename_to_system_filename (fnx->str, NULL); + utf8_file_name = g_filename_to_utf8 (fnx->str, -1, NULL, NULL, NULL); g_string_free (fnx, TRUE); - syntax_gen_string (&filename, ss_cstr (native_file_name)); - g_free (native_file_name); + syntax_gen_string (&filename, ss_cstr (utf8_file_name)); + g_free (utf8_file_name); - if ( de->save_as_portable ) - { - sss = create_syntax_string_source ("EXPORT OUTFILE=%s.", - ds_cstr (&filename)); - } - else - { - sss = create_syntax_string_source ("SAVE OUTFILE=%s.", - ds_cstr (&filename)); - } + syntax = g_strdup_printf ("%s OUTFILE=%s.", + de->save_as_portable ? "EXPORT" : "SAVE", + ds_cstr (&filename)); ds_destroy (&filename); - execute_syntax (sss); + g_free (execute_syntax_string (syntax)); } @@ -561,11 +538,7 @@ on_insert_variable (PsppireDataWindow *dw) static void display_dict (PsppireDataWindow *de) { - - struct getl_interface *sss = - create_syntax_string_source ("DISPLAY DICTIONARY."); - - execute_syntax (sss); + execute_const_syntax_string ("DISPLAY DICTIONARY."); } static void @@ -576,22 +549,22 @@ sysfile_info (PsppireDataWindow *de) if ( GTK_RESPONSE_ACCEPT == gtk_dialog_run (GTK_DIALOG (dialog))) { struct string filename; - struct getl_interface *sss; gchar *file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - gchar *native_file_name = - convert_glib_filename_to_system_filename (file_name, NULL); + gchar *utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, + NULL); + + gchar *syntax; ds_init_empty (&filename); - syntax_gen_string (&filename, ss_cstr (native_file_name)); + syntax_gen_string (&filename, ss_cstr (utf8_file_name)); - g_free (native_file_name); + g_free (utf8_file_name); - sss = create_syntax_string_source ("SYSFILE INFO %s.", - ds_cstr (&filename)); - execute_syntax (sss); + syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename)); + g_free (execute_syntax_string (syntax)); } gtk_widget_destroy (dialog); @@ -702,11 +675,7 @@ data_save (PsppireWindow *de) static void new_file (PsppireDataWindow *de) { - struct getl_interface *sss = - create_syntax_string_source ("NEW FILE."); - - execute_syntax (sss); - + execute_const_syntax_string ("NEW FILE."); psppire_window_set_filename (PSPPIRE_WINDOW (de), NULL); } @@ -958,6 +927,12 @@ connect_action (PsppireDataWindow *dw, const char *action_name, static void psppire_data_window_init (PsppireDataWindow *de) { + static const struct dataset_callbacks cbs = + { + set_unsaved, /* changed */ + transformation_change_callback, /* transformations_changed */ + }; + PsppireVarStore *vs; PsppireDict *dict = NULL; @@ -984,7 +959,7 @@ psppire_data_window_init (PsppireDataWindow *de) g_signal_connect_swapped (the_data_store, "cases-deleted", G_CALLBACK (set_unsaved), de); - dataset_set_callback (the_dataset, set_unsaved, de); + dataset_set_callbacks (the_dataset, &cbs, de); connect_help (de->builder); @@ -1006,11 +981,6 @@ psppire_data_window_init (PsppireDataWindow *de) g_signal_connect_swapped (de->data_editor, "data-available-changed", G_CALLBACK (set_paste_menuitem_sensitivity), de); - dataset_add_transform_change_callback (the_dataset, - transformation_change_callback, - de); - - vs = the_var_store; g_assert(vs); /* Traps a possible bug in w32 build */ @@ -1132,6 +1102,8 @@ psppire_data_window_init (PsppireDataWindow *de) connect_action (de, "chi-square", G_CALLBACK (chisquare_dialog)); connect_action (de, "binomial", G_CALLBACK (binomial_dialog)); + + connect_action (de, "k-related-samples", G_CALLBACK (k_related_dialog)); {