#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>
#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"
\f
/* The "intro" page of the assistant. */
-static void on_intro_amount_changed (struct import_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. */
-void
-init_intro_page (struct import_assistant *ia)
+struct intro_page *
+intro_page_create (struct import_assistant *ia)
{
GtkBuilder *builder = ia->asst.builder;
- struct intro_page *p = ia->intro;
struct string s;
GtkWidget *hbox_n_cases ;
GtkWidget *hbox_percent ;
GtkWidget *table ;
+ struct intro_page *p = xzalloc (sizeof (*p));
p->n_cases_spin = gtk_spin_button_new_with_range (0, INT_MAX, 100);
p->percent_button = get_widget_assert (builder, "import-percent");
g_signal_connect_swapped (p->all_cases_button, "toggled",
- G_CALLBACK (on_intro_amount_changed), ia);
+ G_CALLBACK (on_intro_amount_changed), p);
g_signal_connect_swapped (p->n_cases_button, "toggled",
- G_CALLBACK (on_intro_amount_changed), ia);
+ G_CALLBACK (on_intro_amount_changed), p);
g_signal_connect_swapped (p->percent_button, "toggled",
- G_CALLBACK (on_intro_amount_changed), ia);
+ G_CALLBACK (on_intro_amount_changed), p);
- on_intro_amount_changed (ia);
+ on_intro_amount_changed (p);
ds_init_empty (&s);
ds_put_cstr (&s, _("This assistant will guide you through the process of "
"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 (
gtk_label_set_text (GTK_LABEL (get_widget_assert (builder, "intro-label")),
ds_cstr (&s));
ds_destroy (&s);
+
+ return p;
}
/* Resets IA's intro page to its initial state. */
/* Called when one of the radio buttons is clicked. */
static void
-on_intro_amount_changed (struct import_assistant *ia)
+on_intro_amount_changed (struct intro_page *p)
{
- struct intro_page *p = ia->intro;
-
gtk_widget_set_sensitive (p->n_cases_spin,
gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (p->n_cases_button)));
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");
+}