gui: Make text import assistant accept only one quote character.
[pspp] / src / ui / gui / psppire-import-assistant.h
1 /* PSPPIRE - a graphical user interface for PSPP.
2    Copyright (C) 2015, 2017, 2020  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 "psppire-dict.h"
27 #include "data/spreadsheet-reader.h"
28 #include "psppire-text-file.h"
29 #include "psppire-delimited-text.h"
30
31 #include <ssw-sheet.h>
32
33 G_BEGIN_DECLS
34
35 struct spreadsheet;
36
37
38 #define PSPPIRE_TYPE_IMPORT_ASSISTANT (psppire_import_assistant_get_type ())
39
40 #define PSPPIRE_IMPORT_ASSISTANT(obj)   \
41                      (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
42                                                   PSPPIRE_TYPE_IMPORT_ASSISTANT, PsppireImportAssistant))
43
44 #define PSPPIRE_IMPORT_ASSISTANT_CLASS(klass) \
45                      (G_TYPE_CHECK_CLASS_CAST ((klass), \
46                                  PSPPIRE_TYPE_IMPORT_ASSISTANT, \
47                                  PsppireImportAssistantClass))
48
49 #define PSPPIRE_IS_IMPORT_ASSISTANT(obj) \
50                      (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PSPPIRE_TYPE_IMPORT_ASSISTANT))
51
52 #define PSPPIRE_IS_IMPORT_ASSISTANT_CLASS(klass) \
53                      (G_TYPE_CHECK_CLASS_TYPE ((klass), PSPPIRE_TYPE_IMPORT_ASSISTANT))
54
55
56 #define PSPPIRE_IMPORT_ASSISTANT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
57                                    PSPPIRE_TYPE_IMPORT_ASSISTANT, \
58                                    PsppireImportAssistantClass))
59
60 typedef struct _PsppireImportAssistant       PsppireImportAssistant;
61 typedef struct _PsppireImportAssistantClass  PsppireImportAssistantClass;
62
63 enum IMPORT_ASSISTANT_DIRECTION {IMPORT_ASSISTANT_FORWARDS, IMPORT_ASSISTANT_BACKWARDS};
64
65 struct _PsppireImportAssistant
66 {
67   GtkAssistant parent;
68
69   gint previous_page;
70   gchar *file_name;
71   GMainLoop *main_loop;
72   GtkWidget *paste_button;
73   GtkWidget *reset_button;
74   int response;
75
76   struct dictionary *dict;
77   struct dictionary *casereader_dict;
78
79   GtkWidget *var_sheet;
80   GtkWidget *data_sheet;
81
82
83   /* START The chooser page of the assistant. */
84   GtkWidget *encoding_selector;
85   GtkFileFilter *default_filter;
86   /* END The chooser page of the assistant. */
87
88
89   GtkBuilder *text_builder;
90
91
92   /* START The introduction page of the assistant. */
93     GtkWidget *all_cases_button;
94     GtkWidget *n_cases_button;
95     GtkWidget *n_cases_spin;
96     GtkWidget *percent_button;
97     GtkWidget *percent_spin;
98   /* END The introduction page of the assistant. */
99
100
101   /* START Page where the user chooses field separators. */
102
103   /* How to break lines into columns. */
104   struct string quotes;       /* Quote characters. */
105
106   GtkWidget *custom_cb;
107   GtkWidget *custom_entry;
108   GtkWidget *quote_none;
109   GtkWidget *quote_single;
110   GtkWidget *quote_double;
111   GtkWidget *quote_custom;
112   GtkWidget *quote_custom_entry;
113
114   GtkWidget *fields_tree_view;
115
116 /* END Page where the user chooses field separators. */
117
118
119   /* START first line page */
120   GtkWidget *first_line_tree_view;
121   GtkWidget *variable_names_cb;
122   /* END first line page */
123
124   PsppireTextFile *text_file;
125   PsppireDelimitedText *delimiters_model;
126
127   /* START spreadsheet related things */
128   GtkBuilder *spread_builder;
129   GtkWidget *preview_sheet;
130   struct spreadsheet *spreadsheet;
131   SswRange selection;
132   bool updating_selection;
133 };
134
135 struct _PsppireImportAssistantClass
136 {
137   GtkAssistantClass parent_class;
138 };
139
140 GType psppire_import_assistant_get_type (void) ;
141
142
143 GtkWidget *psppire_import_assistant_new (GtkWindow *toplevel);
144
145 gchar *psppire_import_assistant_generate_syntax (PsppireImportAssistant *);
146
147 int psppire_import_assistant_run (PsppireImportAssistant *asst);
148
149 GtkWidget *add_page_to_assistant (PsppireImportAssistant *ia,
150                                   GtkWidget *page, GtkAssistantPageType type, const gchar *title);
151
152 G_END_DECLS
153
154 #endif /* __PSPPIRE_IMPORT_ASSISTANT_H__ */