Move all intro related stuff to the intro file
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 23 Jan 2013 18:08:36 +0000 (19:08 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 16 Feb 2013 14:03:18 +0000 (15:03 +0100)
src/ui/gui/page-assistant.c
src/ui/gui/page-intro.c
src/ui/gui/text-data-import-dialog.c
src/ui/gui/text-data-import-dialog.h

index 1ebc7405fedd210f564312a54f5efb96bf09c8fe..e7dd02de2767c6502733110c6054fcf896e1d46b 100644 (file)
@@ -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
index 4034834c345957f2905f11d657e4fe4c22bfa5f5..0a8306a05ca2eba77c19d65d8c4e63c396def7ac 100644 (file)
@@ -64,6 +64,17 @@ struct import_assistant;
 \f
 /* 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");
+}
index 6d7e0777db4ebb27fcb4163dbfed204267fe2a61..c2de780328d9462a8c1e88a7b5fbb84771640902 100644 (file)
@@ -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");
index 3b8a987e0dfa9a172b224d31e74c45e49e939e8e..b7268235fbe49f2bb5ed263f48ec4000bd7cc61a 100644 (file)
@@ -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 *);