[evolution] Bug #596720 - Account assistance repeats itself after finishing



commit c655c9f3ec59a83b08903355def83d89ff1f1a93
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 12 11:44:25 2009 +0200

    Bug #596720 - Account assistance repeats itself after finishing

 e-util/e-config.c        |   13 +++++++++----
 mail/em-account-editor.c |   25 ++++++++++++++++++-------
 2 files changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/e-util/e-config.c b/e-util/e-config.c
index 9d2a407..69a6cc7 100644
--- a/e-util/e-config.c
+++ b/e-util/e-config.c
@@ -467,8 +467,8 @@ ec_assistant_forward (gint current_page, gpointer user_data)
 	}
 
 	if (wn && wn->next) {
-		d(printf(" is %s\n",wn->item->path));
 		ec_assistant_find_page (ec, wn->frame, &next_page);
+		d(printf(" is %s (%d)\n",wn->item->path, next_page));
 	}
 
 	return next_page;
@@ -619,7 +619,8 @@ ec_rebuild (EConfig *emp)
 				break;
 			}
 
-			if (wn->widget == NULL) {
+			if (item->type == E_CONFIG_PAGE_FINISH || wn->widget == NULL) {
+				/* always rebuild finish page, to have it as the last page */
 				if (item->factory) {
 					page = item->factory(emp, item, root, wn->frame, wn->context->data);
 				} else {
@@ -639,15 +640,19 @@ ec_rebuild (EConfig *emp)
 					gtk_widget_show_all (page);
 				}
 
+				if (wn->widget != NULL && wn->widget != page) {
+					gtk_widget_destroy (wn->widget);
+				}
+
 				wn->frame = page;
 				wn->widget = page;
 
 				if (page) {
 					const gchar *empty_xpm_img[] = {
-						"48 1 2 1",
+						"75 1 2 1",
 						" 	c None",
 						".	c #FFFFFF",
-						"                                                "};
+						"                                                                           "};
 
 					/* left side place with a blue background on a start and finish page */
 					GdkPixbuf *spacer = gdk_pixbuf_new_from_xpm_data (empty_xpm_img);
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index f12f530..8794c13 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -2062,12 +2062,13 @@ emae_setup_service (EMAccountEditor *emae, EMAccountEditorService *service, Glad
 }
 
 static GtkWidget *
-emae_create_basic_assistant_page (GtkAssistant *assistant, const gchar *page_id)
+emae_create_basic_assistant_page (GtkAssistant *assistant, const gchar *page_id, GtkWidget *old)
 {
 	const gchar *title = NULL, *label = NULL;
 	GtkAssistantPageType page_type = GTK_ASSISTANT_PAGE_CONTENT;
 	GtkWidget *vbox, *lbl;
 	gboolean fill_space = FALSE;
+	gint index = -1;
 
 	g_return_val_if_fail (page_id != NULL, NULL);
 
@@ -2107,7 +2108,17 @@ emae_create_basic_assistant_page (GtkAssistant *assistant, const gchar *page_id)
 	gtk_box_pack_start (GTK_BOX (vbox), lbl, fill_space, fill_space, 0);
 	gtk_widget_show (lbl);
 
-	gtk_assistant_append_page (assistant, vbox);
+	if (old) {
+		/* keep page on its previous index */
+		gint i, sz = gtk_assistant_get_n_pages (assistant);
+
+		for (i = 0; i < sz && index == -1; i++) {
+			if (gtk_assistant_get_nth_page (assistant, i) == old)
+				index = i;
+		}
+	}
+
+	gtk_assistant_insert_page (assistant, vbox, index);
 	gtk_assistant_set_page_title (assistant, vbox, title);
 	gtk_assistant_set_page_type (assistant, vbox, page_type);
 
@@ -2196,7 +2207,7 @@ emae_identity_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget
 	if (emae->type == EMAE_PAGES) {
 		gtk_box_pack_start ((GtkBox *)emae->pages[0], w, TRUE, TRUE, 0);
 	} else if (((EConfig *)gui->config)->type == E_CONFIG_ASSISTANT) {
-		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "identity_page");
+		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "identity_page", old);
 
 		gtk_box_pack_start (GTK_BOX (page), w, TRUE, TRUE, 0);
 
@@ -2237,7 +2248,7 @@ emae_receive_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget
 	if (emae->type == EMAE_PAGES) {
 		gtk_box_pack_start ((GtkBox *)emae->pages[1], w, TRUE, TRUE, 0);
 	} else if (((EConfig *)gui->config)->type == E_CONFIG_ASSISTANT) {
-		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "source_page");
+		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "source_page", old);
 
 		gtk_box_pack_start (GTK_BOX (page), w, TRUE, TRUE, 0);
 
@@ -2697,7 +2708,7 @@ emae_send_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidget *ol
 	if (emae->type == EMAE_PAGES) {
 		gtk_box_pack_start ((GtkBox *)emae->pages[2], w, TRUE, TRUE, 0);
 	} else if (((EConfig *)gui->config)->type == E_CONFIG_ASSISTANT) {
-		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "transport_page");
+		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "transport_page", old);
 
 		gtk_box_pack_start (GTK_BOX (page), w, TRUE, TRUE, 0);
 
@@ -2898,7 +2909,7 @@ emae_management_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, GtkWidg
 
 	w = gui->management_frame;
 	if (((EConfig *)gui->config)->type == E_CONFIG_ASSISTANT) {
-		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "management_page");
+		GtkWidget *page = emae_create_basic_assistant_page (GTK_ASSISTANT (parent), "management_page", old);
 
 		gtk_widget_reparent (w, page);
 
@@ -2916,7 +2927,7 @@ emae_widget_assistant_page (EConfig *ec, EConfigItem *item, GtkWidget *parent, G
 	if (emae->type == EMAE_PAGES)
 		return NULL;
 
-	return emae_create_basic_assistant_page (GTK_ASSISTANT (parent), item->label);
+	return emae_create_basic_assistant_page (GTK_ASSISTANT (parent), item->label, old);
 }
 
 /* plugin meta-data for "org.gnome.evolution.mail.config.accountAssistant" */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]