webif/sleeptimer: allow to toggle confirmed/ask setting
[enigma2-plugins.git] / webinterface / src / WebComponents / Converter / SleepTimer.py
1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
3
4 class SleepTimer(Converter):
5     ENABLED = 0
6     TIME = 1
7     ACTION = 2
8     CONFIRMED = 3
9     TEXT = 4
10     
11     def __init__(self, type):
12         Converter.__init__(self, type)
13         self.type = { "Enabled" : self.ENABLED,
14                       "Time" : self.TIME,
15                       "Action" : self.ACTION,
16                       "Text" : self.TEXT,
17                       "Confirmed" : self.CONFIRMED,
18                     }[type]
19
20     @cached
21     def getText(self):
22         timer = self.source.timer
23         
24         if self.type is self.ENABLED:
25             return str(timer[0])
26         elif self.type is self.TIME:
27             return str(timer[1])
28         elif self.type is self.ACTION:
29             return str(timer[2])
30         elif self.type is self.CONFIRMED:
31             return str(timer[3])
32         elif self.type is self.TEXT:
33             if not timer[4] is None:
34                 return str(timer[4])
35             else:
36                 return "" 
37         else:
38             return "N/A"
39         
40     text = property(getText)