[clocks] Fix Timer to allows setting seconds



commit 6201577ec5ff9cb220ee0789e97940bb7443136f
Author: Eslam Mostafa <eslam Pandora localdomain>
Date:   Wed Jun 13 15:24:40 2012 +0200

    Fix Timer to allows setting seconds
    
    Signed-off-by: Seif Lotfy <seif lotfy collabora co uk>

 clocks.py  |   12 +++++++-----
 timer.py   |   33 +++++++++++++++++++++++----------
 widgets.py |   18 +++++++++---------
 3 files changed, 39 insertions(+), 24 deletions(-)
---
diff --git a/clocks.py b/clocks.py
index 547bceb..6373e89 100644
--- a/clocks.py
+++ b/clocks.py
@@ -298,8 +298,9 @@ class Timer (Clock):
 		if self.g_id == 0: 
 			hours = self.timer_welcome_screen.hours.get_value()
 			minutes = self.timer_welcome_screen.minutes.get_value()
-			self.timer_screen.timerLabel.set_markup (TIMER_LABEL_MARKUP%(hours, minutes, 00))
-			self.time = (hours * 60 * 60) + (minutes * 60) 
+			seconds = self.timer_welcome_screen.seconds.get_value()
+			self.timer_screen.timerLabel.set_markup (TIMER_LABEL_MARKUP%(hours, minutes, seconds))
+			self.time = (hours * 60 * 60) + (minutes * 60) + seconds
 			self.state = 1
 			self.g_id = GObject.timeout_add(1000, self.count)
 		
@@ -319,11 +320,12 @@ class Timer (Clock):
 	
 	def count(self):
 		self.time -= 1
-		minutes, sec = divmod(self.time, 60)
+		minutes, seconds = divmod(self.time, 60)
 		hours, minutes = divmod(minutes, 60)
+		#seconds, minutes = divmod(hours, 0.60)
 
-		self.timer_screen.timerLabel.set_markup (TIMER_LABEL_MARKUP%(hours, minutes, sec))
-		if hours == 00 and minutes == 00 and sec == 00:
+		self.timer_screen.timerLabel.set_markup (TIMER_LABEL_MARKUP%(hours, minutes, seconds))
+		if hours == 00 and minutes == 00 and seconds == 00:
 			return False
 		else:
 			return True
diff --git a/timer.py b/timer.py
index 2c74c35..5689144 100644
--- a/timer.py
+++ b/timer.py
@@ -47,6 +47,8 @@ class Spinner(Gtk.Box):
 		self.down = Gtk.Button()
 		self.down.set_image(imageDown)
 		self.down.set_relief(Gtk.ReliefStyle.NONE)
+		if self.vType == 'hours':
+			self.down.set_sensitive(False)
 		#
 		self.pack_start(self.up, False, False, 0)
 		self.pack_start(self.value, True, True, 0)
@@ -64,33 +66,39 @@ class Spinner(Gtk.Box):
 	def _increase(self, widget):
 		value = self.get_value()
 		if self.vType == 'hours':
-			if value == 23:
-				value = 0
-			else:
 				value += 1
-			self.set_value(value)
+				self.down.set_sensitive(True)
 		elif self.vType == 'minutes':
 			if value == 59:
 				value = 0
 			else:
 				value += 1
-			self.set_value(value)
+		elif self.vType == 'seconds':
+			if value == 60:
+				value = 0
+			else:
+				value += 1
+		self.set_value(value)
 		self.timer_welcome_screen.update_start_button_status()
 			
 	def _decrease(self, widget):
 		value = self.get_value()
 		if self.vType == 'hours':
 			if value == 0:
-				value = 23
+				self.down.set_sensitive(False)
 			else:
-				value -= 1
-			self.set_value(value)
+				value -= 1			
 		elif self.vType == 'minutes':
 			if value == 0:
 				value = 59
 			else:
+				value -= 1			
+		elif self.vType == 'seconds':
+			if value == 0:
+				value = 60
+			else:
 				value -= 1
-			self.set_value(value)	
+		self.set_value(value)
 		self.timer_welcome_screen.update_start_button_status()
 			
 class TimerScreen (Gtk.Box):
@@ -166,13 +174,18 @@ class TimerWelcomeScreen (Gtk.Box):
 		
 		self.hours = Spinner('hours', self)
 		self.minutes = Spinner('minutes', self)
+		self.seconds = Spinner('seconds', self)
 		colon = Gtk.Label('')
 		colon.set_markup('<span font_desc=\"64.0\">:</span>')
+		another_colon = Gtk.Label('')
+		another_colon.set_markup('<span font_desc=\"64.0\">:</span>')
 		
 		spinner.pack_start(self.hours, False, False, 0)
 		spinner.pack_start(colon, False, False, 0)
 		spinner.pack_start(self.minutes, False, False, 0)
-			
+		spinner.pack_start(another_colon, False, False, 0)
+		spinner.pack_start(self.seconds, False, False, 0)
+		
 		#Start Button
 		self.startButton = Gtk.Button()
 		self.startButton.set_sensitive(False)
diff --git a/widgets.py b/widgets.py
index d7731ff..92ffd8b 100644
--- a/widgets.py
+++ b/widgets.py
@@ -134,8 +134,8 @@ class DigitalClock ():
             return False
 
     def update(self):
-        t = self.get_local_time_text ()
-        if not t == self._last_time:
+		t = self.get_local_time_text ()
+		if not t == self._last_time:
 			systemClockFormat = self.get_system_clock_format ()
 			if systemClockFormat == '12h':
 				pass
@@ -149,13 +149,13 @@ class DigitalClock ():
 					hours = str(hours)
 				minutes = t[3:5]
 				t = '%s:%s' % (hours, minutes)
-            img = self.get_image ()
-            self.drawing.render(t, img, self.get_is_day ())
-            if self.view_iter and self.list_store:
-                self.list_store.set_value(self.view_iter, 0, self.drawing.pixbuf)
-            self.standalone.update (img, t)
-        self._last_time = t
-        return True
+			img = self.get_image ()
+			self.drawing.render(t, img, self.get_is_day ())
+			if self.view_iter and self.list_store:
+				self.list_store.set_value(self.view_iter, 0, self.drawing.pixbuf)
+			self.standalone.update (img, t)
+		self._last_time = t
+		return True
 
     def set_iter (self, list_store, view_iter):
         self.view_iter = view_iter



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