On Mon, Jun 11, 2007 at 09:34:54PM -0700, Ben Pfaff wrote:

     The model I was envisioning was this.  The GUI would interact
     primarily with a datasheet and a dictionary.  The GUI-datasheet
     shows what's in the struct datasheet, the dialog boxes work
     mostly with the dictionary, and so on.  Then, when the user told
     the GUI to do something that needed a procedure or other syntax
     to be run, the datasheet would be destructively transformed into
     a casereader with datasheet_make_reader, the casereader would be
     put into a dataset, the syntax would be run, and then the
     casereader would be extracted from the dataset and destructively
     transformed into a struct datasheet, which becomes what the GUI
     works with until the next bit of syntax needs to get run.
     
That's exactly what I had in mind too. (I keep pondering if it might
be a good idea to have the datasheet persist throughout the procedure,
and the GUI updates concurrently as the data's being written, but
that's something to be done in the future, if at all.)

The attached patch does something almost exactly what you describe. It
differs in that it uses the replace_datasheet callback instead of
waiting to the end of the procedure (this can probably change; I'm not
sure if the callbacks to struct dataset are really necessary anymore).

It also differs from your described model in that it uses
casereader_clone (inside psppire_case_file_new) to create the
datasheet.  It's not currently possible to do exactly as you describe,
since the first thing that proc_set_active_file_data does is to
destroy the existing reader, so passing that reader straight to
create_dataset would destroy it again ....

Anyway, see if you can improve on this patch.  I've noticed that FILE
NEW causes problems, and there may be a few other glitches too.  I
haven't yet fully satisfied myself that all the datasheets and
casereaders are being destroyed either.

J'



-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


? g.patch
? libtool
? p.patch
? x.patch
? y.patch
? doc/.dirstamp
? glade/.deps
? lib/gsl-extras/.deps
? lib/gsl-extras/.dirstamp
? lib/gtksheet/.deps
? lib/gtksheet/.dirstamp
? lib/linreg/.deps
? lib/linreg/.dirstamp
? src/data/.deps
? src/data/.dirstamp
? src/language/.deps
? src/language/.dirstamp
? src/language/control/.deps
? src/language/control/.dirstamp
? src/language/data-io/.deps
? src/language/data-io/.dirstamp
? src/language/dictionary/.deps
? src/language/dictionary/.dirstamp
? src/language/expressions/.deps
? src/language/expressions/.dirstamp
? src/language/lexer/.deps
? src/language/lexer/.dirstamp
? src/language/stats/.deps
? src/language/stats/.dirstamp
? src/language/tests/.deps
? src/language/tests/.dirstamp
? src/language/tests/check-model.c
? src/language/utilities/.deps
? src/language/utilities/.dirstamp
? src/language/xforms/.deps
? src/language/xforms/.dirstamp
? src/libpspp/.deps
? src/libpspp/.dirstamp
? src/math/.deps
? src/math/.dirstamp
? src/math/linreg/.deps
? src/math/linreg/.dirstamp
? src/math/ts/.deps
? src/math/ts/.dirstamp
? src/output/.deps
? src/output/.dirstamp
? src/output/charts/.deps
? src/output/charts/.dirstamp
? src/ui/.deps
? src/ui/.dirstamp
? src/ui/gui/.deps
? src/ui/gui/.dirstamp
? src/ui/gui/.libs
? src/ui/gui/libpsppire.la
? src/ui/gui/src_ui_gui_libpsppire_la-glade-register.lo
? src/ui/terminal/.deps
? src/ui/terminal/.dirstamp
? tests/formats/.deps
? tests/formats/.dirstamp
? tests/libpspp/.deps
? tests/libpspp/.dirstamp
Index: src/ui/gui/helper.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/helper.c,v
retrieving revision 1.18
diff -b -w -U 3 -r1.18 helper.c
--- src/ui/gui/helper.c	7 Jun 2007 06:42:06 -0000	1.18
+++ src/ui/gui/helper.c	12 Jun 2007 04:33:01 -0000
@@ -170,6 +170,10 @@
 {
   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,8 +193,8 @@
   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. */
+     every script.  Otherwise commands like GET could leave the GUI
+     without a datasheet. */
   return proc_execute (the_dataset);
 }
 
Index: src/ui/gui/psppire-case-file.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-case-file.c,v
retrieving revision 1.20
diff -b -w -U 3 -r1.20 psppire-case-file.c
--- src/ui/gui/psppire-case-file.c	12 Jun 2007 01:59:00 -0000	1.20
+++ src/ui/gui/psppire-case-file.c	12 Jun 2007 04:33:01 -0000
@@ -28,6 +28,7 @@
 #include <data/case.h>
 #include <data/data-in.h>
 #include <data/datasheet.h>
+#include <data/casereader.h>
 #include <math/sort.h>
 #include <libpspp/misc.h>
 
@@ -154,11 +155,11 @@
  * 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;
@@ -247,9 +248,10 @@
 {
   bool allocated;
 
-  g_return_val_if_fail (cf, false);
-  g_return_val_if_fail (cf->datasheet, false);
+  g_return_val_if_fail (cf, NULL);
+  g_return_val_if_fail (cf->datasheet, NULL);
 
+  g_return_val_if_fail (cf->accessible, NULL);
   g_return_val_if_fail (idx < datasheet_get_column_cnt (cf->datasheet), false);
 
   if (value == NULL)
Index: src/ui/gui/psppire-case-file.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-case-file.h,v
retrieving revision 1.13
diff -b -w -U 3 -r1.13 psppire-case-file.h
--- src/ui/gui/psppire-case-file.h	12 Jun 2007 01:59:00 -0000	1.13
+++ src/ui/gui/psppire-case-file.h	12 Jun 2007 04:33:01 -0000
@@ -70,7 +70,7 @@
 /* -- 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 @@
 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__ */
Index: src/ui/gui/psppire-data-store.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-data-store.c,v
retrieving revision 1.36
diff -b -w -U 3 -r1.36 psppire-data-store.c
--- src/ui/gui/psppire-data-store.c	12 Jun 2007 01:59:00 -0000	1.36
+++ src/ui/gui/psppire-data-store.c	12 Jun 2007 04:33:01 -0000
@@ -686,6 +686,18 @@
 
 
 
+/* 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 @@
   iface->get_button_label = geometry_get_row_button_label;
 }
 
+
+
Index: src/ui/gui/psppire-data-store.h
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/psppire-data-store.h,v
retrieving revision 1.9
diff -b -w -U 3 -r1.9 psppire-data-store.h
--- src/ui/gui/psppire-data-store.h	12 Jun 2007 01:59:00 -0000	1.9
+++ src/ui/gui/psppire-data-store.h	12 Jun 2007 04:33:01 -0000
@@ -106,6 +106,9 @@
 gboolean psppire_data_store_insert_new_case (PsppireDataStore *ds, gint posn);
 
 
+struct casereader * psppire_data_store_get_reader (PsppireDataStore *ds);
+
+
 
 #ifdef __cplusplus
 }

Attachment: signature.asc
Description: Digital signature

_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev

Reply via email to