Merge branch 'bug_271_ac3pcm_delay_servicemp3' into experimental
[enigma2.git] / lib / python / Components / Sources / Clock.py
1 from Components.Element import cached
2 from enigma import eTimer
3 from time import time as getTime
4
5 from Source import Source
6
7 class Clock(Source):
8         def __init__(self):
9                 Source.__init__(self)
10                 self.clock_timer = eTimer()
11                 self.clock_timer.callback.append(self.poll)
12                 self.clock_timer.start(1000)
13
14         @cached
15         def getClock(self):
16                 return getTime()
17
18         time = property(getClock)
19
20         def poll(self):
21                 self.changed((self.CHANGED_POLL,))
22
23         def doSuspend(self, suspended):
24                 if suspended:
25                         self.clock_timer.stop()
26                 else:
27                         self.clock_timer.start(1000)
28                         self.poll()
29
30         def destroy(self):
31                 self.clock_timer.callback.remove(self.poll)
32                 Source.destroy(self)