Whitespace changes only
[pspp] / src / ui / gui / page-intro.c
index 4034834c345957f2905f11d657e4fe4c22bfa5f5..6db2bee688ffe6fe2b73461a2682ef8e674ae991 100644 (file)
 
 #include <config.h>
 
+#include "page-intro.h"
+
 #include "ui/gui/text-data-import-dialog.h"
 
 #include <errno.h>
 #include <fcntl.h>
-#include <gtk-contrib/psppire-sheet.h>
 #include <gtk/gtk.h>
 #include <limits.h>
 #include <stdlib.h>
@@ -36,7 +37,6 @@
 #include "libpspp/i18n.h"
 #include "libpspp/line-reader.h"
 #include "libpspp/message.h"
-#include "ui/gui/checkbox-treeview.h"
 #include "ui/gui/dialog-common.h"
 #include "ui/gui/executor.h"
 #include "ui/gui/helper.h"
 #include "ui/gui/psppire-encoding-selector.h"
 #include "ui/gui/psppire-empty-list-store.h"
 #include "ui/gui/psppire-var-sheet.h"
-#include "ui/gui/psppire-var-store.h"
 #include "ui/gui/psppire-scanf.h"
 #include "ui/syntax-gen.h"
 
-#include "gl/error.h"
 #include "gl/intprops.h"
 #include "gl/xalloc.h"
 
@@ -64,6 +62,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. */
@@ -84,17 +93,17 @@ intro_page_create (struct import_assistant *ia)
 
   table  = get_widget_assert (builder, "button-table");
 
-  gtk_table_attach_defaults (GTK_TABLE (table), hbox_n_cases,
-                   1, 2,
-                   1, 2);
+  gtk_grid_attach (GTK_GRID (table), hbox_n_cases,
+                   1, 1,
+                   1, 1);
 
   p->percent_spin = gtk_spin_button_new_with_range (0, 100, 10);
 
   hbox_percent = psppire_scanf_new (_("Only the first %3d %% of file (approximately)"), &p->percent_spin);
 
-  gtk_table_attach_defaults (GTK_TABLE (table), hbox_percent,
-                            1, 2,
-                            2, 3);
+  gtk_grid_attach (GTK_GRID (table), hbox_percent,
+                  1, 2,
+                  1, 1);
 
   p->page = add_page_to_assistant (ia, get_widget_assert (builder, "Intro"),
                                    GTK_ASSISTANT_PAGE_INTRO);
@@ -121,16 +130,16 @@ intro_page_create (struct import_assistant *ia)
                      "commas, or other delimiters.\n\n"));
   if (ia->file.total_is_exact)
     ds_put_format (
-      &s, ngettext ("The selected file contains %zu line of text.  ",
-                    "The selected file contains %zu lines of text.  ",
+      &s, ngettext ("The selected file contains %'zu line of text.  ",
+                    "The selected file contains %'zu lines of text.  ",
                     ia->file.line_cnt),
       ia->file.line_cnt);
   else if (ia->file.total_lines > 0)
     {
       ds_put_format (
         &s, ngettext (
-          "The selected file contains approximately %lu line of text.  ",
-          "The selected file contains approximately %lu lines of text.  ",
+          "The selected file contains approximately %'lu line of text.  ",
+          "The selected file contains approximately %'lu lines of text.  ",
           ia->file.total_lines),
         ia->file.total_lines);
       ds_put_format (
@@ -171,3 +180,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, "  /IMPORTCASE=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, "  /IMPORTCASE=PERCENT %d\n",
+                  gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (p->percent_spin)));
+  else
+    ds_put_cstr (s, "  /IMPORTCASE=ALL\n");
+}