ia->first_line = first_line_page_create (ia);
- ia->formats = xzalloc (sizeof *ia->formats);
-
-
+ ia->formats = formats_page_create (ia);
g_signal_connect (a->assistant, "prepare", G_CALLBACK (on_prepare), ia);
g_signal_connect (a->assistant, "cancel", G_CALLBACK (on_cancel), ia);
}
-#endif
+
gtk_widget_show (ia->asst.reset_button);
if (page == ia->formats->page)
gtk_widget_show (ia->asst.paste_button);
else
gtk_widget_hide (ia->asst.paste_button);
+
+#endif
}
/* Called when the Cancel button in the assistant is clicked. */
#define _(msgid) gettext (msgid)
#define N_(msgid) msgid
+/* Page where the user verifies and adjusts input formats. */
+struct formats_page
+ {
+ GtkWidget *page;
+ GtkTreeView *data_tree_view;
+ PsppireDict *psppire_dict;
+ struct variable **modified_vars;
+ size_t modified_var_cnt;
+ };
+
/* The "formats" page of the assistant. */
static void on_variable_change (PsppireDict *dict, int idx,
static void clear_modified_vars (struct import_assistant *);
/* Initializes IA's formats substructure. */
-void
-init_formats_page (struct import_assistant *ia)
+
+struct formats_page *
+formats_page_create (struct import_assistant *ia)
{
GtkBuilder *builder = ia->asst.builder;
- struct formats_page *p = ia->formats;
+ struct formats_page *p = xzalloc (sizeof *p);
p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Formats"),
GTK_ASSISTANT_PAGE_CONFIRM);
p->data_tree_view = GTK_TREE_VIEW (get_widget_assert (builder, "data"));
p->modified_vars = NULL;
p->modified_var_cnt = 0;
- p->dict = NULL;
+
+ return p;
}
/* Frees IA's formats substructure. */
psppire_dict = psppire_dict_new_from_dict (dict);
g_signal_connect (psppire_dict, "variable_changed",
G_CALLBACK (on_variable_change), ia);
- ia->formats->dict = dict;
+ ia->dict = dict;
ia->formats->psppire_dict = psppire_dict;
/* XXX: PsppireVarStore doesn't hold a reference to
#include "ui/gui/psppire-scanf.h"
#include "ui/syntax-gen.h"
+#include <data/casereader.h>
+
#include "gl/error.h"
#include "gl/intprops.h"
#include "gl/xalloc.h"
struct import_assistant;
+
/* The "sheet-spec" page of the assistant. */
/* The sheet_spec page of the assistant (only relevant for spreadsheet imports). */
update_assistant (struct import_assistant *ia)
{
struct sheet_spec_page *ssp = ia->sheet_spec;
- // struct file *file = &ia->file;
int rows = 0;
ssp = ia->sheet_spec;
- init_formats_page (ia);
-
gtk_widget_show_all (GTK_WIDGET (ia->asst.assistant));
ia->asst.main_loop = g_main_loop_new (NULL, false);
size_t row, size_t column,
char **outputp, char **tooltipp)
{
- struct substring field;
- union value val;
- struct variable *var;
const struct fmt_spec *in;
struct fmt_spec out;
char *tooltip;
bool ok;
- field = ia->columns[column].contents[row];
- var = dict_get_var (ia->formats->dict, column);
+ struct substring field = ia->columns[column].contents[row];
+ struct variable *var = dict_get_var (ia->dict, column);
+ union value val;
+
value_init (&val, var_get_width (var));
in = var_get_print_format (var);
out = fmt_for_output_from_input (in);
char *error;
error = data_in (field, "UTF-8", in->type, &val, var_get_width (var),
- dict_get_encoding (ia->formats->dict));
+ dict_get_encoding (ia->dict));
if (error != NULL)
{
tooltip = xasprintf (_("Cannot parse field content `%.*s' as "
}
if (outputp != NULL)
{
- *outputp = data_out (&val, dict_get_encoding (ia->formats->dict), &out);
+ *outputp = data_out (&val, dict_get_encoding (ia->dict), &out);
}
value_destroy (&val, var_get_width (var));
if (input)
column = &ia->columns[dict_idx];
else
- var = dict_get_var (ia->formats->dict, dict_idx);
+ var = dict_get_var (ia->dict, dict_idx);
name = escape_underscores (input ? column->name : var_get_name (var));
char_cnt = input ? column->width : var_get_print_format (var)->w;
GtkCellRenderer *prop_renderer;
GtkCellRenderer *fixed_renderer;
-
};
-
-
-/* Page where the user verifies and adjusts input formats. */
-struct formats_page
- {
- struct dictionary *dict;
-
- GtkWidget *page;
- GtkTreeView *data_tree_view;
- PsppireDict *psppire_dict;
- struct variable **modified_vars;
- size_t modified_var_cnt;
- };
-
-
struct import_assistant
{
struct file file;
int skip_lines; /* Number of initial lines to skip? */
bool variable_names; /* Variable names above first line of data? */
+ struct dictionary *dict;
};
-
-
-
struct column
{
/* Variable name for this column. This is the variable name
void reset_sheet_spec_page (struct import_assistant *);
void post_sheet_spec_page (struct import_assistant *ia);
-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 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);