X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpage-intro.c;h=59c252b46cb2ade898b2808b2db41543a9e08c9f;hb=159abf428abd3028a73d064508fac95e542d9f09;hp=56b182686c2502c2a186ce37854341624a3a6367;hpb=001db1bf60acf85491463edcd557aad6e661195c;p=pspp diff --git a/src/ui/gui/page-intro.c b/src/ui/gui/page-intro.c index 56b182686c..59c252b46c 100644 --- a/src/ui/gui/page-intro.c +++ b/src/ui/gui/page-intro.c @@ -16,11 +16,12 @@ #include +#include "page-intro.h" + #include "ui/gui/text-data-import-dialog.h" #include #include -#include #include #include #include @@ -46,7 +47,6 @@ #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" @@ -64,19 +64,30 @@ struct import_assistant; /* 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); @@ -106,13 +117,13 @@ init_intro_page (struct import_assistant *ia) 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 " @@ -147,6 +158,8 @@ init_intro_page (struct import_assistant *ia) 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. */ @@ -159,10 +172,8 @@ reset_intro_page (struct import_assistant *ia) /* 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))); @@ -171,3 +182,17 @@ on_intro_amount_changed (struct import_assistant *ia) 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"); +}