[gnome-control-center] datetime: Toggle the NTP switch when clicking on the row



commit 6fddedad841b4a9d2fdd981b36d4584048c706e0
Author: Kalev Lember <kalevlember gmail com>
Date:   Mon Aug 19 13:28:09 2013 +0100

    datetime: Toggle the NTP switch when clicking on the row
    
    Pointed out by Allan Day on IRC.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694985

 panels/datetime/cc-datetime-panel.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 281e103..533b63b 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -1014,11 +1014,21 @@ run_dialog (CcDateTimePanel *self,
 }
 
 static void
+toggle_switch (GtkWidget *sw)
+{
+  gboolean active;
+
+  active = gtk_switch_get_active (GTK_SWITCH (sw));
+  gtk_switch_set_active (GTK_SWITCH (sw), !active);
+}
+
+static void
 list_box_row_activated (GtkListBox      *listbox,
                         GtkListBoxRow   *row,
                         CcDateTimePanel *self)
 
 {
+  CcDateTimePanelPrivate *priv = self->priv;
   gchar *widget_name, *found;
 
   widget_name = g_strdup (gtk_buildable_get_name (GTK_BUILDABLE (row)));
@@ -1028,17 +1038,18 @@ list_box_row_activated (GtkListBox      *listbox,
 
   gtk_list_box_select_row (listbox, NULL);
 
-  /* replace "button" with "dialog" */
-  found = g_strrstr (widget_name, "button");
-
-  if (!found)
-    goto out;
-
-  memcpy (found, "dialog", 6);
+  if (!g_strcmp0 (widget_name, "auto-datetime-row"))
+    {
+      toggle_switch (W ("network_time_switch"));
+    }
+  else if ((found = g_strrstr (widget_name, "button")))
+    {
+      /* replace "button" with "dialog" */
+      memcpy (found, "dialog", 6);
 
-  run_dialog (self, widget_name);
+      run_dialog (self, widget_name);
+    }
 
-out:
   g_free (widget_name);
 }
 


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