From: John Darrington Date: Sun, 13 Jan 2013 18:43:04 +0000 (+0100) Subject: Put the pages as pointers X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=001db1bf60acf85491463edcd557aad6e661195c;p=pspp Put the pages as pointers --- diff --git a/src/ui/gui/page-assistant.c b/src/ui/gui/page-assistant.c index 0d43248bac..9c95005e4d 100644 --- a/src/ui/gui/page-assistant.c +++ b/src/ui/gui/page-assistant.c @@ -69,11 +69,20 @@ static void close_assistant (struct import_assistant *, int response); /* Initializes IA's asst substructure. PARENT_WINDOW must be the window to use as the assistant window's parent. */ -void -init_assistant (struct import_assistant *ia, GtkWindow *parent_window) +struct import_assistant * +init_assistant (GtkWindow *parent_window) { + struct import_assistant *ia = NULL; + ia = xzalloc (sizeof *ia); struct assistant *a = &ia->asst; + + ia->intro = xzalloc (sizeof *ia->intro); + ia->sheet_spec = xzalloc (sizeof *ia->sheet_spec); + ia->first_line = xzalloc (sizeof *ia->first_line); + ia->separators = xzalloc (sizeof *ia->separators); + ia->formats = xzalloc (sizeof *ia->formats); + a->builder = builder_new ("text-data-import.ui"); a->assistant = GTK_ASSISTANT (gtk_assistant_new ()); g_signal_connect (a->assistant, "prepare", G_CALLBACK (on_prepare), ia); @@ -97,6 +106,7 @@ init_assistant (struct import_assistant *ia, GtkWindow *parent_window) g_object_set (G_OBJECT (a->fixed_renderer), "family", "Monospace", (void *) NULL); + return ia; } /* Frees IA's asst substructure. */ @@ -148,7 +158,7 @@ static void on_prepare (GtkAssistant *assistant, GtkWidget *page, struct import_assistant *ia) { - struct sheet_spec_page *ssp = &ia->sheet_spec; + struct sheet_spec_page *ssp = ia->sheet_spec; int pn = gtk_assistant_get_current_page (assistant); @@ -163,11 +173,11 @@ on_prepare (GtkAssistant *assistant, GtkWidget *page, /* Prepare .... */ - if (page == ia->separators.page) + if (page == ia->separators->page) prepare_separators_page (ia); - else if (page == ia->formats.page) + else if (page == ia->formats->page) prepare_formats_page (ia); - else if (page == ia->sheet_spec.page && ssp->spreadsheet) + else if (page == ia->sheet_spec->page && ssp->spreadsheet) { prepare_sheet_spec_page (ia); } @@ -175,7 +185,7 @@ on_prepare (GtkAssistant *assistant, GtkWidget *page, gtk_widget_show (ia->asst.reset_button); - if (page == ia->formats.page) + if (page == ia->formats->page) gtk_widget_show (ia->asst.paste_button); else gtk_widget_hide (ia->asst.paste_button); @@ -211,15 +221,15 @@ on_reset (GtkButton *button, struct import_assistant *ia) gint page_num = gtk_assistant_get_current_page (ia->asst.assistant); GtkWidget *page = gtk_assistant_get_nth_page (ia->asst.assistant, page_num); - if (page == ia->intro.page) + if (page == ia->intro->page) reset_intro_page (ia); - else if (page == ia->first_line.page) + else if (page == ia->first_line->page) reset_first_line_page (ia); - else if (page == ia->separators.page) + else if (page == ia->separators->page) reset_separators_page (ia); - else if (page == ia->formats.page) + else if (page == ia->formats->page) reset_formats_page (ia); - else if (page == ia->sheet_spec.page) + else if (page == ia->sheet_spec->page) reset_sheet_spec_page (ia); } diff --git a/src/ui/gui/page-file.c b/src/ui/gui/page-file.c index 9ac69e8685..d8939149c4 100644 --- a/src/ui/gui/page-file.c +++ b/src/ui/gui/page-file.c @@ -76,10 +76,10 @@ enum { MAX_PREVIEW_LINES = 1000 }; /* Max number of lines to read. */ void update_assistant (struct import_assistant *ia) { - struct sheet_spec_page *ssp = &ia->sheet_spec; + struct sheet_spec_page *ssp = ia->sheet_spec; struct file *file = &ia->file; - struct separators_page *sepp = &ia->separators; + struct separators_page *sepp = ia->separators; int rows = 0; if (ssp->dict) { @@ -136,7 +136,7 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window) { enum { MAX_LINE_LEN = 16384 }; /* Max length of an acceptable line. */ struct file *file = &ia->file; - struct sheet_spec_page *ssp = &ia->sheet_spec; + struct sheet_spec_page *ssp = ia->sheet_spec; struct spreadsheet_read_info sri; struct spreadsheet_read_options opts; @@ -156,13 +156,9 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window) if (ssp->spreadsheet == NULL) ssp->spreadsheet = gnumeric_probe (sri.file_name); - printf ("%s:%d %p %d\n", __FILE__, __LINE__, ssp->spreadsheet, ssp->spreadsheet->type); - if (ssp->spreadsheet == NULL) ssp->spreadsheet = ods_probe (sri.file_name); - printf ("%s:%d %p %d\n", __FILE__, __LINE__, ssp->spreadsheet, ssp->spreadsheet->type); - if (ssp->spreadsheet) { @@ -170,8 +166,6 @@ init_file (struct import_assistant *ia, GtkWindow *parent_window) } else { - printf ("%s:%d %p\n", __FILE__, __LINE__, ssp->spreadsheet); - struct string input; struct line_reader *reader = line_reader_for_file (file->encoding, file->file_name, O_RDONLY); if (reader == NULL) diff --git a/src/ui/gui/page-first-line.c b/src/ui/gui/page-first-line.c index 2ccdb918b2..8f61b2efda 100644 --- a/src/ui/gui/page-first-line.c +++ b/src/ui/gui/page-first-line.c @@ -74,7 +74,7 @@ static void get_first_line (struct import_assistant *); void init_first_line_page (struct import_assistant *ia) { - struct first_line_page *p = &ia->first_line; + struct first_line_page *p = ia->first_line; GtkBuilder *builder = ia->asst.builder; p->page = add_page_to_assistant (ia, get_widget_assert (builder, "FirstLine"), @@ -97,8 +97,8 @@ init_first_line_page (struct import_assistant *ia) void reset_first_line_page (struct import_assistant *ia) { - ia->first_line.skip_lines = 0; - ia->first_line.variable_names = false; + ia->first_line->skip_lines = 0; + ia->first_line->variable_names = false; set_first_line (ia); } @@ -185,16 +185,16 @@ set_first_line (struct import_assistant *ia) { GtkTreePath *path; - path = gtk_tree_path_new_from_indices (ia->first_line.skip_lines, -1); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (ia->first_line.tree_view), + path = gtk_tree_path_new_from_indices (ia->first_line->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); - gtk_widget_set_sensitive (ia->first_line.variable_names_cb, - ia->first_line.skip_lines > 0); + GTK_TOGGLE_BUTTON (ia->first_line->variable_names_cb), + ia->first_line->variable_names); + gtk_widget_set_sensitive (ia->first_line->variable_names_cb, + ia->first_line->skip_lines > 0); } /* Sets IA's first_line substructure to match the widgets. */ @@ -205,19 +205,19 @@ get_first_line (struct import_assistant *ia) GtkTreeIter iter; GtkTreeModel *model; - selection = gtk_tree_view_get_selection (ia->first_line.tree_view); + selection = gtk_tree_view_get_selection (ia->first_line->tree_view); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { GtkTreePath *path = gtk_tree_model_get_path (model, &iter); 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->first_line->skip_lines = row; + ia->first_line->variable_names = + (ia->first_line->skip_lines > 0 && gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON (ia->first_line.variable_names_cb))); + 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); + gtk_widget_set_sensitive (ia->first_line->variable_names_cb, + ia->first_line->skip_lines > 0); } diff --git a/src/ui/gui/page-formats.c b/src/ui/gui/page-formats.c index c79551fb04..25d070276b 100644 --- a/src/ui/gui/page-formats.c +++ b/src/ui/gui/page-formats.c @@ -69,7 +69,7 @@ void init_formats_page (struct import_assistant *ia) { GtkBuilder *builder = ia->asst.builder; - struct formats_page *p = &ia->formats; + struct formats_page *p = ia->formats; p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Formats"), GTK_ASSISTANT_PAGE_CONFIRM); @@ -83,7 +83,7 @@ init_formats_page (struct import_assistant *ia) void destroy_formats_page (struct import_assistant *ia) { - struct formats_page *p = &ia->formats; + struct formats_page *p = ia->formats; if (p->psppire_dict != NULL) { @@ -104,8 +104,8 @@ prepare_formats_page (struct import_assistant *ia) GtkBin *vars_scroller; GtkWidget *old_var_sheet; PsppireVarSheet *var_sheet; - struct separators_page *seps = &ia->separators; - struct formats_page *p = &ia->formats; + struct separators_page *seps = ia->separators; + struct formats_page *p = ia->formats; struct fmt_guesser *fg; unsigned long int number = 0; size_t column_idx; @@ -134,7 +134,7 @@ prepare_formats_page (struct import_assistant *ia) /* Choose variable format. */ fmt_guesser_clear (fg); - for (row = ia->first_line.skip_lines; row < ia->file.line_cnt; row++) + for (row = ia->first_line->skip_lines; row < ia->file.line_cnt; row++) fmt_guesser_add (fg, column->contents[row]); fmt_guesser_guess (fg, &format); fmt_fix_input (&format); @@ -160,13 +160,13 @@ prepare_formats_page (struct import_assistant *ia) 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->formats.psppire_dict = psppire_dict; + ia->formats->dict = dict; + ia->formats->psppire_dict = psppire_dict; /* XXX: PsppireVarStore doesn't hold a reference to psppire_dict for now, but it should. After it does, we should g_object_ref the psppire_dict here, since we also - hold a reference via ia->formats.dict. */ + hold a reference via ia->formats->dict. */ var_store = psppire_var_store_new (psppire_dict); g_object_set (var_store, "format-type", PSPPIRE_VAR_STORE_INPUT_FORMATS, @@ -184,8 +184,8 @@ prepare_formats_page (struct import_assistant *ia) gtk_container_add (GTK_CONTAINER (vars_scroller), GTK_WIDGET (var_sheet)); gtk_widget_show (GTK_WIDGET (var_sheet)); - gtk_widget_destroy (GTK_WIDGET (ia->formats.data_tree_view)); - ia->formats.data_tree_view = create_data_tree_view ( + gtk_widget_destroy (GTK_WIDGET (ia->formats->data_tree_view)); + ia->formats->data_tree_view = create_data_tree_view ( false, GTK_CONTAINER (get_widget_assert (ia->asst.builder, "data-scroller")), ia); @@ -200,7 +200,7 @@ prepare_formats_page (struct import_assistant *ia) static void clear_modified_vars (struct import_assistant *ia) { - struct formats_page *p = &ia->formats; + struct formats_page *p = ia->formats; size_t i; for (i = 0; i < p->modified_var_cnt; i++) @@ -227,8 +227,8 @@ static void on_variable_change (PsppireDict *dict, int dict_idx, struct import_assistant *ia) { - struct formats_page *p = &ia->formats; - GtkTreeView *tv = ia->formats.data_tree_view; + struct formats_page *p = ia->formats; + GtkTreeView *tv = ia->formats->data_tree_view; gint column_idx = dict_idx + 1; push_watch_cursor (ia); diff --git a/src/ui/gui/page-intro.c b/src/ui/gui/page-intro.c index a279079b1a..56b182686c 100644 --- a/src/ui/gui/page-intro.c +++ b/src/ui/gui/page-intro.c @@ -71,7 +71,7 @@ void init_intro_page (struct import_assistant *ia) { GtkBuilder *builder = ia->asst.builder; - struct intro_page *p = &ia->intro; + struct intro_page *p = ia->intro; struct string s; GtkWidget *hbox_n_cases ; GtkWidget *hbox_percent ; @@ -153,7 +153,7 @@ init_intro_page (struct import_assistant *ia) void reset_intro_page (struct import_assistant *ia) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ia->intro.all_cases_button), + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ia->intro->all_cases_button), true); } @@ -161,7 +161,7 @@ reset_intro_page (struct import_assistant *ia) static void on_intro_amount_changed (struct import_assistant *ia) { - struct intro_page *p = &ia->intro; + struct intro_page *p = ia->intro; gtk_widget_set_sensitive (p->n_cases_spin, gtk_toggle_button_get_active ( diff --git a/src/ui/gui/page-separators.c b/src/ui/gui/page-separators.c index 5432e27663..40a6e71959 100644 --- a/src/ui/gui/page-separators.c +++ b/src/ui/gui/page-separators.c @@ -134,7 +134,7 @@ void init_separators_page (struct import_assistant *ia) { GtkBuilder *builder = ia->asst.builder; - struct separators_page *p = &ia->separators; + struct separators_page *p = ia->separators; size_t i; choose_likely_separators (ia); @@ -170,7 +170,7 @@ init_separators_page (struct import_assistant *ia) void destroy_separators_page (struct import_assistant *ia) { - struct separators_page *s = &ia->separators; + struct separators_page *s = ia->separators; ds_destroy (&s->separators); ds_destroy (&s->quotes); @@ -199,7 +199,7 @@ reset_separators_page (struct import_assistant *ia) static void clear_fields (struct import_assistant *ia) { - struct separators_page *s = &ia->separators; + struct separators_page *s = ia->separators; if (s->column_cnt > 0) { @@ -237,7 +237,7 @@ clear_fields (struct import_assistant *ia) static void split_fields (struct import_assistant *ia) { - struct separators_page *s = &ia->separators; + struct separators_page *s = ia->separators; size_t columns_allocated; bool space_sep; size_t row; @@ -330,8 +330,8 @@ split_fields (struct import_assistant *ia) static void choose_column_names (struct import_assistant *ia) { - const struct first_line_page *f = &ia->first_line; - struct separators_page *s = &ia->separators; + const struct first_line_page *f = ia->first_line; + struct separators_page *s = ia->separators; struct dictionary *dict; unsigned long int generated_name_count = 0; struct column *col; @@ -372,10 +372,9 @@ choose_likely_separators (struct import_assistant *ia) histogram[(unsigned char) line.string[i]]++; } - find_commonest_chars (histogram, "\"'", "", &ia->separators.quotes); - find_commonest_chars (histogram, ",;:/|!\t-", ",", - &ia->separators.separators); - ia->separators.escape = true; + find_commonest_chars (histogram, "\"'", "", &ia->separators->quotes); + find_commonest_chars (histogram, ",;:/|!\t-", ",", &ia->separators->separators); + ia->separators->escape = true; } /* Chooses the most common character among those in TARGETS, @@ -420,12 +419,12 @@ revise_fields_preview (struct import_assistant *ia) push_watch_cursor (ia); - w = GTK_WIDGET (ia->separators.fields_tree_view); + w = GTK_WIDGET (ia->separators->fields_tree_view); gtk_widget_destroy (w); get_separators (ia); split_fields (ia); choose_column_names (ia); - ia->separators.fields_tree_view = create_data_tree_view ( + ia->separators->fields_tree_view = create_data_tree_view ( true, GTK_CONTAINER (get_widget_assert (ia->asst.builder, "fields-scroller")), ia); @@ -437,7 +436,7 @@ revise_fields_preview (struct import_assistant *ia) static void set_separators (struct import_assistant *ia) { - struct separators_page *s = &ia->separators; + struct separators_page *s = ia->separators; unsigned int seps; struct string custom; bool any_custom; @@ -495,7 +494,7 @@ set_separators (struct import_assistant *ia) static void get_separators (struct import_assistant *ia) { - struct separators_page *s = &ia->separators; + struct separators_page *s = ia->separators; int i; ds_clear (&s->separators); @@ -540,7 +539,7 @@ on_separators_custom_cb_toggle (GtkToggleButton *custom_cb, struct import_assistant *ia) { bool is_active = gtk_toggle_button_get_active (custom_cb); - gtk_widget_set_sensitive (ia->separators.custom_entry, is_active); + gtk_widget_set_sensitive (ia->separators->custom_entry, is_active); revise_fields_preview (ia); } @@ -558,8 +557,8 @@ static void on_quote_cb_toggle (GtkToggleButton *quote_cb, struct import_assistant *ia) { bool is_active = gtk_toggle_button_get_active (quote_cb); - gtk_widget_set_sensitive (ia->separators.quote_combo, is_active); - gtk_widget_set_sensitive (ia->separators.escape_cb, is_active); + gtk_widget_set_sensitive (ia->separators->quote_combo, is_active); + gtk_widget_set_sensitive (ia->separators->escape_cb, is_active); revise_fields_preview (ia); } diff --git a/src/ui/gui/page-sheet-spec.c b/src/ui/gui/page-sheet-spec.c index 560a73dd43..0a26f01d88 100644 --- a/src/ui/gui/page-sheet-spec.c +++ b/src/ui/gui/page-sheet-spec.c @@ -73,7 +73,7 @@ void init_sheet_spec_page (struct import_assistant *ia) { GtkBuilder *builder = ia->asst.builder; - struct sheet_spec_page *p = &ia->sheet_spec; + struct sheet_spec_page *p = ia->sheet_spec; p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Sheet"), GTK_ASSISTANT_PAGE_INTRO); @@ -84,7 +84,7 @@ init_sheet_spec_page (struct import_assistant *ia) void prepare_sheet_spec_page (struct import_assistant *ia) { - struct sheet_spec_page *p = &ia->sheet_spec; + struct sheet_spec_page *p = ia->sheet_spec; GtkBuilder *builder = ia->asst.builder; GtkWidget *sheet_entry = get_widget_assert (builder, "sheet-entry"); @@ -117,7 +117,7 @@ post_sheet_spec_page (struct import_assistant *ia) GtkBuilder *builder = ia->asst.builder; struct file *file = &ia->file; - struct sheet_spec_page *ssp = &ia->sheet_spec; + struct sheet_spec_page *ssp = ia->sheet_spec; struct casereader *creader = NULL; struct dictionary *dict = NULL; diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 385af3e2bd..b8d357a713 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -71,18 +71,17 @@ void text_data_import_assistant (PsppireDataWindow *dw) { GtkWindow *parent_window = GTK_WINDOW (dw); - struct import_assistant *ia; + struct import_assistant *ia = init_assistant (parent_window); struct sheet_spec_page *ssp ; - ia = xzalloc (sizeof *ia); if (!init_file (ia, parent_window)) { free (ia); return; } - init_assistant (ia, parent_window); - ssp = &ia->sheet_spec; + + ssp = ia->sheet_spec; if (ssp->spreadsheet == NULL) { init_intro_page (ia); @@ -213,7 +212,7 @@ apply_dict (const struct dictionary *dict, struct string *s) static char * generate_syntax (const struct import_assistant *ia) { - struct sheet_spec_page *ssp = &ia->sheet_spec; + struct sheet_spec_page *ssp = ia->sheet_spec; struct string s = DS_EMPTY_INITIALIZER; @@ -229,46 +228,46 @@ generate_syntax (const struct import_assistant *ia) if (ia->file.encoding && strcmp (ia->file.encoding, "Auto")) syntax_gen_pspp (&s, " /ENCODING=%sq\n", ia->file.encoding); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( - ia->intro.n_cases_button))) + ia->intro->n_cases_button))) ds_put_format (&s, " /IMPORTCASES=FIRST %d\n", gtk_spin_button_get_value_as_int ( - GTK_SPIN_BUTTON (ia->intro.n_cases_spin))); + GTK_SPIN_BUTTON (ia->intro->n_cases_spin))); else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( - ia->intro.percent_button))) + ia->intro->percent_button))) ds_put_format (&s, " /IMPORTCASES=PERCENT %d\n", gtk_spin_button_get_value_as_int ( - GTK_SPIN_BUTTON (ia->intro.percent_spin))); + GTK_SPIN_BUTTON (ia->intro->percent_spin))); else ds_put_cstr (&s, " /IMPORTCASES=ALL\n"); ds_put_cstr (&s, " /ARRANGEMENT=DELIMITED\n" " /DELCASE=LINE\n"); - if (ia->first_line.skip_lines > 0) - ds_put_format (&s, " /FIRSTCASE=%d\n", ia->first_line.skip_lines + 1); + if (ia->first_line->skip_lines > 0) + ds_put_format (&s, " /FIRSTCASE=%d\n", ia->first_line->skip_lines + 1); ds_put_cstr (&s, " /DELIMITERS=\""); - if (ds_find_byte (&ia->separators.separators, '\t') != SIZE_MAX) + if (ds_find_byte (&ia->separators->separators, '\t') != SIZE_MAX) ds_put_cstr (&s, "\\t"); - if (ds_find_byte (&ia->separators.separators, '\\') != SIZE_MAX) + if (ds_find_byte (&ia->separators->separators, '\\') != SIZE_MAX) ds_put_cstr (&s, "\\\\"); - for (i = 0; i < ds_length (&ia->separators.separators); i++) + for (i = 0; i < ds_length (&ia->separators->separators); i++) { - char c = ds_at (&ia->separators.separators, i); + char c = ds_at (&ia->separators->separators, i); if (c == '"') ds_put_cstr (&s, "\"\""); else if (c != '\t' && c != '\\') ds_put_byte (&s, c); } ds_put_cstr (&s, "\"\n"); - if (!ds_is_empty (&ia->separators.quotes)) - syntax_gen_pspp (&s, " /QUALIFIER=%sq\n", ds_cstr (&ia->separators.quotes)); - if (!ds_is_empty (&ia->separators.quotes) && ia->separators.escape) + if (!ds_is_empty (&ia->separators->quotes)) + syntax_gen_pspp (&s, " /QUALIFIER=%sq\n", ds_cstr (&ia->separators->quotes)); + if (!ds_is_empty (&ia->separators->quotes) && ia->separators->escape) ds_put_cstr (&s, " /ESCAPE\n"); ds_put_cstr (&s, " /VARIABLES=\n"); - var_cnt = dict_get_var_cnt (ia->formats.dict); + var_cnt = dict_get_var_cnt (ia->formats->dict); for (i = 0; i < var_cnt; i++) { - struct variable *var = dict_get_var (ia->formats.dict, i); + struct variable *var = dict_get_var (ia->formats->dict, i); char format_string[FMT_STRING_LEN_MAX + 1]; fmt_to_string (var_get_print_format (var), format_string); ds_put_format (&s, " %s %s%s\n", @@ -276,11 +275,11 @@ generate_syntax (const struct import_assistant *ia) i == var_cnt - 1 ? "." : ""); } - apply_dict (ia->formats.dict, &s); + apply_dict (ia->formats->dict, &s); } else { - const struct sheet_spec_page *ssp = &ia->sheet_spec; + const struct sheet_spec_page *ssp = ia->sheet_spec; printf ("%s:%d %p %d\n", __FILE__, __LINE__, ssp->spreadsheet, ssp->spreadsheet->type); @@ -343,8 +342,8 @@ render_input_cell (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, 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; - field = ia->separators.columns[column].contents[row]; + row = empty_list_store_iter_to_row (iter) + ia->first_line->skip_lines; + field = ia->separators->columns[column].contents[row]; if (field.string != NULL) { GValue text = {0, }; @@ -380,7 +379,7 @@ on_query_input_tooltip (GtkWidget *widget, gint wx, gint wy, if (!get_tooltip_location (widget, wx, wy, ia, &row, &column)) return FALSE; - if (ia->separators.columns[column].contents[row].string != NULL) + if (ia->separators->columns[column].contents[row].string != NULL) return FALSE; gtk_tooltip_set_text (tooltip, @@ -410,8 +409,8 @@ parse_field (struct import_assistant *ia, char *tooltip; bool ok; - field = ia->separators.columns[column].contents[row]; - var = dict_get_var (ia->formats.dict, column); + field = ia->separators->columns[column].contents[row]; + var = dict_get_var (ia->formats->dict, column); value_init (&val, var_get_width (var)); in = var_get_print_format (var); out = fmt_for_output_from_input (in); @@ -421,7 +420,7 @@ parse_field (struct import_assistant *ia, 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->formats->dict)); if (error != NULL) { tooltip = xasprintf (_("Cannot parse field content `%.*s' as " @@ -439,7 +438,7 @@ parse_field (struct import_assistant *ia, } if (outputp != NULL) { - *outputp = data_out (&val, dict_get_encoding (ia->formats.dict), &out); + *outputp = data_out (&val, dict_get_encoding (ia->formats->dict), &out); } value_destroy (&val, var_get_width (var)); @@ -467,7 +466,7 @@ render_output_cell (GtkTreeViewColumn *tree_column, ok = parse_field (ia, (empty_list_store_iter_to_row (iter) - + ia->first_line.skip_lines), + + ia->first_line->skip_lines), GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_column), "column-number")), &output, NULL); @@ -550,7 +549,7 @@ get_tooltip_location (GtkWidget *widget, gint wx, gint wy, 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->first_line->skip_lines; return TRUE; } @@ -646,9 +645,9 @@ make_data_column (struct import_assistant *ia, GtkTreeView *tree_view, char *name; if (input) - column = &ia->separators.columns[dict_idx]; + column = &ia->separators->columns[dict_idx]; else - var = dict_get_var (ia->formats.dict, dict_idx); + var = dict_get_var (ia->formats->dict, dict_idx); name = escape_underscores (input ? column->name : var_get_name (var)); char_cnt = input ? column->width : var_get_print_format (var)->w; @@ -682,11 +681,11 @@ create_data_tree_view (bool input, GtkContainer *parent, GtkTreeView *tree_view; gint i; - make_tree_view (ia, ia->first_line.skip_lines, &tree_view); + make_tree_view (ia, ia->first_line->skip_lines, &tree_view); gtk_tree_selection_set_mode (gtk_tree_view_get_selection (tree_view), GTK_SELECTION_NONE); - for (i = 0; i < ia->separators.column_cnt; i++) + for (i = 0; i < ia->separators->column_cnt; i++) gtk_tree_view_append_column (tree_view, make_data_column (ia, tree_view, input, i)); diff --git a/src/ui/gui/text-data-import-dialog.h b/src/ui/gui/text-data-import-dialog.h index 561c0405bf..3b8a987e0d 100644 --- a/src/ui/gui/text-data-import-dialog.h +++ b/src/ui/gui/text-data-import-dialog.h @@ -130,11 +130,12 @@ struct import_assistant { struct file file; struct assistant asst; - struct intro_page intro; - struct sheet_spec_page sheet_spec; - struct first_line_page first_line; - struct separators_page separators; - struct formats_page formats; + + struct intro_page *intro; + struct sheet_spec_page *sheet_spec; + struct first_line_page *first_line; + struct separators_page *separators; + struct formats_page *formats; }; @@ -223,7 +224,7 @@ void prepare_formats_page (struct import_assistant *ia); void reset_formats_page (struct import_assistant *); void destroy_formats_page (struct import_assistant *ia); -void init_assistant (struct import_assistant *, GtkWindow *); +struct import_assistant * init_assistant (GtkWindow *); void destroy_assistant (struct import_assistant *);