1 from HTMLComponent import *
2 from GUIComponent import *
4 from Tools.FuzzyDate import FuzzyTime
7 from enigma import eListboxPythonMultiContent, eListbox, gFont, loadPNG, \
8 RT_HALIGN_CENTER, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_VALIGN_CENTER
9 from timer import TimerEntry
10 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
13 # | <Service> <Name of the Timer> |
14 # | <start, end> <state> |
16 def TimerEntryComponent(timer, processed):
19 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 560, 30, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.service_ref.getServiceName()))
20 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, 560, 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>")
59 res.append((eListboxPythonMultiContent.TYPE_TEXT, 320, 50, 240, 20, 1, RT_HALIGN_RIGHT|RT_VALIGN_CENTER, state))
62 png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "redx.png"))
63 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 490, 5, 40, 40, png))
67 class TimerList(HTMLComponent, GUIComponent, object):
68 def __init__(self, list):
69 GUIComponent.__init__(self)
70 self.l = eListboxPythonMultiContent()
72 self.l.setFont(0, gFont("Regular", 20))
73 self.l.setFont(1, gFont("Regular", 18))
76 return self.l.getCurrentSelection()
80 def postWidgetCreate(self, instance):
81 instance.setContent(self.l)
82 instance.setItemHeight(70)
84 def moveToIndex(self, index):
85 self.instance.moveSelectionTo(index)
87 def getCurrentIndex(self):
88 return self.instance.getCurrentIndex()
90 currentIndex = property(moveToIndex, getCurrentIndex)
91 currentSelection = property(getCurrent)
94 self.instance.moveSelection(self.instance.moveDown)