Import assistant: Simplify the construction of the introductory page
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 5 Jun 2017 13:33:07 +0000 (15:33 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 6 Jun 2017 05:58:29 +0000 (07:58 +0200)
src/ui/gui/psppire-import-assistant.c

index 2eecd7a10589180cb819700b0bee0e9e436cf745..ecedef692061e5dfd49a606d02d0afc294447e98 100644 (file)
@@ -910,43 +910,27 @@ intro_on_enter (PsppireImportAssistant *ia)
                       ds_cstr (&s));
   ds_destroy (&s);
 
-  GtkWidget *w  =  gtk_grid_get_child_at (GTK_GRID (table), 1, 1);
-  int old_value = w ? gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (ia->n_cases_spin)) : 1;
-  if (w)
-    gtk_container_remove (GTK_CONTAINER (table), w);
-
-  w  =  gtk_grid_get_child_at (GTK_GRID (table), 1, 2);
-  if (w)
-    gtk_container_remove (GTK_CONTAINER (table), w);
-
-
-  GtkWidget *hbox_n_cases = psppire_scanf_new (_("Only the first %4d cases"), &ia->n_cases_spin);
+  if (gtk_grid_get_child_at (GTK_GRID (table), 1, 1) == NULL)
+    {
+      GtkWidget *hbox_n_cases = psppire_scanf_new (_("Only the first %4d cases"), &ia->n_cases_spin);
+      gtk_grid_attach (GTK_GRID (table), hbox_n_cases,
+                      1, 1,
+                      1, 1);
+    }
 
   GtkAdjustment *adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (ia->n_cases_spin));
   gtk_adjustment_set_lower (adj, 1.0);
 
-  if (ia->text_file)
-    {
-      if (psppire_text_file_get_total_exact (ia->text_file))
-       {
-         gulong total_lines = psppire_text_file_get_n_lines (ia->text_file);
-         gtk_adjustment_set_upper (adj, total_lines);
-         gtk_adjustment_set_value (adj, old_value);
-       }
-      else
-       gtk_adjustment_set_upper (adj, DBL_MAX);
-    }
-  gtk_grid_attach (GTK_GRID (table), hbox_n_cases,
-                  1, 1,
-                  1, 1);
-
 
-  GtkWidget *hbox_percent = psppire_scanf_new (_("Only the first %3d %% of file (approximately)"),
-                                              &ia->percent_spin);
+  if (gtk_grid_get_child_at (GTK_GRID (table), 1, 2) == NULL)
+    {
+      GtkWidget *hbox_percent = psppire_scanf_new (_("Only the first %3d %% of file (approximately)"),
+                                                  &ia->percent_spin);
 
-  gtk_grid_attach (GTK_GRID (table), hbox_percent,
-                  1, 2,
-                  1, 1);
+      gtk_grid_attach (GTK_GRID (table), hbox_percent,
+                      1, 2,
+                      1, 1);
+    }
 
   gtk_widget_show_all (table);