Put the pages as pointers
[pspp] / src / ui / gui / page-assistant.c
index 70c658d371e04c7957b9745de63f2a52b22964a0..9c95005e4d02820d5472653b146d19ef0bca568c 100644 (file)
@@ -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,9 +158,11 @@ static void
 on_prepare (GtkAssistant *assistant, GtkWidget *page,
             struct import_assistant *ia)
 {
+  struct sheet_spec_page *ssp = ia->sheet_spec;
+
   int pn = gtk_assistant_get_current_page (assistant);
 
-  if (pn == 1 && ia->file.type != FTYPE_TEXT)
+  if (pn == 1 && ssp->spreadsheet)
     post_sheet_spec_page (ia);
 
   if (gtk_assistant_get_page_type (assistant, page)
@@ -159,13 +171,21 @@ on_prepare (GtkAssistant *assistant, GtkWidget *page,
   else
     gtk_widget_grab_focus (assistant->forward);
 
-  if (page == ia->separators.page)
+
+  /* Prepare .... */
+  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)
+    {
+      prepare_sheet_spec_page (ia);
+    }
+
 
+  
   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);
@@ -201,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);
 }