set defaults
[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
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>  |
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" % FuzzyTime(timer.begin)))
31
32         res.append((200, 0, 200, 20, 1, RT_HALIGN_RIGHT, timer.description))    
33         if processed:
34                 res.append((200, 30, 200, 20, 1, RT_HALIGN_RIGHT, FuzzyTime(timer.end)[1]))
35         else:
36                 res.append((200, 30, 200, 20, 1, RT_HALIGN_RIGHT, "done"))
37         return res
38
39 class TimerList(HTMLComponent, GUIComponent):
40         def __init__(self, list):
41                 GUIComponent.__init__(self)
42                 self.l = eListboxPythonMultiContent()
43                 self.l.setList(list)
44                 self.l.setFont(0, gFont("Arial", 20))
45                 self.l.setFont(1, gFont("Arial", 18))
46         
47         def getCurrent(self):
48                 return self.l.getCurrentSelection()
49         
50         def GUIcreate(self, parent):
51                 self.instance = eListbox(parent)
52                 self.instance.setContent(self.l)
53                 self.instance.setItemHeight(50)
54         
55         def GUIdelete(self):
56                 self.instance.setContent(None)
57                 self.instance = None
58
59