[gnome-control-center] datetime: support new timedated CanNTP property
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] datetime: support new timedated CanNTP property
- Date: Thu, 7 Mar 2013 02:49:51 +0000 (UTC)
commit 8d813defb1fc17bc3c2fd46a5280cd4fe30c209c
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Mar 5 17:24:46 2013 -0500
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 deletions(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 84fe007..ef681b8 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -848,6 +848,30 @@ update_ntp_switch_from_system (CcDateTimePanel *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)
{
update_ntp_switch_from_system (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 b035d10..3370e0e 100644
--- a/panels/datetime/timedated1-interface.xml
+++ b/panels/datetime/timedated1-interface.xml
@@ -4,6 +4,7 @@
<interface name="org.freedesktop.timedate1">
<property name="Timezone" type="s" access="read"/>
<property name="LocalRTC" type="b" access="read"/>
+ <property name="CanNTP" type="b" access="read"/>
<property name="NTP" type="b" access="read"/>
<method name="SetTime">
<arg name="usec_utc" type="x" direction="in"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]