summaryrefslogtreecommitdiff
path: root/panels/datetime/cc-datetime-panel.c
diff options
context:
space:
mode:
Diffstat (limited to 'panels/datetime/cc-datetime-panel.c')
-rw-r--r--panels/datetime/cc-datetime-panel.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 33a975941..4e7b3ee00 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -626,11 +626,29 @@ on_clock_changed (CcDateTimePanel *panel,
update_timezone (panel);
}
-static void
-change_ntp (CcDateTimePanel *self,
- GParamSpec *pspec)
+static gboolean
+change_ntp (CcDateTimePanel *self)
{
queue_set_ntp (self);
+
+ /* The new state will be visible once we see the reply. */
+ return TRUE;
+}
+
+static void
+on_ntp_changed (CcDateTimePanel *self)
+{
+ gboolean ntp_on;
+
+ g_object_get (self->dtm, "ntp", &ntp_on, NULL);
+
+ g_signal_handlers_block_by_func (self->network_time_switch, change_ntp, self);
+
+ g_object_set (self->network_time_switch,
+ "state", ntp_on,
+ NULL);
+
+ g_signal_handlers_unblock_by_func (self->network_time_switch, change_ntp, self);
}
static gboolean
@@ -1105,11 +1123,11 @@ cc_date_time_panel_init (CcDateTimePanel *self)
bind_switch_to_row (self,
self->network_time_switch,
self->datetime_button);
- g_object_bind_property (self->dtm, "ntp",
- self->network_time_switch, "active",
- G_BINDING_SYNC_CREATE);
- g_signal_connect_object (self->network_time_switch, "notify::active",
+ g_signal_connect_object (self->dtm, "notify::ntp",
+ G_CALLBACK (on_ntp_changed), self, G_CONNECT_SWAPPED);
+ g_signal_connect_object (self->network_time_switch, "state-set",
G_CALLBACK (change_ntp), self, G_CONNECT_SWAPPED);
+ on_ntp_changed (self);
gtk_widget_set_visible (self->auto_datetime_row, is_ntp_available (self));