[network-manager-applet] connection-editor: ensure that pages always appear in the correct order



commit 3023b67db252f6d487dd683b781c0adfda88d04e
Author: Dan Winship <danw gnome org>
Date:   Thu Nov 1 15:59:06 2012 -0400

    connection-editor: ensure that pages always appear in the correct order
    
    If the connection-editor had to ask for authentication in order to
    retrieve the secrets for a given editor page, then that page would end
    up getting appending to the notebook out of order. Fix it so that
    pages always end up in the order we called add_page() in, regardless
    of what order they call page_initialized() in.

 src/connection-editor/nm-connection-editor.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index e23f8a6..666149d 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -96,6 +96,9 @@ struct GetSecretsInfo {
 	gboolean canceled;
 };
 
+#define SECRETS_TAG "secrets-setting-name"
+#define ORDER_TAG "page-order"
+
 static void
 nm_connection_editor_update_title (NMConnectionEditor *editor)
 {
@@ -609,6 +612,9 @@ page_initialized (CEPage *page, GError *error, gpointer user_data)
 	GtkWidget *widget, *parent;
 	GtkNotebook *notebook;
 	GtkWidget *label;
+	GList *children, *iter;
+	gpointer order, child_order;
+	int i;
 
 	if (error) {
 		gtk_widget_hide (editor->window);
@@ -627,7 +633,19 @@ page_initialized (CEPage *page, GError *error, gpointer user_data)
 	parent = gtk_widget_get_parent (widget);
 	if (parent)
 		gtk_container_remove (GTK_CONTAINER (parent), widget);
-	gtk_notebook_append_page (notebook, widget, label);
+
+	order = g_object_get_data (G_OBJECT (page), ORDER_TAG);
+	g_object_set_data (G_OBJECT (widget), ORDER_TAG, order);
+
+	children = gtk_container_get_children (GTK_CONTAINER (notebook));
+	for (iter = children, i = 0; iter; iter = iter->next, i++) {
+		child_order = g_object_get_data (G_OBJECT (iter->data), ORDER_TAG);
+		if (child_order > order)
+			break;
+	}
+	g_list_free (children);
+
+	gtk_notebook_insert_page (notebook, widget, label, i);
 
 	if (CE_IS_PAGE_VPN (page) && ce_page_vpn_can_export (CE_PAGE_VPN (page)))
 		gtk_widget_show (editor->export_button);
@@ -720,8 +738,6 @@ get_secrets_for_page (NMConnectionEditor *self,
 	}
 }
 
-#define SECRETS_TAG "secrets-setting-name"
-
 static gboolean
 add_page (NMConnectionEditor *editor,
           CEPageNewFunc func,
@@ -742,6 +758,9 @@ add_page (NMConnectionEditor *editor,
 		                        SECRETS_TAG,
 		                        g_strdup (secrets_setting_name),
 		                        g_free);
+		g_object_set_data (G_OBJECT (page),
+		                   ORDER_TAG,
+		                   GINT_TO_POINTER (g_slist_length (editor->initializing_pages)));
 
 		editor->initializing_pages = g_slist_append (editor->initializing_pages, page);
 		g_signal_connect (page, "changed", G_CALLBACK (page_changed), editor);



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