[gnome-control-center] datetime: Show the automatic timezone switch



commit c68f9eca501b662fd819bab1ae021098a7cdaf9b
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Sep 2 00:37:12 2013 +0200

    datetime: Show the automatic timezone switch
    
    The backend in gnome-settings-daemon is now functional, so we can expose
    the option in the UI.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707252

 configure.ac                        |    2 +-
 panels/datetime/cc-datetime-panel.c |   24 ++++++++++++++++++++++--
 panels/datetime/datetime.ui         |    1 +
 3 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 51ef581..b6c5d53 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,7 +95,7 @@ NETWORK_MANAGER_APPLET_REQUIRED_VERSION=0.9.7.995
 MODEM_MANAGER_REQUIRED_VERSION=0.7
 LIBNOTIFY_REQUIRED_VERSION=0.7.3
 GNOME_DESKTOP_REQUIRED_VERSION=3.9.90
-SCHEMAS_REQUIRED_VERSION=3.7.2.2
+SCHEMAS_REQUIRED_VERSION=3.9.91
 LIBWACOM_REQUIRED_VERSION=0.7
 CLUTTER_REQUIRED_VERSION=1.11.3
 GOA_REQUIRED_VERSION=3.9.90
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index af73341..faf707b 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -63,6 +63,9 @@ enum {
 #define CLOCK_SCHEMA "org.gnome.desktop.interface"
 #define CLOCK_FORMAT_KEY "clock-format"
 
+#define DATETIME_SCHEMA "org.gnome.desktop.datetime"
+#define AUTO_TIMEZONE_KEY "automatic-timezone"
+
 struct _CcDateTimePanelPrivate
 {
   GtkBuilder *builder;
@@ -75,6 +78,7 @@ struct _CcDateTimePanelPrivate
   GDateTime *date;
 
   GSettings *clock_settings;
+  GSettings *datetime_settings;
   GDesktopClockFormat clock_format;
   gboolean ampm_available;
   GtkWidget *am_label;
@@ -739,15 +743,17 @@ on_permission_changed (GPermission *permission,
                        gpointer     data)
 {
   CcDateTimePanelPrivate *priv = CC_DATE_TIME_PANEL (data)->priv;
-  gboolean allowed, using_ntp;
+  gboolean allowed, auto_timezone, using_ntp;
 
   allowed = (priv->permission == NULL || g_permission_get_allowed (priv->permission));
   using_ntp = gtk_switch_get_active (GTK_SWITCH (W("network_time_switch")));
+  auto_timezone = gtk_switch_get_active (GTK_SWITCH (W("auto_timezone_switch")));
 
   /* All the widgets but the lock button and the 24h setting */
   gtk_widget_set_sensitive (W("auto-datetime-row"), allowed);
+  gtk_widget_set_sensitive (W("auto-timezone-row"), allowed);
   gtk_widget_set_sensitive (W("datetime-button"), allowed && !using_ntp);
-  gtk_widget_set_sensitive (W("timezone-button"), allowed);
+  gtk_widget_set_sensitive (W("timezone-button"), allowed && !auto_timezone);
 
   /* Hide the subdialogs if we no longer have permissions */
   if (!allowed)
@@ -913,6 +919,10 @@ list_box_row_activated (GtkListBox      *listbox,
     {
       toggle_switch (W ("network_time_switch"));
     }
+  else if (!g_strcmp0 (widget_name, "auto-timezone-row"))
+    {
+      toggle_switch (W ("auto_timezone_switch"));
+    }
   else if ((found = g_strrstr (widget_name, "button")))
     {
       /* replace "button" with "dialog" */
@@ -1233,6 +1243,16 @@ cc_date_time_panel_init (CcDateTimePanel *self)
   g_signal_connect (W("network_time_switch"), "notify::active",
                     G_CALLBACK (change_ntp), self);
 
+  /* Timezone settings */
+  bind_switch_to_row (self,
+                      W ("auto_timezone_switch"),
+                      W ("timezone-button"));
+
+  priv->datetime_settings = g_settings_new (DATETIME_SCHEMA);
+  g_settings_bind (priv->datetime_settings, AUTO_TIMEZONE_KEY,
+                   W ("auto_timezone_switch"), "active",
+                   G_SETTINGS_BIND_DEFAULT);
+
   /* Clock settings */
   priv->clock_settings = g_settings_new (CLOCK_SCHEMA);
 
diff --git a/panels/datetime/datetime.ui b/panels/datetime/datetime.ui
index 8a6be14..fbf3fca 100644
--- a/panels/datetime/datetime.ui
+++ b/panels/datetime/datetime.ui
@@ -565,6 +565,7 @@
                 </child>
                 <child>
                   <object class="GtkListBoxRow" id="auto-timezone-row">
+                    <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
                       <object class="GtkBox" id="box3">


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