X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fui%2Fgui%2Fpage-assistant.c;h=cad23763de75dcbb99834074ee6d4e40d9e26374;hb=8870ca57b746c93b91fb740927fcda45643499d2;hp=1ebc7405fedd210f564312a54f5efb96bf09c8fe;hpb=a654213065a03c99b868ebad39286c1c5e06a38e;p=pspp diff --git a/src/ui/gui/page-assistant.c b/src/ui/gui/page-assistant.c index 1ebc7405fe..cad23763de 100644 --- a/src/ui/gui/page-assistant.c +++ b/src/ui/gui/page-assistant.c @@ -65,25 +65,25 @@ static void on_cancel (GtkAssistant *assistant, struct import_assistant *); 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. */ struct import_assistant * init_assistant (GtkWindow *parent_window) { - struct import_assistant *ia = NULL; - ia = xzalloc (sizeof *ia); + struct import_assistant *ia = xzalloc (sizeof *ia); struct assistant *a = &ia->asst; a->builder = builder_new ("text-data-import.ui"); a->assistant = GTK_ASSISTANT (gtk_assistant_new ()); - ia->intro = intro_page_create (ia); - ia->sheet_spec = xzalloc (sizeof *ia->sheet_spec); - ia->first_line = xzalloc (sizeof *ia->first_line); - ia->separators = xzalloc (sizeof *ia->separators); - ia->formats = xzalloc (sizeof *ia->formats); + a->prop_renderer = gtk_cell_renderer_text_new (); + g_object_ref_sink (a->prop_renderer); + a->fixed_renderer = gtk_cell_renderer_text_new (); + g_object_ref_sink (a->fixed_renderer); + g_object_set (G_OBJECT (a->fixed_renderer), + "family", "Monospace", + (void *) NULL); g_signal_connect (a->assistant, "prepare", G_CALLBACK (on_prepare), ia); g_signal_connect (a->assistant, "cancel", G_CALLBACK (on_cancel), ia); @@ -99,13 +99,7 @@ init_assistant (GtkWindow *parent_window) gtk_window_set_transient_for (GTK_WINDOW (a->assistant), parent_window); gtk_window_set_icon_name (GTK_WINDOW (a->assistant), "pspp"); - a->prop_renderer = gtk_cell_renderer_text_new (); - g_object_ref_sink (a->prop_renderer); - a->fixed_renderer = gtk_cell_renderer_text_new (); - g_object_ref_sink (a->fixed_renderer); - g_object_set (G_OBJECT (a->fixed_renderer), - "family", "Monospace", - (void *) NULL); + return ia; } @@ -158,37 +152,37 @@ static void 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); - 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); + if (pn == 0) + prepare_separators_page (ia); + else if (pn == 3) + prepare_formats_page (ia); } - - 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. */ @@ -214,6 +208,15 @@ on_paste (GtkButton *button, struct import_assistant *ia) close_assistant (ia, PSPPIRE_RESPONSE_PASTE); } +static GtkWidget * +assist_get_page (struct assist_page *ap) +{ + if (ap == NULL) + return NULL; + + return ap->page; +} + /* Called when the Reset button is clicked. */ static void on_reset (GtkButton *button, struct import_assistant *ia) @@ -221,15 +224,15 @@ on_reset (GtkButton *button, struct import_assistant *ia) 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) + if (page == assist_get_page ((struct assist_page *) ia->intro)) reset_intro_page (ia); - else if (page == ia->first_line->page) + else if (page == assist_get_page ((struct assist_page *) ia->first_line)) reset_first_line_page (ia); - else if (page == ia->separators->page) + else if (page == assist_get_page ((struct assist_page *) ia->separators)) reset_separators_page (ia); - else if (page == ia->formats->page) + else if (page == assist_get_page ((struct assist_page *) ia->formats)) reset_formats_page (ia); - else if (page == ia->sheet_spec->page) + else if (page == assist_get_page ((struct assist_page *) ia->sheet_spec)) reset_sheet_spec_page (ia); } @@ -239,7 +242,10 @@ static void 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)); }