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