revert local change
[enigma2.git] / lib / python / Components / Sources / Clock.py
index f840ea2..4833ddd 100644 (file)
@@ -1,4 +1,5 @@
 from Tools.Event import Event
+from Components.Element import cached
 from enigma import eTimer
 import time
 
@@ -6,17 +7,23 @@ from Source import Source
 
 class Clock(Source):
        def __init__(self):
-               self.changed = Event(start=self.start, stop=self.stop)
+               Source.__init__(self)
                self.clock_timer = eTimer()
-               self.clock_timer.timeout.get().append(self.changed)
-
-       def start(self):
+               self.clock_timer.timeout.get().append(self.poll)
                self.clock_timer.start(1000)
 
-       def stop(self):
-               self.clock_timer.stop()
-
+       @cached
        def getClock(self):
                return time.time()
 
        time = property(getClock)
+
+       def poll(self):
+               self.changed((self.CHANGED_POLL,))
+
+       def doSuspend(self, suspended):
+               if suspended:
+                       self.clock_timer.stop()
+               else:
+                       self.clock_timer.start(1000)
+                       self.poll()