From 7a187ebfbb18802df6b5a11b2eaf244a209dff4f Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 23 Jan 2013 19:08:36 +0100 Subject: [PATCH] Move all intro related stuff to the intro file --- src/ui/gui/page-assistant.c | 6 ++++++ src/ui/gui/page-intro.c | 27 +++++++++++++++++++++++++++ src/ui/gui/text-data-import-dialog.c | 15 +++------------ src/ui/gui/text-data-import-dialog.h | 15 --------------- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/ui/gui/page-assistant.c b/src/ui/gui/page-assistant.c index 1ebc7405fe..e7dd02de27 100644 --- a/src/ui/gui/page-assistant.c +++ b/src/ui/gui/page-assistant.c @@ -85,6 +85,7 @@ init_assistant (GtkWindow *parent_window) ia->separators = xzalloc (sizeof *ia->separators); 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); @@ -161,7 +162,9 @@ on_prepare (GtkAssistant *assistant, GtkWidget *page, struct sheet_spec_page *ssp = ia->sheet_spec; int pn = gtk_assistant_get_current_page (assistant); + g_print ("%s:%d Page %d %p\n", __FILE__, __LINE__, pn, page); +#if 0 if (pn == 1 && ssp->spreadsheet) post_sheet_spec_page (ia); @@ -183,6 +186,7 @@ on_prepare (GtkAssistant *assistant, GtkWidget *page, } +#endif gtk_widget_show (ia->asst.reset_button); if (page == ia->formats->page) @@ -218,6 +222,7 @@ on_paste (GtkButton *button, struct import_assistant *ia) static void on_reset (GtkButton *button, struct import_assistant *ia) { +#if 0 gint page_num = gtk_assistant_get_current_page (ia->asst.assistant); GtkWidget *page = gtk_assistant_get_nth_page (ia->asst.assistant, page_num); @@ -231,6 +236,7 @@ on_reset (GtkButton *button, struct import_assistant *ia) reset_formats_page (ia); else if (page == ia->sheet_spec->page) reset_sheet_spec_page (ia); +#endif } /* Causes the assistant to close, returning RESPONSE for diff --git a/src/ui/gui/page-intro.c b/src/ui/gui/page-intro.c index 4034834c34..0a8306a05c 100644 --- a/src/ui/gui/page-intro.c +++ b/src/ui/gui/page-intro.c @@ -64,6 +64,17 @@ struct import_assistant; /* The "intro" page of the assistant. */ +/* The introduction page of the assistant. */ +struct intro_page + { + GtkWidget *page; + GtkWidget *all_cases_button; + GtkWidget *n_cases_button; + GtkWidget *n_cases_spin; + GtkWidget *percent_button; + GtkWidget *percent_spin; + }; + static void on_intro_amount_changed (struct intro_page *); /* Initializes IA's intro substructure. */ @@ -98,6 +109,8 @@ intro_page_create (struct import_assistant *ia) p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Intro"), GTK_ASSISTANT_PAGE_INTRO); + + g_print ("%s:%d Added page %p\n", __FILE__, __LINE__, p->page); p->all_cases_button = get_widget_assert (builder, "import-all-cases"); @@ -171,3 +184,17 @@ on_intro_amount_changed (struct intro_page *p) gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON (p->percent_button))); } + + +void +intro_append_syntax (const struct intro_page *p, struct string *s) +{ + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (p->n_cases_button))) + ds_put_format (s, " /IMPORTCASES=FIRST %d\n", + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (p->n_cases_spin))); + else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (p->percent_button))) + ds_put_format (s, " /IMPORTCASES=PERCENT %d\n", + gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (p->percent_spin))); + else + ds_put_cstr (s, " /IMPORTCASES=ALL\n"); +} diff --git a/src/ui/gui/text-data-import-dialog.c b/src/ui/gui/text-data-import-dialog.c index 6d7e0777db..c2de780328 100644 --- a/src/ui/gui/text-data-import-dialog.c +++ b/src/ui/gui/text-data-import-dialog.c @@ -225,18 +225,9 @@ generate_syntax (const struct import_assistant *ia) ia->file.file_name); 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))) - ds_put_format (&s, " /IMPORTCASES=FIRST %d\n", - gtk_spin_button_get_value_as_int ( - GTK_SPIN_BUTTON (ia->intro->n_cases_spin))); - else if (gtk_toggle_button_get_active (GTK_TOGGLE_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))); - else - ds_put_cstr (&s, " /IMPORTCASES=ALL\n"); + + intro_append_syntax (ia->intro, &s); + ds_put_cstr (&s, " /ARRANGEMENT=DELIMITED\n" " /DELCASE=LINE\n"); diff --git a/src/ui/gui/text-data-import-dialog.h b/src/ui/gui/text-data-import-dialog.h index 3b8a987e0d..b7268235fb 100644 --- a/src/ui/gui/text-data-import-dialog.h +++ b/src/ui/gui/text-data-import-dialog.h @@ -68,17 +68,6 @@ struct sheet_spec_page }; -/* The introduction page of the assistant. */ -struct intro_page - { - GtkWidget *page; - GtkWidget *all_cases_button; - GtkWidget *n_cases_button; - GtkWidget *n_cases_spin; - GtkWidget *percent_button; - GtkWidget *percent_spin; - }; - /* Page where the user chooses the first line of data. */ struct first_line_page { @@ -197,14 +186,10 @@ GtkTreeViewColumn *make_data_column (struct import_assistant *, void update_assistant (struct import_assistant *ia); - bool init_file (struct import_assistant *ia, GtkWindow *parent_window); void destroy_file (struct import_assistant *ia); -void init_intro_page (struct import_assistant *); -void reset_intro_page (struct import_assistant *); - 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 *); -- 2.30.2