[evolution/wip/gsettings] Bug #656620 - Account editor doesn't update on settings change



commit c4247dda8f228360592c9a527f5df71f4aba9221
Author: Milan Crha <mcrha redhat com>
Date:   Tue Aug 16 08:52:13 2011 +0200

    Bug #656620 - Account editor doesn't update on settings change

 mail/em-account-editor.c |    6 +-----
 mail/em-config.c         |   38 ++++++++++++++++++++++++++++++++++++++
 mail/em-config.h         |    4 ++++
 3 files changed, 43 insertions(+), 5 deletions(-)
---
diff --git a/mail/em-account-editor.c b/mail/em-account-editor.c
index 3b1c167..52f930d 100644
--- a/mail/em-account-editor.c
+++ b/mail/em-account-editor.c
@@ -1588,11 +1588,7 @@ emae_setup_settings (EMAccountEditorService *service)
 	config = E_CONFIG (service->emae->priv->config);
 	target = (EMConfigTargetAccount *) config->target;
 
-	if (target->settings != NULL)
-		g_object_unref (target->settings);
-	target->settings = service->emae->priv->source.settings;
-	if (target->settings != NULL)
-		g_object_ref (target->settings);
+	em_config_target_new_account_update_settings (config, target, service->emae->priv->source.settings);
 }
 
 static void
diff --git a/mail/em-config.c b/mail/em-config.c
index fbde5d5..3f649ba 100644
--- a/mail/em-config.c
+++ b/mail/em-config.c
@@ -85,6 +85,8 @@ em_config_set_target (EConfig *ep,
 			config->priv->account_changed_id = g_signal_connect (
 				s->modified_account, "changed",
 				G_CALLBACK (emp_account_changed), ep);
+
+			em_config_target_new_account_update_settings (ep, s, s->settings);
 			break; }
 		}
 	}
@@ -110,6 +112,8 @@ em_config_target_free (EConfig *ep,
 					config->priv->account_changed_id);
 				config->priv->account_changed_id = 0;
 			}
+
+			em_config_target_new_account_update_settings (ep, s, NULL);
 			break; }
 		}
 	}
@@ -233,3 +237,37 @@ em_config_target_new_account (EMConfig *emp,
 
 	return t;
 }
+
+void
+em_config_target_new_account_update_settings (EConfig *ep, EMConfigTargetAccount *target, CamelSettings *settings)
+{
+	g_return_if_fail (ep != NULL);
+	g_return_if_fail (target != NULL);
+
+	if (settings)
+		g_object_ref (settings);
+
+	if (target->settings != NULL) {
+		g_signal_handlers_disconnect_by_func (target->settings, G_CALLBACK (emp_account_changed), ep);
+		g_object_unref (target->settings);
+	}
+
+	target->settings = settings;
+
+	if (target->settings != NULL) {
+		GParamSpec **params;
+		guint n_params = 0;
+
+		params = camel_settings_class_list_settings (CAMEL_SETTINGS_GET_CLASS (target->settings), &n_params);
+		if (params) {
+			guint ii;
+			gchar *sig_name;
+
+			for (ii = 0; ii < n_params; ii++) {
+				sig_name = g_strconcat ("notify::", params[ii]->name, NULL);
+				g_signal_connect (target->settings, sig_name, G_CALLBACK (emp_account_changed), ep);
+				g_free (sig_name);
+			}
+		}
+	}
+}
diff --git a/mail/em-config.h b/mail/em-config.h
index 0291f24..dcd5194e 100644
--- a/mail/em-config.h
+++ b/mail/em-config.h
@@ -93,6 +93,10 @@ EMConfigTargetAccount *
 						 EAccount *original_account,
 						 EAccount *modified_account,
 						 CamelSettings *settings);
+void		em_config_target_new_account_update_settings
+						(EConfig *ep,
+						 EMConfigTargetAccount *target,
+						 CamelSettings *settings);
 
 G_END_DECLS
 



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