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