From 0c5217288cb57d0994d4c99997f5341e2c3a6871 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 5 Dec 2010 06:43:51 -0800 Subject: [PATCH] gui: Factor out duplicated code for executing and pasting syntax. Reducing code duplication is good on its own. This will also make it easier in upcoming patches to swap out "getl_interface" with a new structure, by eliminating most of the references to getl_interface. --- src/ui/gui/aggregate-dialog.c | 17 +---- src/ui/gui/binomial-dialog.c | 17 +---- src/ui/gui/chi-square-dialog.c | 17 +---- src/ui/gui/comments-dialog.c | 20 +----- src/ui/gui/compute-dialog.c | 20 +----- src/ui/gui/correlation-dialog.c | 19 +----- src/ui/gui/crosstabs-dialog.c | 20 +----- src/ui/gui/descriptives-dialog.c | 16 +---- src/ui/gui/examine-dialog.c | 19 +----- src/ui/gui/executor.c | 37 ++++++++--- src/ui/gui/executor.h | 5 +- src/ui/gui/factor-dialog.c | 19 +----- src/ui/gui/frequencies-dialog.c | 16 +---- src/ui/gui/helper.c | 6 +- src/ui/gui/helper.h | 2 +- src/ui/gui/k-related-dialog.c | 17 +---- src/ui/gui/oneway-anova-dialog.c | 19 +----- src/ui/gui/psppire-data-editor.c | 17 ++--- src/ui/gui/psppire-data-window.c | 41 ++++-------- src/ui/gui/psppire.c | 2 +- src/ui/gui/rank-dialog.c | 18 +----- src/ui/gui/recode-dialog.c | 19 +----- src/ui/gui/regression-dialog.c | 19 +----- src/ui/gui/reliability-dialog.c | 19 +----- src/ui/gui/roc-dialog.c | 19 +----- src/ui/gui/select-cases-dialog.c | 19 +----- src/ui/gui/sort-cases-dialog.c | 19 +----- src/ui/gui/split-file-dialog.c | 17 +---- .../gui/t-test-independent-samples-dialog.c | 18 +----- src/ui/gui/t-test-one-sample.c | 20 +----- src/ui/gui/t-test-paired-samples.c | 17 +---- src/ui/gui/text-data-import-dialog.c | 62 ++++++++----------- src/ui/gui/text-data-import-dialog.h | 6 +- src/ui/gui/transpose-dialog.c | 12 +--- src/ui/gui/variable-info-dialog.c | 3 +- src/ui/gui/weight-cases-dialog.c | 17 +---- 36 files changed, 152 insertions(+), 498 deletions(-) diff --git a/src/ui/gui/aggregate-dialog.c b/src/ui/gui/aggregate-dialog.c index 9ab455aa..ced6a32c 100644 --- a/src/ui/gui/aggregate-dialog.c +++ b/src/ui/gui/aggregate-dialog.c @@ -17,7 +17,6 @@ #include #include "dialog-common.h" -#include #include @@ -591,22 +590,10 @@ aggregate_dialog (PsppireDataWindow *dw) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&fd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&fd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&fd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&fd))); break; default: break; diff --git a/src/ui/gui/binomial-dialog.c b/src/ui/gui/binomial-dialog.c index 130c3dd6..256b3252 100644 --- a/src/ui/gui/binomial-dialog.c +++ b/src/ui/gui/binomial-dialog.c @@ -18,8 +18,6 @@ #include "binomial-dialog.h" -#include - #include "psppire-dialog.h" #include "psppire-var-view.h" #include "psppire-acr.h" @@ -187,21 +185,10 @@ binomial_dialog (PsppireDataWindow *dw) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&bin_d); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&bin_d))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&bin_d); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&bin_d))); break; default: break; diff --git a/src/ui/gui/chi-square-dialog.c b/src/ui/gui/chi-square-dialog.c index 6bb42e47..ccfa48ec 100644 --- a/src/ui/gui/chi-square-dialog.c +++ b/src/ui/gui/chi-square-dialog.c @@ -18,8 +18,6 @@ #include "chi-square-dialog.h" -#include - #include "psppire-dialog.h" #include "psppire-var-view.h" #include "psppire-acr.h" @@ -230,21 +228,10 @@ chisquare_dialog (PsppireDataWindow *dw) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&csd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&csd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&csd); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&csd))); break; default: break; diff --git a/src/ui/gui/comments-dialog.c b/src/ui/gui/comments-dialog.c index 306e3b40..78cc74de 100644 --- a/src/ui/gui/comments-dialog.c +++ b/src/ui/gui/comments-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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 @@ -20,7 +20,6 @@ #include "helper.h" #include "psppire-data-window.h" #include "psppire-data-editor.h" -#include #include "executor.h" #include "psppire-var-store.h" #include @@ -164,23 +163,10 @@ comments_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&cd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&cd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&cd); - - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&cd))); break; default: break; diff --git a/src/ui/gui/compute-dialog.c b/src/ui/gui/compute-dialog.c index 1154b512..89a64563 100644 --- a/src/ui/gui/compute-dialog.c +++ b/src/ui/gui/compute-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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 @@ -27,7 +27,6 @@ #include #include -#include #include "executor.h" static void function_list_populate (GtkTreeView *tv); @@ -435,23 +434,10 @@ compute_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&scd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&scd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&scd); - - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&scd))); break; default: break; diff --git a/src/ui/gui/correlation-dialog.c b/src/ui/gui/correlation-dialog.c index afc23447..e0dfd89f 100644 --- a/src/ui/gui/correlation-dialog.c +++ b/src/ui/gui/correlation-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009 Free Software Foundation + Copyright (C) 2009, 2010 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 @@ -17,7 +17,6 @@ #include #include "dialog-common.h" -#include #include #include @@ -118,22 +117,10 @@ correlation_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&rd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&rd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&rd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&rd))); break; default: break; diff --git a/src/ui/gui/crosstabs-dialog.c b/src/ui/gui/crosstabs-dialog.c index 7d94e375..d3903437 100644 --- a/src/ui/gui/crosstabs-dialog.c +++ b/src/ui/gui/crosstabs-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008 Free Software Foundation + Copyright (C) 2008, 2010 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 @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -464,23 +463,10 @@ crosstabs_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&cd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&cd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&cd); - - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&cd))); break; default: break; diff --git a/src/ui/gui/descriptives-dialog.c b/src/ui/gui/descriptives-dialog.c index 5a774902..ef772468 100644 --- a/src/ui/gui/descriptives-dialog.c +++ b/src/ui/gui/descriptives-dialog.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -258,21 +257,10 @@ descriptives_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&scd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&scd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&scd); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&scd))); break; default: break; diff --git a/src/ui/gui/examine-dialog.c b/src/ui/gui/examine-dialog.c index 87a048ac..931c0461 100644 --- a/src/ui/gui/examine-dialog.c +++ b/src/ui/gui/examine-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2008, 2009 Free Software Foundation + Copyright (C) 2007, 2008, 2009, 2010 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 @@ -22,7 +22,6 @@ #include #include -#include #include #include #include @@ -301,22 +300,10 @@ examine_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&ex_d); - - struct getl_interface *sss = create_syntax_string_source (syntax); - - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&ex_d))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&ex_d); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&ex_d))); break; default: break; diff --git a/src/ui/gui/executor.c b/src/ui/gui/executor.c index 7b4d10cf..24b80db2 100644 --- a/src/ui/gui/executor.c +++ b/src/ui/gui/executor.c @@ -16,15 +16,18 @@ #include -#include "executor.h" -#include "psppire-data-store.h" -#include -#include -#include -#include -#include -#include -#include "psppire-output-window.h" +#include "ui/gui/executor.h" + +#include "data/lazy-casereader.h" +#include "data/procedure.h" +#include "language/command.h" +#include "language/lexer/lexer.h" +#include "language/syntax-string-source.h" +#include "libpspp/cast.h" +#include "libpspp/getl.h" +#include "output/driver.h" +#include "ui/gui/psppire-data-store.h" +#include "ui/gui/psppire-output-window.h" extern struct dataset *the_dataset; extern struct source_stream *the_source_stream; @@ -108,3 +111,19 @@ execute_syntax (struct getl_interface *sss) return retval; } + +/* Executes null-terminated string SYNTAX as syntax. + Returns SYNTAX. */ +gchar * +execute_syntax_string (gchar *syntax) +{ + execute_const_syntax_string (syntax); + return syntax; +} + +/* Executes null-terminated string SYNTAX as syntax. */ +void +execute_const_syntax_string (const gchar *syntax) +{ + execute_syntax (create_syntax_string_source (syntax)); +} diff --git a/src/ui/gui/executor.h b/src/ui/gui/executor.h index 40925bee..81ece2b8 100644 --- a/src/ui/gui/executor.h +++ b/src/ui/gui/executor.h @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2009 Free Software Foundation + Copyright (C) 2007, 2009, 2010 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 @@ -23,6 +23,7 @@ struct getl_interface; gboolean execute_syntax (struct getl_interface *sss); - +gchar *execute_syntax_string (gchar *syntax); +void execute_const_syntax_string (const gchar *syntax); #endif diff --git a/src/ui/gui/factor-dialog.c b/src/ui/gui/factor-dialog.c index 61427cc2..e0b9f4fa 100644 --- a/src/ui/gui/factor-dialog.c +++ b/src/ui/gui/factor-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009 Free Software Foundation + Copyright (C) 2009, 2010 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 @@ -17,7 +17,6 @@ #include #include "dialog-common.h" -#include #include #include @@ -400,22 +399,10 @@ factor_dialog (PsppireDataWindow *dw) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&fd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&fd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&fd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&fd))); break; default: break; diff --git a/src/ui/gui/frequencies-dialog.c b/src/ui/gui/frequencies-dialog.c index 2bbb5546..3378d819 100644 --- a/src/ui/gui/frequencies-dialog.c +++ b/src/ui/gui/frequencies-dialog.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -570,21 +569,10 @@ frequencies_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&fd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&fd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&fd); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&fd))); break; default: break; diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index 1ad77bc9..a68c0c2b 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -282,8 +282,8 @@ on_delete (GtkWindow *window, GdkEvent *e, GtkWindow **addr) return FALSE; } -void -paste_syntax_to_window (const gchar *syntax) +char * +paste_syntax_to_window (gchar *syntax) { static GtkWidget *the_syntax_pasteboard = NULL; @@ -304,6 +304,8 @@ paste_syntax_to_window (const gchar *syntax) gtk_text_buffer_end_user_action (buffer); gtk_widget_show (the_syntax_pasteboard); + + return syntax; } diff --git a/src/ui/gui/helper.h b/src/ui/gui/helper.h index 77abc1d8..f7660dc4 100644 --- a/src/ui/gui/helper.h +++ b/src/ui/gui/helper.h @@ -29,7 +29,7 @@ #include "gl/configmake.h" -void paste_syntax_to_window (const gchar *syntax); +gchar *paste_syntax_to_window (gchar *syntax); struct fmt_spec; diff --git a/src/ui/gui/k-related-dialog.c b/src/ui/gui/k-related-dialog.c index 1f5d382a..c7f48a9b 100644 --- a/src/ui/gui/k-related-dialog.c +++ b/src/ui/gui/k-related-dialog.c @@ -18,8 +18,6 @@ #include "k-related-dialog.h" -#include - #include "psppire-dialog.h" #include "psppire-var-view.h" #include "psppire-acr.h" @@ -162,21 +160,10 @@ k_related_dialog (PsppireDataWindow *dw) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&krd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&krd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&krd); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&krd))); break; default: break; diff --git a/src/ui/gui/oneway-anova-dialog.c b/src/ui/gui/oneway-anova-dialog.c index 0d6f5aa5..9919a598 100644 --- a/src/ui/gui/oneway-anova-dialog.c +++ b/src/ui/gui/oneway-anova-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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 @@ -29,7 +29,6 @@ #include "psppire-selector.h" #include "dict-display.h" -#include #include "executor.h" @@ -211,22 +210,10 @@ oneway_anova_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&ow); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&ow))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&ow); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&ow))); break; default: break; diff --git a/src/ui/gui/psppire-data-editor.c b/src/ui/gui/psppire-data-editor.c index 036b9b77..094a4f69 100644 --- a/src/ui/gui/psppire-data-editor.c +++ b/src/ui/gui/psppire-data-editor.c @@ -21,7 +21,6 @@ #include "psppire-data-editor.h" #include "psppire-var-sheet.h" -#include #include "psppire-data-store.h" #include #include @@ -1249,21 +1248,13 @@ popup_cases_menu (PsppireSheet *sheet, gint row, static void do_sort (PsppireDataStore *ds, int var, gboolean descend) { - GString *string = g_string_new ("SORT CASES BY "); - const struct variable *v = psppire_dict_get_variable (ds->dict, var); + gchar *syntax; - g_string_append_printf (string, "%s", var_get_name (v)); - - if ( descend ) - g_string_append (string, " (D)"); - - g_string_append (string, "."); - - execute_syntax (create_syntax_string_source (string->str)); - - g_string_free (string, TRUE); + syntax = g_strdup_printf ("SORT CASES BY %s%s.", + var_get_name (v), descend ? " (D)" : ""); + g_free (execute_syntax_string (syntax)); } diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index e024fb94..b01582bb 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -187,9 +187,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 @@ -503,9 +501,9 @@ save_file (PsppireWindow *w) gchar *native_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); @@ -529,20 +527,13 @@ save_file (PsppireWindow *w) syntax_gen_string (&filename, ss_cstr (native_file_name)); g_free (native_file_name); - if ( de->save_as_portable ) - { - sss = create_syntax_format_source ("EXPORT OUTFILE=%s.", - ds_cstr (&filename)); - } - else - { - sss = create_syntax_format_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)); } @@ -562,11 +553,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 @@ -577,22 +564,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 *syntax; + ds_init_empty (&filename); syntax_gen_string (&filename, ss_cstr (native_file_name)); g_free (native_file_name); - sss = create_syntax_format_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); @@ -703,11 +690,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); } diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 621814cd..bb6006d1 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -134,7 +134,7 @@ initialize (struct source_stream *ss, const char *data_file) if (data_file != NULL) load_data_file (data_file); - execute_syntax (create_syntax_string_source ("")); + execute_const_syntax_string (""); gtk_widget_show (the_data_window); } diff --git a/src/ui/gui/rank-dialog.c b/src/ui/gui/rank-dialog.c index fa998b47..a092cab7 100644 --- a/src/ui/gui/rank-dialog.c +++ b/src/ui/gui/rank-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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,7 +21,6 @@ #include #include -#include #include #include #include @@ -322,21 +321,10 @@ rank_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&rd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&rd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&rd); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&rd))); break; default: break; diff --git a/src/ui/gui/recode-dialog.c b/src/ui/gui/recode-dialog.c index 27f69725..8c44c444 100644 --- a/src/ui/gui/recode-dialog.c +++ b/src/ui/gui/recode-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2009 Free Software Foundation + Copyright (C) 2007, 2009, 2010 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 @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -1060,22 +1059,10 @@ recode_dialog (PsppireDataWindow *de, gboolean diff) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&rd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&rd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&rd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&rd))); break; default: break; diff --git a/src/ui/gui/regression-dialog.c b/src/ui/gui/regression-dialog.c index d6997f74..062d69e4 100644 --- a/src/ui/gui/regression-dialog.c +++ b/src/ui/gui/regression-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008 Free Software Foundation + Copyright (C) 2008, 2010 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 @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -288,22 +287,10 @@ regression_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&rd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&rd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&rd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&rd))); break; default: break; diff --git a/src/ui/gui/reliability-dialog.c b/src/ui/gui/reliability-dialog.c index 957d9e11..431a9c0e 100644 --- a/src/ui/gui/reliability-dialog.c +++ b/src/ui/gui/reliability-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009 Free Software Foundation + Copyright (C) 2009, 2010 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 @@ -17,7 +17,6 @@ #include #include "dialog-common.h" -#include #include "reliability-dialog.h" #include "psppire-selector.h" #include "psppire-dictview.h" @@ -167,22 +166,10 @@ reliability_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&rd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&rd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&rd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&rd))); break; default: break; diff --git a/src/ui/gui/roc-dialog.c b/src/ui/gui/roc-dialog.c index 45972d54..2e57830a 100644 --- a/src/ui/gui/roc-dialog.c +++ b/src/ui/gui/roc-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2009 Free Software Foundation + Copyright (C) 2009, 2010 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 @@ -17,7 +17,6 @@ #include #include "dialog-common.h" -#include #include #include @@ -162,22 +161,10 @@ roc_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&rd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&rd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&rd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&rd))); break; default: break; diff --git a/src/ui/gui/select-cases-dialog.c b/src/ui/gui/select-cases-dialog.c index 0f50c91a..04fcf0dd 100644 --- a/src/ui/gui/select-cases-dialog.c +++ b/src/ui/gui/select-cases-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 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 @@ -25,7 +25,6 @@ #include "dict-display.h" #include "dialog-common.h" #include "widget-io.h" -#include #include "helper.h" #include @@ -348,22 +347,10 @@ select_cases_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&scd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&scd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&scd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&scd))); break; default: break; diff --git a/src/ui/gui/sort-cases-dialog.c b/src/ui/gui/sort-cases-dialog.c index 8252e320..50624ad0 100644 --- a/src/ui/gui/sort-cases-dialog.c +++ b/src/ui/gui/sort-cases-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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 @@ -26,7 +26,6 @@ #include "dict-display.h" #include "psppire-var-view.h" -#include #include "helper.h" static void @@ -129,22 +128,10 @@ sort_cases_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&scd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&scd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&scd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&scd))); break; default: break; diff --git a/src/ui/gui/split-file-dialog.c b/src/ui/gui/split-file-dialog.c index 1748651a..9aacdffd 100644 --- a/src/ui/gui/split-file-dialog.c +++ b/src/ui/gui/split-file-dialog.c @@ -22,7 +22,6 @@ #include "executor.h" #include "psppire-data-window.h" #include "dict-display.h" -#include #include "helper.h" #include @@ -200,22 +199,10 @@ split_file_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&sfd); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&sfd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&sfd); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&sfd))); break; default: break; diff --git a/src/ui/gui/t-test-independent-samples-dialog.c b/src/ui/gui/t-test-independent-samples-dialog.c index 93102c05..2da218e5 100644 --- a/src/ui/gui/t-test-independent-samples-dialog.c +++ b/src/ui/gui/t-test-independent-samples-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2009 Free Software Foundation + Copyright (C) 2007, 2009, 2010 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 @@ -31,7 +31,6 @@ #include "t-test-options.h" #include -#include #include "helper.h" #include @@ -455,21 +454,10 @@ t_test_independent_samples_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&tt_d); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&tt_d))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&tt_d); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&tt_d))); break; default: break; diff --git a/src/ui/gui/t-test-one-sample.c b/src/ui/gui/t-test-one-sample.c index ea92a921..79168714 100644 --- a/src/ui/gui/t-test-one-sample.c +++ b/src/ui/gui/t-test-one-sample.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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 @@ -31,7 +31,6 @@ #include "executor.h" #include "t-test-options.h" -#include #include #define _(msgid) gettext (msgid) @@ -166,23 +165,10 @@ t_test_one_sample_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&tt_d); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&tt_d))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&tt_d); - - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&tt_d))); break; default: break; diff --git a/src/ui/gui/t-test-paired-samples.c b/src/ui/gui/t-test-paired-samples.c index 5f226d4e..1b1c2511 100644 --- a/src/ui/gui/t-test-paired-samples.c +++ b/src/ui/gui/t-test-paired-samples.c @@ -17,7 +17,6 @@ #include #include -#include #include "psppire-data-window.h" #include "psppire-selector.h" @@ -210,22 +209,10 @@ t_test_paired_samples_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&tt_d); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&tt_d))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&tt_d); - paste_syntax_to_window (syntax); - - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&tt_d))); break; default: break; diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 4db2d8ca..8eb4f3c7 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -16,39 +16,37 @@ #include -#include - - -#include "widget-io.h" -#include "checkbox-treeview.h" -#include "descriptives-dialog.h" +#include "ui/gui/text-data-import-dialog.h" #include - #include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "executor.h" - -#include "error.h" -#include "xalloc.h" +#include "data/data-in.h" +#include "data/data-out.h" +#include "data/format-guesser.h" +#include "data/value-labels.h" +#include "language/data-io/data-parser.h" +#include "language/lexer/lexer.h" +#include "libpspp/assertion.h" +#include "libpspp/message.h" +#include "ui/gui/checkbox-treeview.h" +#include "ui/gui/descriptives-dialog.h" +#include "ui/gui/dialog-common.h" +#include "ui/gui/executor.h" +#include "ui/gui/helper.h" +#include "ui/gui/psppire-data-window.h" +#include "ui/gui/psppire-dialog.h" +#include "ui/gui/psppire-var-sheet.h" +#include "ui/gui/psppire-var-store.h" +#include "ui/gui/widget-io.h" +#include "ui/syntax-gen.h" + +#include "gl/error.h" +#include "gl/xalloc.h" #include "gettext.h" #define _(msgid) gettext (msgid) @@ -259,18 +257,10 @@ text_data_import_assistant (GtkWindow *parent_window) switch (ia->asst.response) { case GTK_RESPONSE_APPLY: - { - char *syntax = generate_syntax (ia); - execute_syntax (create_syntax_string_source (syntax)); - free (syntax); - } + free (execute_syntax_string (generate_syntax (ia))); break; case PSPPIRE_RESPONSE_PASTE: - { - char *syntax = generate_syntax (ia); - paste_syntax_to_window (syntax); - free (syntax); - } + free (paste_syntax_to_window (generate_syntax (ia))); break; default: break; diff --git a/src/ui/gui/text-data-import-dialog.h b/src/ui/gui/text-data-import-dialog.h index f770dfac..1aeaee98 100644 --- a/src/ui/gui/text-data-import-dialog.h +++ b/src/ui/gui/text-data-import-dialog.h @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2008 Free Software Foundation + Copyright (C) 2008, 2010 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 @@ -17,8 +17,8 @@ #ifndef TEXT_DATA_IMPORT_DIALOG_H #define TEXT_DATA_IMPORT_DIALOG_H -#include +#include -void text_data_import_assistant (GObject *o, gpointer data); +void text_data_import_assistant (GtkWindow *parent_window); #endif diff --git a/src/ui/gui/transpose-dialog.c b/src/ui/gui/transpose-dialog.c index ebc34bd8..c2169a53 100644 --- a/src/ui/gui/transpose-dialog.c +++ b/src/ui/gui/transpose-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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 @@ -23,7 +23,6 @@ #include "executor.h" #include "psppire-data-window.h" #include "dict-display.h" -#include #include "helper.h" #include "dialog-common.h" @@ -111,14 +110,7 @@ transpose_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (dict, xml); - - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (dict, xml))); break; case PSPPIRE_RESPONSE_PASTE: { diff --git a/src/ui/gui/variable-info-dialog.c b/src/ui/gui/variable-info-dialog.c index 16a5f462..d0b3eeae 100644 --- a/src/ui/gui/variable-info-dialog.c +++ b/src/ui/gui/variable-info-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007, 2009 Free Software Foundation + Copyright (C) 2007, 2009, 2010 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 @@ -20,7 +20,6 @@ #include #include #include -#include #include #include "variable-info-dialog.h" diff --git a/src/ui/gui/weight-cases-dialog.c b/src/ui/gui/weight-cases-dialog.c index fc50aea9..066c5e54 100644 --- a/src/ui/gui/weight-cases-dialog.c +++ b/src/ui/gui/weight-cases-dialog.c @@ -1,5 +1,5 @@ /* PSPPIRE - a graphical user interface for PSPP. - Copyright (C) 2007 Free Software Foundation + Copyright (C) 2007, 2010 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 @@ -22,7 +22,6 @@ #include "executor.h" #include "psppire-data-window.h" #include "dict-display.h" -#include #include "helper.h" #include @@ -153,20 +152,10 @@ weight_cases_dialog (PsppireDataWindow *de) switch (response) { case GTK_RESPONSE_OK: - { - gchar *syntax = generate_syntax (&wcd); - struct getl_interface *sss = create_syntax_string_source (syntax); - execute_syntax (sss); - - g_free (syntax); - } + g_free (execute_syntax_string (generate_syntax (&wcd))); break; case PSPPIRE_RESPONSE_PASTE: - { - gchar *syntax = generate_syntax (&wcd); - paste_syntax_to_window (syntax); - g_free (syntax); - } + g_free (paste_syntax_to_window (generate_syntax (&wcd))); break; default: break; -- 2.30.2