[gnome-system-tools] Allow gst_tool_add_configuration_object() to skip updating child objects



commit 551be4dc2a5290756cc9b1bbdcf9640a3aed78d3
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Sat Feb 13 23:24:53 2010 +0100

    Allow gst_tool_add_configuration_object() to skip updating child objects
    
    Since OobsUser and OobsGroup are now individually committed, we add them as configuration objects. But we don't want them to be updated individually: this triggers too many re-reads of the configuration in the backends (admittedly a bug), while simply updating OobsUsersConfig and OobsGroupsConfig handles destroying old child objects and creating new ones. So add an additional parameters, only used in those cases, to only watch "commit" signal, and not "updated".

 src/common/gst-tool.c        |   18 +++++++++++++-----
 src/common/gst-tool.h        |    3 ++-
 src/network/network-tool.c   |    4 ++--
 src/services/services-tool.c |    2 +-
 src/shares/shares-tool.c     |   10 +++++-----
 src/time/time-tool.c         |    6 +++---
 src/users/user-settings.c    |    2 +-
 src/users/users-tool.c       |   10 +++++-----
 8 files changed, 32 insertions(+), 23 deletions(-)
---
diff --git a/src/common/gst-tool.c b/src/common/gst-tool.c
index 9622748..e5a7139 100644
--- a/src/common/gst-tool.c
+++ b/src/common/gst-tool.c
@@ -646,17 +646,25 @@ configuration_object_committed (OobsObject *object,
 
 void
 gst_tool_add_configuration_object (GstTool    *tool,
-				   OobsObject *object)
+                                   OobsObject *object,
+                                   gboolean    watch_updates)
 {
 	g_return_if_fail (GST_IS_TOOL (tool));
 	g_return_if_fail (OOBS_IS_OBJECT (object));
 
-	g_ptr_array_add (tool->objects, object);
-
-	g_signal_connect (object, "changed",
-			  G_CALLBACK (configuration_object_changed), tool);
 	g_signal_connect (object, "committed",
 			  G_CALLBACK (configuration_object_committed), tool);
+
+	/* For child objects like OobsUser or OobsService, we don't want
+	 * to get updates directly: instead, we update OobsUsersConfig and OobsServicesConfig,
+	 * and drop old child objects.
+	 */
+	if (watch_updates) {
+		g_ptr_array_add (tool->objects, object);
+
+		g_signal_connect (object, "changed",
+		                  G_CALLBACK (configuration_object_changed), tool);
+	}
 }
 
 /*
diff --git a/src/common/gst-tool.h b/src/common/gst-tool.h
index a18fdab..fcb0ade 100644
--- a/src/common/gst-tool.h
+++ b/src/common/gst-tool.h
@@ -118,7 +118,8 @@ void         gst_tool_commit_error    (GstTool             *tool,
 void         gst_tool_update_async    (GstTool             *tool);
 
 void         gst_tool_add_configuration_object (GstTool    *tool,
-						OobsObject *object);
+                                                OobsObject *object,
+                                                gboolean    watch_updates);
 
 gboolean     gst_tool_authenticate    (GstTool *tool,
 				       OobsObject *object);
diff --git a/src/network/network-tool.c b/src/network/network-tool.c
index 5b332ae..1e426ce 100644
--- a/src/network/network-tool.c
+++ b/src/network/network-tool.c
@@ -56,9 +56,9 @@ static void
 gst_network_tool_init (GstNetworkTool *tool)
 {
   tool->hosts_config = OOBS_HOSTS_CONFIG (oobs_hosts_config_get ());
-  gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (tool->hosts_config));
+  gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (tool->hosts_config), TRUE);
   tool->ifaces_config = OOBS_IFACES_CONFIG (oobs_ifaces_config_get ());
-  gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (tool->ifaces_config));
+  gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (tool->ifaces_config), TRUE);
 
   tool->bus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, NULL);
 
diff --git a/src/services/services-tool.c b/src/services/services-tool.c
index 9df5129..51b5ac2 100644
--- a/src/services/services-tool.c
+++ b/src/services/services-tool.c
@@ -48,7 +48,7 @@ static void
 gst_services_tool_init (GstServicesTool *tool)
 {
 	tool->services_config = oobs_services_config_get ();
-	gst_tool_add_configuration_object (GST_TOOL (tool), tool->services_config);
+	gst_tool_add_configuration_object (GST_TOOL (tool), tool->services_config, TRUE);
 }
 
 static void
diff --git a/src/shares/shares-tool.c b/src/shares/shares-tool.c
index 4ff16af..54c0a07 100644
--- a/src/shares/shares-tool.c
+++ b/src/shares/shares-tool.c
@@ -57,19 +57,19 @@ gst_shares_tool_init (GstSharesTool *tool)
 	GstTool *gst_tool = GST_TOOL (tool);
 
 	tool->nfs_config = oobs_nfs_config_get ();
-	gst_tool_add_configuration_object (gst_tool, tool->nfs_config);
+	gst_tool_add_configuration_object (gst_tool, tool->nfs_config, TRUE);
 
 	tool->smb_config = oobs_smb_config_get ();
-	gst_tool_add_configuration_object (gst_tool, tool->smb_config);
+	gst_tool_add_configuration_object (gst_tool, tool->smb_config, TRUE);
 
 	tool->services_config = oobs_services_config_get ();
-	gst_tool_add_configuration_object (gst_tool, tool->services_config);
+	gst_tool_add_configuration_object (gst_tool, tool->services_config, TRUE);
 
 	tool->hosts_config = oobs_hosts_config_get ();
-	gst_tool_add_configuration_object (gst_tool, tool->hosts_config);
+	gst_tool_add_configuration_object (gst_tool, tool->hosts_config, TRUE);
 
 	tool->users_config = oobs_users_config_get ();
-	gst_tool_add_configuration_object (gst_tool, tool->users_config);
+	gst_tool_add_configuration_object (gst_tool, tool->users_config, TRUE);
 }
 
 static GObject *
diff --git a/src/time/time-tool.c b/src/time/time-tool.c
index 78aa1de..74b1b13 100644
--- a/src/time/time-tool.c
+++ b/src/time/time-tool.c
@@ -131,13 +131,13 @@ gst_time_tool_init (GstTimeTool *tool)
 	}
 
 	tool->time_config = oobs_time_config_get ();
-	gst_tool_add_configuration_object (GST_TOOL (tool), tool->time_config);
+	gst_tool_add_configuration_object (GST_TOOL (tool), tool->time_config, TRUE);
 
 	tool->ntp_config = oobs_ntp_config_get ();
-	gst_tool_add_configuration_object (GST_TOOL (tool), tool->ntp_config);
+	gst_tool_add_configuration_object (GST_TOOL (tool), tool->ntp_config, TRUE);
 
 	tool->services_config = oobs_services_config_get ();
-	gst_tool_add_configuration_object (GST_TOOL (tool), tool->services_config);
+	gst_tool_add_configuration_object (GST_TOOL (tool), tool->services_config, TRUE);
 }
 
 static void
diff --git a/src/users/user-settings.c b/src/users/user-settings.c
index 44a58c6..a17fea0 100644
--- a/src/users/user-settings.c
+++ b/src/users/user-settings.c
@@ -992,7 +992,7 @@ on_user_new (GtkButton *button, gpointer user_data)
 
 	/* We need to know about this user before adding it, else we won't be aware
 	 * that we triggered the commit, and we will show a "Reload config?" dialog. */
-	gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (user));
+	gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (user), FALSE);
 
 	/* Commit both user and groups config because of possible memberships
 	 * added by the profile. Avoid showing the new user or trying to commit
diff --git a/src/users/users-tool.c b/src/users/users-tool.c
index 5aae962..bd26f50 100644
--- a/src/users/users-tool.c
+++ b/src/users/users-tool.c
@@ -75,13 +75,13 @@ static void
 gst_users_tool_init (GstUsersTool *tool)
 {
 	tool->users_config = oobs_users_config_get ();
-	gst_tool_add_configuration_object (GST_TOOL (tool), tool->users_config);
+	gst_tool_add_configuration_object (GST_TOOL (tool), tool->users_config, TRUE);
 
 	tool->groups_config = oobs_groups_config_get ();
-	gst_tool_add_configuration_object (GST_TOOL (tool), tool->groups_config);
+	gst_tool_add_configuration_object (GST_TOOL (tool), tool->groups_config, TRUE);
 
 	tool->self_config = oobs_self_config_get ();
-	gst_tool_add_configuration_object (GST_TOOL (tool), tool->self_config);
+	gst_tool_add_configuration_object (GST_TOOL (tool), tool->self_config, TRUE);
 
 	tool->profiles = gst_user_profiles_get ();
 }
@@ -147,7 +147,7 @@ update_users (GstUsersTool *tool)
 	while (valid) {
 		user = oobs_list_get (list, &iter);
 		path = users_table_add_user (OOBS_USER (user));
-		gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (user));
+		gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (user), FALSE);
 
 		if (self == (OobsUser *) user)
 			users_table_select_path (path);
@@ -175,7 +175,7 @@ update_groups (GstUsersTool *tool)
 	while (valid) {
 		group = oobs_list_get (list, &iter);
 		groups_table_add_group (OOBS_GROUP (group));
-		gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (group));
+		gst_tool_add_configuration_object (GST_TOOL (tool), OOBS_OBJECT (group), FALSE);
 
 		/* update privileges table too */
 		privileges_table_add_group (OOBS_GROUP (group));



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