1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
4 from Tools.FuzzyDate import FuzzyTime
6 from enigma import eListboxPythonMultiContent, eListbox, gFont, loadPNG, \
7 RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_VALIGN_CENTER
8 from timer import TimerEntry
9 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
11 class TimerList(HTMLComponent, GUIComponent, object):
13 # | <Service> <Name of the Timer> |
14 # | <start, end> <state> |
16 def buildTimerEntry(self, timer, processed):
17 width = self.l.getItemSize().width()
19 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, width, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.service_ref.getServiceName()))
20 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, width, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.name))
23 days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]
25 flags = timer.repeated
31 repeatedtext += days[x]
35 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s "+ _("(ZAP)")) % (FuzzyTime(timer.begin)[1]))))
37 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 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))))
40 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (("%s, %s " + _("(ZAP)")) % (FuzzyTime(timer.begin)))))
42 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 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,)))))
45 if timer.state == TimerEntry.StateWaiting:
47 elif timer.state == TimerEntry.StatePrepared:
48 state = _("about to start")
49 elif timer.state == TimerEntry.StateRunning:
53 state = _("recording...")
55 state = _("<unknown>")
62 res.append((eListboxPythonMultiContent.TYPE_TEXT, width-240, 50, 240, 20, 1, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, state))
65 png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "redx.png"))
66 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 490, 5, 40, 40, png))
69 def __init__(self, list):
70 GUIComponent.__init__(self)
71 self.l = eListboxPythonMultiContent()
72 self.l.setBuildFunc(self.buildTimerEntry)
73 self.l.setFont(0, gFont("Regular", 20))
74 self.l.setFont(1, gFont("Regular", 18))
75 self.l.setItemHeight(70)
79 cur = self.l.getCurrentSelection()
84 def postWidgetCreate(self, instance):
85 instance.setContent(self.l)
87 def moveToIndex(self, index):
88 self.instance.moveSelectionTo(index)
90 def getCurrentIndex(self):
91 return self.instance.getCurrentIndex()
93 currentIndex = property(moveToIndex, getCurrentIndex)
94 currentSelection = property(getCurrent)
97 self.instance.moveSelection(self.instance.moveDown)