From 6ec22dc4846b927b557b690b54ba52cb2b3458bc Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Tue, 26 Nov 2013 10:19:54 +0100 Subject: [PATCH] connectivity-monitor: start watching 'use-conn' key in constructed We have to wait for the default GObject properties to be set before calling g_settings_bind(). If we don't, they override the value fetched from GSettings. --- src/connectivity-monitor.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/connectivity-monitor.c b/src/connectivity-monitor.c index fded50b..286d73e 100644 --- a/src/connectivity-monitor.c +++ b/src/connectivity-monitor.c @@ -477,9 +477,9 @@ mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) #ifdef ENABLE_CONN_SETTING priv->settings = g_settings_new ("im.telepathy.MissionControl.FromEmpathy"); - g_settings_bind (priv->settings, "use-conn", - connectivity_monitor, "use-conn", - G_SETTINGS_BIND_GET); + /* We'll call g_settings_bind() in constructed because default values of + * properties haven't been set yet at this point and we don't want them to + * override the value from GSettings. */ #endif #ifdef HAVE_NM @@ -503,6 +503,17 @@ mcd_connectivity_monitor_init (McdConnectivityMonitor *connectivity_monitor) } static void +connectivity_monitor_constructed (GObject *object) +{ +#ifdef ENABLE_CONN_SETTING + McdConnectivityMonitor *self = MCD_CONNECTIVITY_MONITOR (object); + + g_settings_bind (self->priv->settings, "use-conn", + self, "use-conn", G_SETTINGS_BIND_GET); +#endif +} + +static void connectivity_monitor_finalize (GObject *object) { #if defined(HAVE_NM) @@ -626,6 +637,7 @@ mcd_connectivity_monitor_class_init (McdConnectivityMonitorClass *klass) oclass->finalize = connectivity_monitor_finalize; oclass->dispose = connectivity_monitor_dispose; oclass->constructor = connectivity_monitor_constructor; + oclass->constructed = connectivity_monitor_constructed; oclass->get_property = connectivity_monitor_get_property; oclass->set_property = connectivity_monitor_set_property; -- 1.8.3.1