[network-manager-netbook] Rework how we react to GConf changes.



commit bf3e17e90d39d255f922c4289385c5fc3fac2843
Author: Tambet Ingo <tambet gmail com>
Date:   Thu Dec 10 15:09:59 2009 +0200

    Rework how we react to GConf changes.
    
    Fixes warnings regularily happen when connections get added and removed.

 libnm-gtk/nm-gconf-settings.c |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)
---
diff --git a/libnm-gtk/nm-gconf-settings.c b/libnm-gtk/nm-gconf-settings.c
index 062b34f..bd31cba 100644
--- a/libnm-gtk/nm-gconf-settings.c
+++ b/libnm-gtk/nm-gconf-settings.c
@@ -359,17 +359,23 @@ connection_changes_done (gpointer data)
 	NMGConfConnection *connection;
 
 	connection = get_connection_by_gconf_path (info->settings, info->path);
-	if (!connection) {
-		/* New connection */
-		connection = nm_gconf_connection_new (priv->client, info->path);
-		if (connection)
-			internal_add_connection (info->settings, connection);
-	} else {
-		if (gconf_client_dir_exists (priv->client, info->path, NULL)) {
-			/* Updated connection */
+
+	if (gconf_client_dir_exists (priv->client, info->path, NULL)) {
+		if (connection) {
+			/* Update */
 			if (!nm_gconf_connection_gconf_changed (connection))
-				priv->connections = g_slist_remove (priv->connections, connection);
+				connection_removed (NM_EXPORTED_CONNECTION (connection), info->settings);
+		} else {
+			/* Add */
+			connection = nm_gconf_connection_new (priv->client, info->path);
+			if (connection)
+				internal_add_connection (info->settings, connection);
 		}
+	} else {
+		if (connection)
+			/* Remove */
+			connection_removed (NM_EXPORTED_CONNECTION (connection), info->settings);
+		/* else already removed */
 	}
 
 	g_hash_table_remove (priv->pending_changes, info->path);
@@ -411,8 +417,9 @@ connections_changed_cb (GConfClient *conf_client,
 		info->path = path;
 		path = NULL;
 
-		id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, connection_changes_done, 
-							  info, connection_changed_info_destroy);
+		id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 500,
+								 connection_changes_done, info,
+								 connection_changed_info_destroy);
 		g_hash_table_insert (priv->pending_changes, info->path, GUINT_TO_POINTER (id));
 	}
 



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