1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
4 from Tools.FuzzyDate import FuzzyTime
6 from enigma import eListboxPythonMultiContent, eListbox, gFont, \
7 RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_VALIGN_CENTER
8 from Tools.LoadPixmap import LoadPixmap
9 from timer import TimerEntry
10 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
12 class TimerList(HTMLComponent, GUIComponent, object):
14 # | <Service> <Name of the Timer> |
15 # | <start, end> <state> |
17 def buildTimerEntry(self, timer, processed):
18 width = self.l.getItemSize().width()
20 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, width, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.service_ref.getServiceName()))
21 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, width, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.name))
24 days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]
26 flags = timer.repeated
32 repeatedtext += days[x]
36 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width-150, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s "+ _("(ZAP)")) % (FuzzyTime(timer.begin)[1]))))
38 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width-150, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s ... %s (%d " + _("mins") + ")") % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1], (timer.end - timer.begin) / 60))))
41 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width-150, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (("%s, %s " + _("(ZAP)")) % (FuzzyTime(timer.begin)))))
43 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, width-150, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (("%s, %s ... %s (%d " + _("mins") + ")") % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:] + ((timer.end - timer.begin) / 60,)))))
46 if timer.state == TimerEntry.StateWaiting:
48 elif timer.state == TimerEntry.StatePrepared:
49 state = _("about to start")
50 elif timer.state == TimerEntry.StateRunning:
54 state = _("recording...")
55 elif timer.state == TimerEntry.StateEnded:
58 state = _("<unknown>")
65 res.append((eListboxPythonMultiContent.TYPE_TEXT, width-150, 50, 150, 20, 1, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, state))
68 png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/redx.png"))
69 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 490, 5, 40, 40, png))
72 def __init__(self, list):
73 GUIComponent.__init__(self)
74 self.l = eListboxPythonMultiContent()
75 self.l.setBuildFunc(self.buildTimerEntry)
76 self.l.setFont(0, gFont("Regular", 20))
77 self.l.setFont(1, gFont("Regular", 18))
78 self.l.setItemHeight(70)
82 cur = self.l.getCurrentSelection()
87 def postWidgetCreate(self, instance):
88 instance.setContent(self.l)
90 def moveToIndex(self, index):
91 self.instance.moveSelectionTo(index)
93 def getCurrentIndex(self):
94 return self.instance.getCurrentIndex()
96 currentIndex = property(moveToIndex, getCurrentIndex)
97 currentSelection = property(getCurrent)
100 self.instance.moveSelection(self.instance.moveDown)
102 def invalidate(self):
105 def entryRemoved(self, idx):
106 self.l.entryRemoved(idx)