1 /* PSPPIRE - a graphical user interface for PSPP.
2 Copyright (C) 2013 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/>. */
19 #include "ui/gui/text-data-import-dialog.h"
23 #include <gtk-contrib/psppire-sheet.h>
29 #include "data/data-in.h"
30 #include "data/data-out.h"
31 #include "data/format-guesser.h"
32 #include "data/value-labels.h"
33 #include "data/gnumeric-reader.h"
34 #include "data/ods-reader.h"
35 #include "data/spreadsheet-reader.h"
36 #include "language/data-io/data-parser.h"
37 #include "language/lexer/lexer.h"
38 #include "libpspp/assertion.h"
39 #include "libpspp/i18n.h"
40 #include "libpspp/line-reader.h"
41 #include "libpspp/message.h"
42 #include "ui/gui/checkbox-treeview.h"
43 #include "ui/gui/dialog-common.h"
44 #include "ui/gui/executor.h"
45 #include "ui/gui/helper.h"
46 #include "ui/gui/builder-wrapper.h"
47 #include "ui/gui/psppire-data-window.h"
48 #include "ui/gui/psppire-dialog.h"
49 #include "ui/gui/psppire-encoding-selector.h"
50 #include "ui/gui/psppire-empty-list-store.h"
51 #include "ui/gui/psppire-var-sheet.h"
52 #include "ui/gui/psppire-var-store.h"
53 #include "ui/gui/psppire-scanf.h"
54 #include "ui/syntax-gen.h"
57 #include "gl/intprops.h"
58 #include "gl/xalloc.h"
61 #define _(msgid) gettext (msgid)
62 #define N_(msgid) msgid
64 struct import_assistant;
68 /* The "sheet-spec" page of the assistant. */
71 /* Initializes IA's sheet_spec substructure. */
73 init_sheet_spec_page (struct import_assistant *ia)
75 GtkBuilder *builder = ia->asst.builder;
76 struct sheet_spec_page *p = &ia->sheet_spec;
78 p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Sheet"),
79 GTK_ASSISTANT_PAGE_INTRO);
83 /* Resets IA's sheet_spec page to its initial state. */
85 reset_sheet_spec_page (struct import_assistant *ia)
87 printf ("%s\n", __FUNCTION__);
90 /* Called when the Forward button is clicked,
91 but before displaying the new page.
94 post_sheet_spec_page (struct import_assistant *ia)
96 GtkBuilder *builder = ia->asst.builder;
98 struct file *file = &ia->file;
99 struct sheet_spec_page *ssp = &ia->sheet_spec;
100 struct casereader *creader;
101 struct dictionary *dict;
103 GtkWidget *sheet_entry = get_widget_assert (builder, "sheet-entry");
104 GtkWidget *readnames_checkbox = get_widget_assert (builder, "readnames-checkbox");
106 gint num = atoi (gtk_entry_get_text (sheet_entry));
108 printf ("%s sheet number %d\n", __FUNCTION__, num);
110 ssp->opts.sheet_name = NULL;
111 ssp->opts.cell_range = NULL;
112 ssp->opts.sheet_index = num;
114 ssp->sri.file_name = file->file_name;
115 ssp->sri.read_names = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (readnames_checkbox));
118 switch (ia->file.type)
121 creader = ods_open_reader (&ssp->sri, &ssp->opts, &dict);
124 creader = gnumeric_open_reader (&ssp->sri, &ssp->opts, &dict);
127 g_assert_not_reached ();
132 ssp->reader = creader;
134 update_assistant (ia);