Merge remote-tracking branch 'origin/master' into sheet
[pspp] / src / ui / gui / psppire-import-assistant.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2015  Free Software Foundation
3
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.
8
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.
13
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/>. */
16
17
18 #ifndef __PSPPIRE_IMPORT_ASSISTANT_H__
19 #define __PSPPIRE_IMPORT_ASSISTANT_H__
20
21 #include <glib-object.h>
22 #include <glib.h>
23
24 #include <gtk/gtk.h>
25
26 #include "libpspp/str.h"
27 #include "psppire-dict.h"
28 #include "data/spreadsheet-reader.h"
29 #include "psppire-text-file.h"
30
31 G_BEGIN_DECLS
32
33 struct spreadsheet;
34
35
36 #define PSPPIRE_TYPE_IMPORT_ASSISTANT (psppire_import_assistant_get_type ())
37
38 #define PSPPIRE_IMPORT_ASSISTANT(obj)   \
39                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
40                                                   PSPPIRE_TYPE_IMPORT_ASSISTANT, PsppireImportAssistant))
41
42 #define PSPPIRE_IMPORT_ASSISTANT_CLASS(klass) \
43                      (G_TYPE_CHECK_CLASS_CAST ((klass), \
44                                  PSPPIRE_TYPE_IMPORT_ASSISTANT, \
45                                  PsppireImportAssistantClass))
46
47 #define PSPPIRE_IS_IMPORT_ASSISTANT(obj) \
48                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_IMPORT_ASSISTANT))
49
50 #define PSPPIRE_IS_IMPORT_ASSISTANT_CLASS(klass) \
51                      (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_IMPORT_ASSISTANT))
52
53
54 #define PSPPIRE_IMPORT_ASSISTANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
55                                    PSPPIRE_TYPE_IMPORT_ASSISTANT, \
56                                    PsppireImportAssistantClass))
57
58 typedef struct _PsppireImportAssistant       PsppireImportAssistant;
59 typedef struct _PsppireImportAssistantClass  PsppireImportAssistantClass;
60
61
62 typedef void page_func (PsppireImportAssistant *, GtkWidget *page);
63
64 struct _PsppireImportAssistant
65 {
66   GtkAssistant parent;
67
68   GtkBuilder *builder;
69
70   gint current_page;
71
72   /* START The chooser page of the assistant. */
73   GtkWidget *encoding_selector;
74   GtkFileFilter *default_filter;
75   /* END The chooser page of the assistant. */
76
77
78   /* START The introduction page of the assistant. */
79     GtkWidget *all_cases_button;
80     GtkWidget *n_cases_button;
81     GtkWidget *n_cases_spin;
82     GtkWidget *percent_button;
83     GtkWidget *percent_spin;
84   /* END The introduction page of the assistant. */
85
86
87 /* START Page where the user chooses field separators. */
88
89   /* How to break lines into columns. */
90   struct string separators;   /* Field separators. */
91   struct string quotes;       /* Quote characters. */
92
93   GtkWidget *custom_cb;
94   GtkWidget *custom_entry;
95   GtkWidget *quote_cb;
96   GtkWidget *quote_combo;
97   GtkEntry *quote_entry;
98   GtkWidget *fields_tree_view;
99
100 /* END Page where the user chooses field separators. */
101
102
103 /* START Page where the user verifies and adjusts input formats. */
104   GtkWidget *data_tree_view;
105   PsppireDict *psppire_dict;
106   struct variable **modified_vars;
107   size_t modified_var_cnt;
108 /* END Page where the user verifies and adjusts input formats. */
109
110
111   /* START first line page */
112   GtkWidget *first_line_tree_view;
113   GtkWidget *variable_names_cb;
114   /* END first line page */
115
116   GMainLoop *main_loop;
117   GtkWidget *paste_button;
118   GtkWidget *reset_button;
119   int response;
120   int watch_cursor;
121
122   GtkCellRenderer *prop_renderer;
123   GtkCellRenderer *fixed_renderer;
124
125   PsppireTextFile *text_file;
126
127   GtkTreeModel *delimiters_model;
128   
129   struct sheet_spec_page *sheet_spec;
130
131   /* The columns produced. */
132   struct column *columns;     /* Information about each column. */
133   size_t column_cnt;          /* Number of columns. */
134
135   int skip_lines;             /* Number of initial lines to skip? */
136   gboolean variable_names;        /* Variable names above first line of data? */
137   struct dictionary *dict;
138
139   struct spreadsheet *spreadsheet;
140 };
141
142 struct _PsppireImportAssistantClass
143 {
144   GtkAssistantClass parent_class;
145 };
146
147 GType psppire_import_assistant_get_type (void) ;
148
149
150 GtkWidget *psppire_import_assistant_new (GtkWindow *toplevel);
151
152 gchar *psppire_import_assistant_generate_syntax (PsppireImportAssistant *);
153
154 G_END_DECLS
155
156 #endif /* __PSPPIRE_IMPORT_ASSISTANT_H__ */