finish the TimerEntry editor... should work now for editing repeated timers
[enigma2.git] / lib / python / Components / TimerList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3
4 from Tools.FuzzyDate import FuzzyTime
5
6 from enigma import eListboxPythonMultiContent, eListbox, gFont
7 from timer import TimerEntry
8
9 RT_HALIGN_LEFT = 0
10 RT_HALIGN_RIGHT = 1
11 RT_HALIGN_CENTER = 2
12 RT_HALIGN_BLOCK = 4
13
14 RT_VALIGN_TOP = 0
15 RT_VALIGN_CENTER = 8
16 RT_VALIGN_BOTTOM = 16
17
18 RT_WRAP = 32
19
20
21 #
22 #  | <Service>     <Name of the Timer>  |
23 #  | <start, end>              <state>  |
24 #
25 def TimerEntryComponent(timer, processed):
26         res = [ timer ]
27         
28
29         res.append((0, 0, 400, 30, 0, RT_HALIGN_LEFT, timer.service_ref.getServiceName()))
30         res.append((0, 30, 200, 20, 1, RT_HALIGN_LEFT, "%s, %s ... %s" % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:])))
31
32         res.append((300, 0, 200, 20, 1, RT_HALIGN_RIGHT, timer.description))
33         
34         if not processed:
35                 if timer.state == TimerEntry.StateWait:
36                         state = "waiting"
37                 elif timer.state == TimerEntry.StatePrepare:
38                         state = "about to start"
39                 elif timer.state == TimerEntry.StateRunning:
40                         state = "recording..."
41                 else:
42                         state = "<unknown>"
43         else:
44                 state = "done!"
45         
46         res.append((300, 30, 200, 20, 1, RT_HALIGN_RIGHT, state))
47         
48         return res
49
50 class TimerList(HTMLComponent, GUIComponent):
51         def __init__(self, list):
52                 GUIComponent.__init__(self)
53                 self.l = eListboxPythonMultiContent()
54                 self.l.setList(list)
55                 self.l.setFont(0, gFont("Arial", 20))
56                 self.l.setFont(1, gFont("Arial", 18))
57         
58         def getCurrent(self):
59                 return self.l.getCurrentSelection()
60         
61         def GUIcreate(self, parent):
62                 self.instance = eListbox(parent)
63                 self.instance.setContent(self.l)
64                 self.instance.setItemHeight(50)
65         
66         def GUIdelete(self):
67                 self.instance.setContent(None)
68                 self.instance = None
69
70         def invalidate(self):
71                 self.l.invalidate()
72