[gnome-control-center] datetime: check CanNTP when initializing the panel



commit c8654808c26a138e21327b411fcb9933c78e9c76
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Jun 21 17:26:46 2014 -0500

    datetime: check CanNTP when initializing the panel
    
    If the system does not support NTP (as determined by the presence of an
    NTP unit in /usr/lib/systemd/ntp-units.d), the Automatic Date & Time row
    is intended to be hidden. We respond to changes to timedated's CanNTP
    property, but we never account for the initial state of the property,
    so we wind up displaying the Automatic Date & Time row even though the
    switch is guaranteed to be broken.
    
    Check CanNTP when initializing the panel to fix this.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732021

 panels/datetime/cc-datetime-panel.c |   39 ++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 16 deletions(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 6854f3c..60c1abd 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -743,6 +743,26 @@ change_ntp (GObject         *gobject,
   queue_set_ntp (self);
 }
 
+static gboolean
+is_ntp_available (CcDateTimePanel *self)
+{
+  GVariant *value;
+  gboolean ntp_available = TRUE;
+
+  /* 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))
+        ntp_available = g_variant_get_boolean (value);
+      g_variant_unref (value);
+    }
+
+  return ntp_available;
+}
+
 static void
 on_permission_changed (GPermission *permission,
                        GParamSpec  *pspec,
@@ -773,22 +793,7 @@ static void
 on_can_ntp_changed (CcDateTimePanel *self)
 {
   CcDateTimePanelPrivate *priv = self->priv;
-  gboolean ntp_available = TRUE;
-  GVariant *value;
-
-  /* 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))
-        ntp_available = g_variant_get_boolean (value);
-      g_variant_unref (value);
-    }
-
-  gtk_widget_set_visible (W ("auto-datetime-row"),
-                          ntp_available);
+  gtk_widget_set_visible (W ("auto-datetime-row"), is_ntp_available (self));
 }
 
 static void
@@ -1281,6 +1286,8 @@ cc_date_time_panel_init (CcDateTimePanel *self)
   g_signal_connect (W("network_time_switch"), "notify::active",
                     G_CALLBACK (change_ntp), self);
 
+  gtk_widget_set_visible (W ("auto-datetime-row"), is_ntp_available (self));
+
   /* Timezone settings */
   bind_switch_to_row (self,
                       W ("auto_timezone_switch"),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]