ia->intro = intro_page_create (ia);
ia->separators = separators_page_create (ia);
- ia->first_line = xzalloc (sizeof *ia->first_line);
+
+ a->prop_renderer = gtk_cell_renderer_text_new ();
+ g_object_ref_sink (a->prop_renderer);
+ a->fixed_renderer = gtk_cell_renderer_text_new ();
+ g_object_ref_sink (a->fixed_renderer);
+ g_object_set (G_OBJECT (a->fixed_renderer),
+ "family", "Monospace",
+ (void *) NULL);
+
+ ia->first_line = first_line_page_create (ia);
+
ia->formats = xzalloc (sizeof *ia->formats);
+
g_signal_connect (a->assistant, "prepare", G_CALLBACK (on_prepare), ia);
g_signal_connect (a->assistant, "cancel", G_CALLBACK (on_cancel), ia);
g_signal_connect (a->assistant, "close", G_CALLBACK (on_close), ia);
gtk_window_set_transient_for (GTK_WINDOW (a->assistant), parent_window);
gtk_window_set_icon_name (GTK_WINDOW (a->assistant), "pspp");
- a->prop_renderer = gtk_cell_renderer_text_new ();
- g_object_ref_sink (a->prop_renderer);
- a->fixed_renderer = gtk_cell_renderer_text_new ();
- g_object_ref_sink (a->fixed_renderer);
- g_object_set (G_OBJECT (a->fixed_renderer),
- "family", "Monospace",
- (void *) NULL);
-
return ia;
}
#define N_(msgid) msgid
+
/* The "first line" page of the assistant. */
+/* Page where the user chooses the first line of data. */
+struct first_line_page
+ {
+ GtkWidget *page;
+ GtkTreeView *tree_view;
+ GtkWidget *variable_names_cb;
+ };
+
static GtkTreeView *create_lines_tree_view (GtkContainer *parent_window,
struct import_assistant *);
static void on_first_line_change (GtkTreeSelection *,
static void get_first_line (struct import_assistant *);
/* Initializes IA's first_line substructure. */
-void
-init_first_line_page (struct import_assistant *ia)
+struct first_line_page *
+first_line_page_create (struct import_assistant *ia)
{
- struct first_line_page *p = ia->first_line;
+ struct first_line_page *p = xzalloc (sizeof *p);
+
GtkBuilder *builder = ia->asst.builder;
p->page = add_page_to_assistant (ia, get_widget_assert (builder, "FirstLine"),
gtk_tree_selection_set_mode (
gtk_tree_view_get_selection (GTK_TREE_VIEW (p->tree_view)),
GTK_SELECTION_BROWSE);
- set_first_line (ia);
g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (p->tree_view)),
"changed", G_CALLBACK (on_first_line_change), ia);
g_signal_connect (p->variable_names_cb, "toggled",
G_CALLBACK (on_variable_names_cb_toggle), ia);
+ return p;
}
/* Resets the first_line page to its initial content. */
void
reset_first_line_page (struct import_assistant *ia)
{
- ia->first_line->skip_lines = 0;
- ia->first_line->variable_names = false;
+ ia->skip_lines = 0;
+ ia->variable_names = false;
set_first_line (ia);
}
static GtkTreeView *
create_lines_tree_view (GtkContainer *parent, struct import_assistant *ia)
{
- GtkTreeView *tree_view;
+ GtkTreeView *tree_view = NULL;
GtkTreeViewColumn *column;
size_t max_line_length;
gint content_width, header_width;
{
GtkTreePath *path;
- path = gtk_tree_path_new_from_indices (ia->first_line->skip_lines, -1);
+ path = gtk_tree_path_new_from_indices (ia->skip_lines, -1);
gtk_tree_view_set_cursor (GTK_TREE_VIEW (ia->first_line->tree_view),
path, NULL, false);
gtk_tree_path_free (path);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (ia->first_line->variable_names_cb),
- ia->first_line->variable_names);
+ ia->variable_names);
gtk_widget_set_sensitive (ia->first_line->variable_names_cb,
- ia->first_line->skip_lines > 0);
+ ia->skip_lines > 0);
}
/* Sets IA's first_line substructure to match the widgets. */
int row = gtk_tree_path_get_indices (path)[0];
gtk_tree_path_free (path);
- ia->first_line->skip_lines = row;
- ia->first_line->variable_names =
- (ia->first_line->skip_lines > 0
+ ia->skip_lines = row;
+ ia->variable_names =
+ (ia->skip_lines > 0
&& gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (ia->first_line->variable_names_cb)));
}
gtk_widget_set_sensitive (ia->first_line->variable_names_cb,
- ia->first_line->skip_lines > 0);
+ ia->skip_lines > 0);
}
/* Choose variable format. */
fmt_guesser_clear (fg);
- for (row = ia->first_line->skip_lines; row < ia->file.line_cnt; row++)
+ for (row = ia->skip_lines; row < ia->file.line_cnt; row++)
fmt_guesser_add (fg, column->contents[row]);
fmt_guesser_guess (fg, &format);
fmt_fix_input (&format);
static void
choose_column_names (struct import_assistant *ia)
{
- const struct first_line_page *f = ia->first_line;
struct dictionary *dict;
unsigned long int generated_name_count = 0;
struct column *col;
size_t name_row;
dict = dict_create (get_default_encoding ());
- name_row = f->variable_names && f->skip_lines ? f->skip_lines : 0;
+ name_row = ia->variable_names && ia->skip_lines ? ia->skip_lines : 0;
for (col = ia->columns; col < &ia->columns[ia->column_cnt]; col++)
{
char *hint, *name;
}
ssp = ia->sheet_spec;
- init_first_line_page (ia);
init_formats_page (ia);
column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_column),
"column-number"));
- row = empty_list_store_iter_to_row (iter) + ia->first_line->skip_lines;
+ row = empty_list_store_iter_to_row (iter) + ia->skip_lines;
field = ia->columns[column].contents[row];
if (field.string != NULL)
{
ok = parse_field (ia,
(empty_list_store_iter_to_row (iter)
- + ia->first_line->skip_lines),
+ + ia->skip_lines),
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_column),
"column-number")),
&output, NULL);
if (!ok)
return FALSE;
- *row = empty_list_store_iter_to_row (&iter) + ia->first_line->skip_lines;
+ *row = empty_list_store_iter_to_row (&iter) + ia->skip_lines;
return TRUE;
}
GtkTreeView *tree_view;
gint i;
- make_tree_view (ia, ia->first_line->skip_lines, &tree_view);
+ make_tree_view (ia, ia->skip_lines, &tree_view);
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (tree_view),
GTK_SELECTION_NONE);
-/* Page where the user chooses the first line of data. */
-struct first_line_page
- {
- int skip_lines; /* Number of initial lines to skip? */
- bool variable_names; /* Variable names above first line of data? */
-
- GtkWidget *page;
- GtkTreeView *tree_view;
- GtkWidget *variable_names_cb;
- };
-
-
/* Page where the user verifies and adjusts input formats. */
struct formats_page
{
/* The columns produced. */
struct column *columns; /* Information about each column. */
size_t column_cnt; /* Number of columns. */
+
+ int skip_lines; /* Number of initial lines to skip? */
+ bool variable_names; /* Variable names above first line of data? */
};
bool init_file (struct import_assistant *ia, GtkWindow *parent_window);
void destroy_file (struct import_assistant *ia);
-
-void init_sheet_spec_page (struct import_assistant *);
void prepare_sheet_spec_page (struct import_assistant *ia);
void reset_sheet_spec_page (struct import_assistant *);
void post_sheet_spec_page (struct import_assistant *ia);
void prepare_first_line_page (struct import_assistant *ia);
void reset_first_line_page (struct import_assistant *);
-void init_separators_page (struct import_assistant *ia);
void prepare_separators_page (struct import_assistant *ia);
void reset_separators_page (struct import_assistant *);
void destroy_separators_page (struct import_assistant *ia);