From 8d813defb1fc17bc3c2fd46a5280cd4fe30c209c Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Tue, 5 Mar 2013 17:24:46 -0500 Subject: [PATCH] datetime: support new timedated CanNTP property Set the NTP switch insensitive in the case that timedated has a CanNTP property and that property is set to false. https://bugzilla.gnome.org/show_bug.cgi?id=695253 --- panels/datetime/cc-datetime-panel.c | 31 +++++++++++++++++++++++- panels/datetime/timedated1-interface.xml | 1 + 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c index 84fe0072e..ef681b87c 100644 --- a/panels/datetime/cc-datetime-panel.c +++ b/panels/datetime/cc-datetime-panel.c @@ -847,6 +847,30 @@ update_ntp_switch_from_system (CcDateTimePanel *self) g_signal_handlers_unblock_by_func (switch_widget, change_ntp, self); } +static void +on_can_ntp_changed (CcDateTimePanel *self) +{ + CcDateTimePanelPrivate *priv = self->priv; + GtkWidget *switch_widget; + gboolean sensitive = TRUE; + GVariant *value; + + switch_widget = W("network_time_switch"); + + /* We need to access this directly so that we can default to TRUE if + * it is not set. + */ + value = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (self->priv->dtm), "CanNTP"); + if (value) + { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + sensitive = g_variant_get_boolean (value); + g_variant_unref (value); + } + + gtk_widget_set_sensitive (switch_widget, sensitive); +} + static void on_ntp_changed (CcDateTimePanel *self) { @@ -990,7 +1014,10 @@ cc_date_time_panel_init (CcDateTimePanel *self) /* set up network time button */ if (priv->dtm != NULL) - update_ntp_switch_from_system (self); + { + update_ntp_switch_from_system (self); + on_can_ntp_changed (self); + } g_signal_connect (W("network_time_switch"), "notify::active", G_CALLBACK (change_ntp), self); @@ -1119,6 +1146,8 @@ cc_date_time_panel_init (CcDateTimePanel *self) G_CALLBACK (on_timedated_properties_changed), self); g_signal_connect_swapped (priv->dtm, "notify::ntp", G_CALLBACK (on_ntp_changed), self); + g_signal_connect_swapped (priv->dtm, "notify::can-ntp", + G_CALLBACK (on_can_ntp_changed), self); g_signal_connect_swapped (priv->dtm, "notify::timezone", G_CALLBACK (on_timezone_changed), self); } diff --git a/panels/datetime/timedated1-interface.xml b/panels/datetime/timedated1-interface.xml index b035d10aa..3370e0e2b 100644 --- a/panels/datetime/timedated1-interface.xml +++ b/panels/datetime/timedated1-interface.xml @@ -4,6 +4,7 @@ +