Whitespace changes only
[pspp] / src / ui / gui / text-data-import-dialog.h
index b23130d7f425174be4185108b5d6322ce520f9fb..9e13b65f0af233151835f1bfdad16ec921766976 100644 (file)
 
 #include <glib-object.h>
 #include "ui/gui/psppire-data-window.h"
+#include "data/spreadsheet-reader.h"
 
 #include "libpspp/str.h"
 
-enum file_type
-  {
-    FTYPE_TEXT,
-    FTYPE_SPREADSHEET
-  };
+enum { MAX_PREVIEW_LINES = 1000 }; /* Max number of lines to read. */
 
 /* The file to be imported. */
 struct file
   {
     char *file_name;        /* File name. */
 
-    enum file_type type;
-
     /* Relevant only for text files */
 
     gchar *encoding;        /* Encoding. */
@@ -52,6 +47,7 @@ struct assistant
     GtkBuilder *builder;
     GtkAssistant *assistant;
     GMainLoop *main_loop;
+    bool loop_done;
     GtkWidget *paste_button;
     GtkWidget *reset_button;
     int response;
@@ -61,86 +57,28 @@ struct assistant
     GtkCellRenderer *fixed_renderer;
   };
 
-
-/* The sheet_spec page of the assistant (only relevant for spreadsheet imports). */
-struct sheet_spec_page
-  {
-    GtkWidget *page;
-  };
-
-
-/* The introduction page of the assistant. */
-struct intro_page
-  {
-    GtkWidget *page;
-    GtkWidget *all_cases_button;
-    GtkWidget *n_cases_button;
-    GtkWidget *n_cases_spin;
-    GtkWidget *percent_button;
-    GtkWidget *percent_spin;
-  };
-
-/* Page where the user chooses the first line of data. */
-struct first_line_page
+struct import_assistant
   {
-    int skip_lines;    /* Number of initial lines to skip? */
-    bool variable_names; /* Variable names above first line of data? */
-
-    GtkWidget *page;
-    GtkTreeView *tree_view;
-    GtkWidget *variable_names_cb;
-  };
-
+    struct file file;
+    struct assistant asst;
 
-/* Page where the user chooses field separators. */
-struct separators_page
-  {
-    /* How to break lines into columns. */
-    struct string separators;   /* Field separators. */
-    struct string quotes;       /* Quote characters. */
-    bool escape;                /* Doubled quotes yield a quote mark? */
+    struct intro_page *intro;
+    struct sheet_spec_page *sheet_spec;
+    struct first_line_page *first_line;
+    struct separators_page *separators;
+    struct formats_page *formats;
 
-    /* The columns produced thereby. */
+    /* The columns produced. */
     struct column *columns;     /* Information about each column. */
     size_t column_cnt;          /* Number of columns. */
 
-    GtkWidget *page;
-    GtkWidget *custom_cb;
-    GtkWidget *custom_entry;
-    GtkWidget *quote_cb;
-    GtkWidget *quote_combo;
-    GtkEntry *quote_entry;
-    GtkWidget *escape_cb;
-    GtkTreeView *fields_tree_view;
-  };
-
-/* Page where the user verifies and adjusts input formats. */
-struct formats_page
-  {
+    int skip_lines;             /* Number of initial lines to skip? */
+    bool variable_names;        /* Variable names above first line of data? */
     struct dictionary *dict;
 
-    GtkWidget *page;
-    GtkTreeView *data_tree_view;
-    PsppireDict *psppire_dict;
-    struct variable **modified_vars;
-    size_t modified_var_cnt;
+    struct spreadsheet *spreadsheet;
   };
 
-
-struct import_assistant
-  {
-    struct file file;
-    struct assistant asst;
-    struct intro_page intro;
-    struct sheet_spec_page sheet_spec;
-    struct first_line_page first_line;
-    struct separators_page separators;
-    struct formats_page formats;
-  };
-
-
-
-
 struct column
   {
     /* Variable name for this column.  This is the variable name
@@ -174,11 +112,11 @@ void text_data_import_assistant (PsppireDataWindow *);
 /* FIXME: Should this be private to first line page ? */
 void make_tree_view (const struct import_assistant *ia,
                             size_t first_line,
-                            GtkTreeView **tree_view);
+                            PsppSheetView **tree_view);
 
-gint get_monospace_width (GtkTreeView *, GtkCellRenderer *,
+gint get_monospace_width (PsppSheetView *, GtkCellRenderer *,
                                  size_t char_cnt);
-gint get_string_width (GtkTreeView *, GtkCellRenderer *,
+gint get_string_width (PsppSheetView *, GtkCellRenderer *,
                               const char *string);
 
 
@@ -187,38 +125,37 @@ void push_watch_cursor (struct import_assistant *);
 void pop_watch_cursor (struct import_assistant *);
 
 
-GtkTreeView *create_data_tree_view (bool input, GtkContainer *parent,
-                                           struct import_assistant *);
+PsppSheetView *create_data_tree_view (bool input, GtkContainer *parent,
+                                      struct import_assistant *);
 
-GtkTreeViewColumn *make_data_column (struct import_assistant *,
-                                            GtkTreeView *, bool input,
-                                            gint column_idx);
+PsppSheetViewColumn *make_data_column (struct import_assistant *,
+                                       PsppSheetView *, bool input,
+                                       gint column_idx);
 
 
+void  update_assistant (struct import_assistant *ia);
+
 bool init_file (struct import_assistant *ia, GtkWindow *parent_window);
 void destroy_file (struct import_assistant *ia);
 
+void prepare_sheet_spec_page (struct import_assistant *ia);
+void reset_sheet_spec_page (struct import_assistant *);
+void post_sheet_spec_page (struct import_assistant *ia);
 
-void init_intro_page (struct import_assistant *);
-void reset_intro_page (struct import_assistant *);
-
-void init_first_line_page (struct import_assistant *ia);
 void prepare_first_line_page (struct import_assistant *ia);
 void reset_first_line_page (struct import_assistant *);
-void destroy_first_line_page (struct import_assistant *ia);
 
-void init_separators_page (struct import_assistant *ia);
+void reset_intro_page (struct import_assistant *ia);
+
 void prepare_separators_page (struct import_assistant *ia);
 void reset_separators_page (struct import_assistant *);
 void destroy_separators_page (struct import_assistant *ia);
 
-void init_formats_page (struct import_assistant *ia);
 void prepare_formats_page (struct import_assistant *ia);
 void reset_formats_page (struct import_assistant *);
 void destroy_formats_page (struct import_assistant *ia);
 
-
-void init_assistant (struct import_assistant *, GtkWindow *);
+struct import_assistant * init_assistant (GtkWindow *);
 void destroy_assistant (struct import_assistant *);