[gnome-control-center] datetime: use a switch for 24 hour time



commit 26a45cafe82e8866e87a9f2d77946cde2f02f059
Author: William Jon McCann <jmccann redhat com>
Date:   Thu Jan 6 17:05:38 2011 -0500

    datetime: use a switch for 24 hour time

 panels/datetime/cc-datetime-panel.c |   31 ++++++++++--------------
 panels/datetime/datetime.ui         |   45 +++++++++++++++++++---------------
 2 files changed, 38 insertions(+), 38 deletions(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 16337dc..0ef70e1 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -148,7 +148,8 @@ static void clock_settings_changed_cb (GSettings       *settings,
                                        CcDateTimePanel *panel);
 
 static void
-change_clock_settings (GtkWidget       *widget,
+change_clock_settings (GObject         *gobject,
+                       GParamSpec      *pspec,
                        CcDateTimePanel *panel)
 {
   CcDateTimePanelPrivate *priv = panel->priv;
@@ -157,10 +158,10 @@ change_clock_settings (GtkWidget       *widget,
   g_signal_handlers_block_by_func (priv->settings, clock_settings_changed_cb,
                                    panel);
 
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (W ("12_radiobutton"))))
-    value = G_DESKTOP_CLOCK_FORMAT_12H;
-  else
+  if (gtk_switch_get_active (GTK_SWITCH (W ("24h_time_switch"))))
     value = G_DESKTOP_CLOCK_FORMAT_24H;
+  else
+    value = G_DESKTOP_CLOCK_FORMAT_12H;
 
   g_settings_set_enum (priv->settings, CLOCK_FORMAT_KEY, value);
   priv->clock_format = value;
@@ -177,28 +178,24 @@ clock_settings_changed_cb (GSettings       *settings,
                            CcDateTimePanel *panel)
 {
   CcDateTimePanelPrivate *priv = panel->priv;
-  GtkWidget *radio12, *radio24;
-  gboolean use_12_hour;
+  GtkWidget *switch24h;
+  gboolean use_24_hour;
   GDesktopClockFormat value;
 
   value = g_settings_get_enum (settings, CLOCK_FORMAT_KEY);
   priv->clock_format = value;
 
-  radio12 = W ("12_radiobutton");
-  radio24 = W ("24_radiobutton");
+  switch24h = W ("24h_time_switch");
 
-  use_12_hour = (value == G_DESKTOP_CLOCK_FORMAT_12H);
+  use_24_hour = (value == G_DESKTOP_CLOCK_FORMAT_24H);
 
-  g_signal_handlers_block_by_func (radio12, change_clock_settings, panel);
-  g_signal_handlers_block_by_func (radio24, change_clock_settings, panel);
+  g_signal_handlers_block_by_func (switch24h, change_clock_settings, panel);
 
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio12), use_12_hour);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio24), !use_12_hour);
+  gtk_switch_set_active (GTK_SWITCH (switch24h), use_24_hour);
 
   update_time (panel);
 
-  g_signal_handlers_unblock_by_func (radio12, change_clock_settings, panel);
-  g_signal_handlers_unblock_by_func (radio24, change_clock_settings, panel);
+  g_signal_handlers_unblock_by_func (switch24h, change_clock_settings, panel);
 }
 
 static void
@@ -715,9 +712,7 @@ cc_date_time_panel_init (CcDateTimePanel *self)
   g_signal_connect (priv->settings, "changed::" CLOCK_FORMAT_KEY,
                     G_CALLBACK (clock_settings_changed_cb), self);
 
-  g_signal_connect (W ("12_radiobutton"), "toggled",
-                    G_CALLBACK (change_clock_settings), self);
-  g_signal_connect (W ("24_radiobutton"), "toggled",
+  g_signal_connect (W("24h_time_switch"), "notify::active",
                     G_CALLBACK (change_clock_settings), self);
 
   update_time (self);
diff --git a/panels/datetime/datetime.ui b/panels/datetime/datetime.ui
index 5e491fb..6717fb1 100644
--- a/panels/datetime/datetime.ui
+++ b/panels/datetime/datetime.ui
@@ -339,31 +339,36 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkRadioButton" id="12_radiobutton">
-                        <property name="label" translatable="yes">12 hour format</property>
+                      <object class="GtkHBox" id="hbox23">
                         <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="active">True</property>
-                        <property name="draw_indicator">True</property>
+                        <property name="spacing">12</property>
+                        <child>
+                          <object class="GtkLabel" id="label33">
+                            <property name="visible">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">24-Hour Time</property>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkSwitch" id="24h_time_switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                          </object>
+                          <packing>
+                            <property name="pack_type">end</property>
+                            <property name="position">2</property>
+                            <property name="expand">False</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
-                        <property name="expand">False</property>
                         <property name="position">3</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkRadioButton" id="24_radiobutton">
-                        <property name="label" translatable="yes">24 hour format</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">False</property>
-                        <property name="draw_indicator">True</property>
-                        <property name="group">12_radiobutton</property>
-                      </object>
-                      <packing>
+                        <property name="padding">6</property>
                         <property name="expand">False</property>
-                        <property name="position">4</property>
+                        <property name="pack_type">end</property>
                       </packing>
                     </child>
                     <child>



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