From: John Darrington Date: Fri, 15 Jun 2007 01:24:28 +0000 (+0000) Subject: Fixed procedure execution in GUI. X-Git-Tag: v0.6.0~427 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d908f52b818f4fdf2ab23797756812ec2986bd2b;p=pspp-builds.git Fixed procedure execution in GUI. --- diff --git a/src/data/casereader.c b/src/data/casereader.c index 1baeef5d..3c062d90 100644 --- a/src/data/casereader.c +++ b/src/data/casereader.c @@ -97,6 +97,8 @@ casereader_clone (const struct casereader *reader_) { struct casereader *reader = (struct casereader *) reader_; struct casereader *clone; + if ( reader == NULL ) + return NULL; if (reader->class->clone == NULL) insert_shim (reader); diff --git a/src/data/procedure.c b/src/data/procedure.c index 0741b1cc..14b2ccdf 100644 --- a/src/data/procedure.c +++ b/src/data/procedure.c @@ -700,6 +700,12 @@ dataset_dict (const struct dataset *ds) return ds->dict; } +const struct casereader * +dataset_source (const struct dataset *ds) +{ + return ds->source; +} + void dataset_need_lag (struct dataset *ds, int n_before) { diff --git a/src/data/procedure.h b/src/data/procedure.h index 2d79d425..ba91e377 100644 --- a/src/data/procedure.h +++ b/src/data/procedure.h @@ -77,6 +77,8 @@ bool proc_commit (struct dataset *); bool dataset_end_of_command (struct dataset *); struct dictionary *dataset_dict (const struct dataset *ds); +const struct casereader *dataset_source (const struct dataset *ds); + struct ccase *lagged_case (const struct dataset *ds, int n_before); void dataset_need_lag (struct dataset *ds, int n_before); diff --git a/src/ui/gui/helper.c b/src/ui/gui/helper.c index f8e3ddba..b5822981 100644 --- a/src/ui/gui/helper.c +++ b/src/ui/gui/helper.c @@ -168,8 +168,13 @@ extern PsppireDataStore *the_data_store; gboolean execute_syntax (struct getl_interface *sss) { + gboolean status; struct lexer *lexer; + struct casereader *reader = psppire_data_store_get_reader (the_data_store); + + proc_set_active_file_data (the_dataset, reader); + g_return_val_if_fail (proc_has_active_file (the_dataset), FALSE); lexer = lex_create (the_source_stream); @@ -189,9 +194,20 @@ execute_syntax (struct getl_interface *sss) lex_destroy (lexer); /* GUI syntax needs this implicit EXECUTE command at the end of - every script. Otherwise commands like GET could leave the GUI without - a casefile. */ - return proc_execute (the_dataset); + every script. Otherwise commands like GET could leave the GUI + without a datasheet. */ + status = proc_execute (the_dataset); + + psppire_dict_replace_dictionary (the_data_store->dict, + dataset_dict (the_dataset)); + + { + PsppireCaseFile *pcf = psppire_case_file_new (dataset_source (the_dataset)); + + psppire_data_store_set_case_file (the_data_store, pcf); + } + + return status; } diff --git a/src/ui/gui/psppire-case-file.c b/src/ui/gui/psppire-case-file.c index 15626633..215eecc5 100644 --- a/src/ui/gui/psppire-case-file.c +++ b/src/ui/gui/psppire-case-file.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -93,7 +94,7 @@ psppire_case_file_class_init (PsppireCaseFileClass *class) object_class->finalize = psppire_case_file_finalize; signals [CASE_CHANGED] = - g_signal_new ("case_changed", + g_signal_new ("case-changed", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_FIRST, 0, @@ -105,7 +106,7 @@ psppire_case_file_class_init (PsppireCaseFileClass *class) signals [CASE_INSERTED] = - g_signal_new ("case_inserted", + g_signal_new ("case-inserted", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_FIRST, 0, @@ -117,7 +118,7 @@ psppire_case_file_class_init (PsppireCaseFileClass *class) signals [CASES_DELETED] = - g_signal_new ("cases_deleted", + g_signal_new ("cases-deleted", G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_FIRST, 0, @@ -154,11 +155,11 @@ psppire_case_file_init (PsppireCaseFile *cf) * Creates a new #PsppireCaseFile. */ PsppireCaseFile* -psppire_case_file_new (struct casereader *reader) +psppire_case_file_new (const struct casereader *reader) { PsppireCaseFile *cf = g_object_new (G_TYPE_PSPPIRE_CASE_FILE, NULL); - cf->datasheet = datasheet_create (reader); + cf->datasheet = datasheet_create (casereader_clone (reader)); cf->accessible = TRUE; return cf; @@ -320,7 +321,7 @@ psppire_case_file_data_in (PsppireCaseFile *cf, gint casenum, gint idx, if (ok) g_signal_emit (cf, signals [CASE_CHANGED], 0, casenum); - freesa (value); + freea (value); return TRUE; } diff --git a/src/ui/gui/psppire-case-file.h b/src/ui/gui/psppire-case-file.h index f274624f..98ce6e9c 100644 --- a/src/ui/gui/psppire-case-file.h +++ b/src/ui/gui/psppire-case-file.h @@ -70,7 +70,7 @@ struct _PsppireCaseFileClass /* -- PsppireCaseFile --- */ GType psppire_case_file_get_type (void); -PsppireCaseFile *psppire_case_file_new (struct casereader *); +PsppireCaseFile *psppire_case_file_new (const struct casereader *); gboolean psppire_case_file_insert_case (PsppireCaseFile *cf, struct ccase *c, gint row); @@ -105,6 +105,10 @@ void psppire_case_file_sort (PsppireCaseFile *cf, struct case_ordering *); gboolean psppire_case_file_get_case (const PsppireCaseFile *cf, gint casenum, struct ccase *c); + +struct casereader * psppire_case_file_make_reader (PsppireCaseFile *cf); + + G_END_DECLS #endif /* __PSPPIRE_CASE_FILE_H__ */ diff --git a/src/ui/gui/psppire-data-store.c b/src/ui/gui/psppire-data-store.c index f711162f..c7d94cee 100644 --- a/src/ui/gui/psppire-data-store.c +++ b/src/ui/gui/psppire-data-store.c @@ -686,6 +686,18 @@ psppire_data_store_clear (PsppireDataStore *data_store) +/* Return a casereader made from this datastore */ +struct casereader * +psppire_data_store_get_reader (PsppireDataStore *ds) +{ + struct casereader *reader ; + + reader = psppire_case_file_make_reader (ds->case_file); + + return reader; +} + + /* Column related funcs */ @@ -850,3 +862,5 @@ psppire_data_store_sheet_row_init (GSheetRowIface *iface) iface->get_button_label = geometry_get_row_button_label; } + + diff --git a/src/ui/gui/psppire-data-store.h b/src/ui/gui/psppire-data-store.h index 9b480c98..7e2067fd 100644 --- a/src/ui/gui/psppire-data-store.h +++ b/src/ui/gui/psppire-data-store.h @@ -106,6 +106,9 @@ void psppire_data_store_create_system_file (PsppireDataStore *store, gboolean psppire_data_store_insert_new_case (PsppireDataStore *ds, gint posn); +struct casereader * psppire_data_store_get_reader (PsppireDataStore *ds); + + #ifdef __cplusplus } diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index 20bc2fc3..30d1ad75 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -290,6 +290,8 @@ psppire_dict_replace_dictionary (PsppireDict *dict, struct dictionary *d) filter_changed_callback (d, var ? var_get_dict_index (var) : -1, dict); split_changed_callback (d, dict); + + dict_set_callbacks (dict->dict, &gui_callbacks, dict); } diff --git a/src/ui/gui/psppire.c b/src/ui/gui/psppire.c index 06b14887..bd123970 100644 --- a/src/ui/gui/psppire.c +++ b/src/ui/gui/psppire.c @@ -58,12 +58,6 @@ static void create_icon_factory (void); struct source_stream *the_source_stream ; struct dataset * the_dataset = NULL; -static void -replace_dictionary (struct dictionary *d) -{ - psppire_dict_replace_dictionary (the_data_store->dict, d); -} - static void replace_casereader (struct casereader *s) @@ -96,9 +90,7 @@ initialize (void) fn_getenv_default ("STAT_INCLUDE_PATH", include_path) ); - the_dataset = create_dataset (replace_casereader, - replace_dictionary); - + the_dataset = create_dataset (NULL, NULL); message_dialog_init (the_source_stream);