#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 "gl/error.h"
#include "gl/intprops.h"
#include "gl/xalloc.h"
static void on_close (GtkAssistant *assistant, struct import_assistant *);
static void on_paste (GtkButton *button, struct import_assistant *);
static void on_reset (GtkButton *button, struct import_assistant *);
-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. */
a->builder = builder_new ("text-data-import.ui");
a->assistant = GTK_ASSISTANT (gtk_assistant_new ());
- ia->sheet_spec = sheet_spec_page_create (ia);
- ia->intro = intro_page_create (ia);
- ia->separators = separators_page_create (ia);
-
-
a->prop_renderer = gtk_cell_renderer_text_new ();
g_object_ref_sink (a->prop_renderer);
a->fixed_renderer = gtk_cell_renderer_text_new ();
"family", "Monospace",
(void *) NULL);
- ia->first_line = first_line_page_create (ia);
-
- ia->formats = xzalloc (sizeof *ia->formats);
-
-
-
g_signal_connect (a->assistant, "prepare", G_CALLBACK (on_prepare), ia);
g_signal_connect (a->assistant, "cancel", G_CALLBACK (on_cancel), ia);
g_signal_connect (a->assistant, "close", G_CALLBACK (on_close), ia);
gtk_window_set_transient_for (GTK_WINDOW (a->assistant), parent_window);
gtk_window_set_icon_name (GTK_WINDOW (a->assistant), "pspp");
+
return ia;
}
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);
- g_print ("%s:%d Page %d %p\n", __FILE__, __LINE__, pn, page);
-#if 0
- if (pn == 1 && ssp->spreadsheet)
- post_sheet_spec_page (ia);
+ gtk_widget_show (ia->asst.reset_button);
+ gtk_widget_hide (ia->asst.paste_button);
- if (gtk_assistant_get_page_type (assistant, page)
- == GTK_ASSISTANT_PAGE_CONFIRM)
- gtk_widget_grab_focus (assistant->apply);
+ if ( ia->spreadsheet)
+ {
+ if (pn == 0)
+ {
+ prepare_sheet_spec_page (ia);
+ }
+ else if (pn == 1)
+ {
+ post_sheet_spec_page (ia);
+ prepare_formats_page (ia);
+ }
+ }
else
- gtk_widget_grab_focus (assistant->forward);
-
-
- /* Prepare .... */
- if (page == ia->separators->page)
- prepare_separators_page (ia);
- else if (page == ia->formats->page)
- prepare_formats_page (ia);
- else if (page == ia->sheet_spec->page && ssp->spreadsheet)
{
- prepare_sheet_spec_page (ia);
+ switch (pn)
+ {
+ case 0:
+ reset_intro_page (ia);
+ break;
+ case 1:
+ reset_first_line_page (ia);
+ break;
+ case 2:
+ prepare_separators_page (ia);
+ reset_separators_page (ia);
+ break;
+ case 3:
+ prepare_formats_page (ia);
+ reset_formats_page (ia);
+ break;
+ }
}
-#endif
-
- gtk_widget_show (ia->asst.reset_button);
- if (page == ia->formats->page)
- gtk_widget_show (ia->asst.paste_button);
+ if (gtk_assistant_get_page_type (assistant, page)
+ == GTK_ASSISTANT_PAGE_CONFIRM)
+ gtk_widget_grab_focus (assistant->apply);
else
- gtk_widget_hide (ia->asst.paste_button);
+ gtk_widget_grab_focus (assistant->forward);
}
/* Called when the Cancel button in the assistant is clicked. */
static void
on_reset (GtkButton *button, struct import_assistant *ia)
{
-#if 0
- 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)
- reset_intro_page (ia);
- else if (page == ia->first_line->page)
- reset_first_line_page (ia);
- else if (page == ia->separators->page)
- reset_separators_page (ia);
- else if (page == ia->formats->page)
- reset_formats_page (ia);
- else if (page == ia->sheet_spec->page)
- reset_sheet_spec_page (ia);
-#endif
+ gint pn = gtk_assistant_get_current_page (ia->asst.assistant);
+
+ if ( ia->spreadsheet)
+ {
+ switch (pn)
+ {
+ case 0:
+ reset_sheet_spec_page (ia);
+ break;
+ case 1:
+ reset_formats_page (ia);
+ break;
+ }
+ }
+ else
+ {
+ switch (pn)
+ {
+ case 0:
+ reset_intro_page (ia);
+ break;
+ case 1:
+ reset_first_line_page (ia);
+ break;
+ case 2:
+ reset_separators_page (ia);
+ break;
+ case 3:
+ reset_formats_page (ia);
+ break;
+ }
+ }
}
/* Causes the assistant to close, returning RESPONSE for
close_assistant (struct import_assistant *ia, int response)
{
ia->asst.response = response;
- g_main_loop_quit (ia->asst.main_loop);
+ /* Use our loop_done variable until we find out
+ why g_main_loop_quit (ia->asst.main_loop); doesn't work.
+ */
+ ia->asst.loop_done = true;
gtk_widget_hide (GTK_WIDGET (ia->asst.assistant));
}