1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2015 Free Software Foundation
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #ifndef __PSPPIRE_IMPORT_ASSISTANT_H__
19 #define __PSPPIRE_IMPORT_ASSISTANT_H__
21 #include <glib-object.h>
26 #include "libpspp/str.h"
27 #include "psppire-dict.h"
28 #include "data/spreadsheet-reader.h"
35 #define PSPPIRE_TYPE_IMPORT_ASSISTANT (psppire_import_assistant_get_type ())
37 #define PSPPIRE_IMPORT_ASSISTANT(obj) \
38 (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
39 PSPPIRE_TYPE_IMPORT_ASSISTANT, PsppireImportAssistant))
41 #define PSPPIRE_IMPORT_ASSISTANT_CLASS(klass) \
42 (G_TYPE_CHECK_CLASS_CAST ((klass), \
43 PSPPIRE_TYPE_IMPORT_ASSISTANT, \
44 PsppireImportAssistantClass))
46 #define PSPPIRE_IS_IMPORT_ASSISTANT(obj) \
47 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_IMPORT_ASSISTANT))
49 #define PSPPIRE_IS_IMPORT_ASSISTANT_CLASS(klass) \
50 (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_IMPORT_ASSISTANT))
53 #define PSPPIRE_IMPORT_ASSISTANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
54 PSPPIRE_TYPE_IMPORT_ASSISTANT, \
55 PsppireImportAssistantClass))
57 typedef struct _PsppireImportAssistant PsppireImportAssistant;
58 typedef struct _PsppireImportAssistantClass PsppireImportAssistantClass;
61 struct first_line_page;
63 typedef void page_func (PsppireImportAssistant *, GtkWidget *page);
65 enum { MAX_PREVIEW_LINES = 1000 }; /* Max number of lines to read. */
67 struct _PsppireImportAssistant
75 /* START The chooser page of the assistant. */
76 GtkWidget *encoding_selector;
77 GtkFileFilter *default_filter;
78 /* END The chooser page of the assistant. */
81 /* START The introduction page of the assistant. */
82 GtkWidget *all_cases_button;
83 GtkWidget *n_cases_button;
84 GtkWidget *n_cases_spin;
85 GtkWidget *percent_button;
86 GtkWidget *percent_spin;
87 /* END The introduction page of the assistant. */
90 /* START Page where the user chooses field separators. */
92 /* How to break lines into columns. */
93 struct string separators; /* Field separators. */
94 struct string quotes; /* Quote characters. */
97 GtkWidget *custom_entry;
99 GtkWidget *quote_combo;
100 GtkEntry *quote_entry;
101 GtkWidget *fields_tree_view;
103 /* END Page where the user chooses field separators. */
106 /* START Page where the user verifies and adjusts input formats. */
107 GtkWidget *data_tree_view;
108 PsppireDict *psppire_dict;
109 struct variable **modified_vars;
110 size_t modified_var_cnt;
111 /* END Page where the user verifies and adjusts input formats. */
114 /* START first line page */
115 GtkWidget *tree_view;
116 GtkWidget *variable_names_cb;
117 /* END first line page */
119 GMainLoop *main_loop;
120 GtkWidget *paste_button;
121 GtkWidget *reset_button;
125 GtkCellRenderer *prop_renderer;
126 GtkCellRenderer *fixed_renderer;
128 // START struct file file;
129 char *file_name; /* File name. */
131 /* Relevant only for text files */
133 gchar *encoding; /* Encoding. */
134 unsigned long int total_lines; /* Number of lines in file. */
135 gboolean total_is_exact; /* Is total_lines exact (or an estimate)? */
137 /* The first several lines of the file. */
138 struct string lines[MAX_PREVIEW_LINES];
141 // END struct file file;
143 struct sheet_spec_page *sheet_spec;
144 struct first_line_page *first_line;
146 /* The columns produced. */
147 struct column *columns; /* Information about each column. */
148 size_t column_cnt; /* Number of columns. */
150 int skip_lines; /* Number of initial lines to skip? */
151 gboolean variable_names; /* Variable names above first line of data? */
152 struct dictionary *dict;
154 struct spreadsheet *spreadsheet;
157 struct _PsppireImportAssistantClass
159 GtkAssistantClass parent_class;
162 GType psppire_import_assistant_get_type (void) ;
165 GtkWidget *psppire_import_assistant_new (GtkWindow *toplevel);
167 gchar *psppire_import_assistant_generate_syntax (PsppireImportAssistant *);
171 #endif /* __PSPPIRE_IMPORT_ASSISTANT_H__ */