X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/2e874fa14264bf37f17ae9b9375e26059e7f35ec..cfb7ccb1ee949337ebbbde784828ed46943af6eb:/lib/python/Components/Sources/Clock.py diff --git a/lib/python/Components/Sources/Clock.py b/lib/python/Components/Sources/Clock.py index f840ea24..4833ddde 100644 --- a/lib/python/Components/Sources/Clock.py +++ b/lib/python/Components/Sources/Clock.py @@ -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()