X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/2e874fa14264bf37f17ae9b9375e26059e7f35ec..57794b7710b06a1dcc156a91c84bb8316f104f06:/lib/python/Components/Sources/Clock.py diff --git a/lib/python/Components/Sources/Clock.py b/lib/python/Components/Sources/Clock.py index f840ea24..ba672825 100644 --- a/lib/python/Components/Sources/Clock.py +++ b/lib/python/Components/Sources/Clock.py @@ -1,22 +1,32 @@ -from Tools.Event import Event +from Components.Element import cached from enigma import eTimer -import time +from time import time as getTime 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.callback.append(self.poll) self.clock_timer.start(1000) - def stop(self): - self.clock_timer.stop() - + @cached def getClock(self): - return time.time() + return getTime() 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() + + def destroy(self): + self.clock_timer.callback.remove(self.poll) + Source.destroy(self)