[gnome-clocks] Add leading zero to minutes when necessary.



commit c830fce9d64856da1ab23fa997b97753ebe9d296
Author: MaÃl Lavault <mael lavault mailz org>
Date:   Thu Aug 16 15:55:07 2012 +0200

    Add leading zero to minutes when necessary.
    
    Signed-off-by: MaÃl Lavault <mael lavault mailz org>
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681931

 gnomeclocks/alarm.py   |    4 ++--
 gnomeclocks/widgets.py |    7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index 993e32e..bdecc6c 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -85,7 +85,7 @@ class AlarmItem:
                 h = self.h - 12
         else:
             h = self.h
-        return "%2i:%2i %s" % (h, self.m, self.p)
+        return "%2i:%02i %s" % (h, self.m, self.p)
 
 
     def get_time_24h_as_string(self):
@@ -95,7 +95,7 @@ class AlarmItem:
                 h = 12
         else:
             h = self.h
-        return "%2i:%2i" % (h, self.m)
+        return "%2i:%02i" % (h, self.m)
 
     def set_alarm_name(self, name):
         self.name = name
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index d34130e..c881831 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -385,6 +385,7 @@ class NewAlarmDialog (Gtk.Dialog):
         minute_spinbutton = Gtk.SpinButton()
         minute_spinbutton.set_increments(1.0, 1.0)
         minute_spinbutton.set_wrap(True)
+        minute_spinbutton.connect('output', self.show_leading_zeros)
 
         if cf == "12h":
             if p == "PM":
@@ -400,8 +401,6 @@ class NewAlarmDialog (Gtk.Dialog):
         minute_spinbutton.set_value(m)
         self.minuteselect = minuteselect = minute_spinbutton
 
-
-
         if cf == "12h":
             self.ampm = ampm = Gtk.ComboBoxText()
             ampm.append_text("AM")
@@ -474,6 +473,10 @@ class NewAlarmDialog (Gtk.Dialog):
         soundbox = Gtk.ComboBox ()
         #table1.attach(soundbox, 1, 3, 3, 4)
 
+    def show_leading_zeros(self, spin_button):
+        spin_button.set_text('{:02d}'.format(spin_button.get_value_as_int()))
+        return True
+
     def get_system_clock_format(self):
         settings = Gio.Settings.new('org.gnome.desktop.interface')
         systemClockFormat = settings.get_string('clock-format')



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