Made the text import dialogs sort of work again
[pspp] / src / ui / gui / text-data-import-dialog.c
index 22425b96ab58c52c45c8defebee9baa38016d838..ab7d743b1dad384d81d7d733547af426277cc070 100644 (file)
 
 #include "ui/gui/text-data-import-dialog.h"
 
+#include "page-intro.h"
+#include "page-sheet-spec.h"
+#include "page-first-line.h"
+#include "page-separators.h"
+#include "page-formats.h"
+
 #include <errno.h>
 #include <fcntl.h>
 #include <gtk-contrib/psppire-sheet.h>
@@ -72,7 +78,6 @@ text_data_import_assistant (PsppireDataWindow *dw)
 {
   GtkWindow *parent_window = GTK_WINDOW (dw);
   struct import_assistant *ia = init_assistant (parent_window);
-  GtkBuilder *builder = ia->asst.builder;
   struct sheet_spec_page *ssp ;
 
   if (!init_file (ia, parent_window))
@@ -92,6 +97,8 @@ text_data_import_assistant (PsppireDataWindow *dw)
       ia->intro = intro_page_create (ia);
       ia->separators = separators_page_create (ia);
       ia->first_line = first_line_page_create (ia);
+
+      printf ("%s:%d %p\n", __FILE__, __LINE__, ia->intro);
     }
   ia->formats = formats_page_create (ia);
 
@@ -214,11 +221,8 @@ generate_syntax (const struct import_assistant *ia)
 {
   struct string s = DS_EMPTY_INITIALIZER;
 
-#if 0
-  if (ssp->spreadsheet == NULL)
+  if (ia->spreadsheet == NULL)
     {
-      size_t var_cnt;
-      size_t i;
       syntax_gen_pspp (&s,
                       "GET DATA"
                       "\n  /TYPE=TXT"
@@ -227,11 +231,14 @@ generate_syntax (const struct import_assistant *ia)
       if (ia->file.encoding && strcmp (ia->file.encoding, "Auto"))
        syntax_gen_pspp (&s, "  /ENCODING=%sq\n", ia->file.encoding);
 
+#if 0
       intro_append_syntax (ia->intro, &s);
 
       ds_put_cstr (&s,
                   "  /ARRANGEMENT=DELIMITED\n"
                   "  /DELCASE=LINE\n");
+
+
       if (ia->first_line->skip_lines > 0)
        ds_put_format (&s, "  /FIRSTCASE=%d\n", ia->first_line->skip_lines + 1);
       ds_put_cstr (&s, "  /DELIMITERS=\"");
@@ -265,42 +272,15 @@ generate_syntax (const struct import_assistant *ia)
                         i == var_cnt - 1 ? "." : "");
        }
 
+
       apply_dict (ia->formats->dict, &s);
+#endif
     }
   else
-
     {
-      const struct sheet_spec_page *ssp = ia->sheet_spec;
-
-      syntax_gen_pspp (&s,
-                      "GET DATA"
-                      "\n  /TYPE=%ss"
-                      "\n  /FILE=%sq"
-                      "\n  /SHEET=index %d"
-                      "\n  /READNAMES=%ss",
-                      (ssp->spreadsheet->type == SPREADSHEET_GNUMERIC) ? "GNM" : "ODS",
-                      ia->file.file_name,                       
-                      ssp->opts.sheet_index,
-                      ssp->sri.read_names ? "ON" : "OFF");
-
-
-      if ( ssp->opts.cell_range)
-       {
-         syntax_gen_pspp (&s,
-                          "\n  /CELLRANGE=RANGE %sq",
-                          ssp->opts.cell_range);
-       }
-      else
-       {
-         syntax_gen_pspp (&s,
-                          "\n  /CELLRANGE=FULL");
-       }
-
-
-      syntax_gen_pspp (&s, ".");
+      return sheet_spec_gen_syntax (ia);
     }
 
-#endif
   return ds_cstr (&s);
 }