telepathy-mission-control: connectivity-monitor: start watching 'use-conn' key in constructed
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Tue Nov 26 01:30:37 PST 2013
Module: telepathy-mission-control
Branch: master
Commit: 51eb9027ec1b72591166ecde65793c9f5877ac16
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=51eb9027ec1b72591166ecde65793c9f5877ac16
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Tue Nov 26 10:19:54 2013 +0100
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 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/connectivity-monitor.c b/src/connectivity-monitor.c
index b1b03a1..682dfa1 100644
--- a/src/connectivity-monitor.c
+++ b/src/connectivity-monitor.c
@@ -522,9 +522,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
@@ -558,6 +558,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) || defined(HAVE_UPOWER)
@@ -687,6 +698,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;
More information about the telepathy-commits
mailing list