1 from HTMLComponent import *
2 from GUIComponent import *
3 from Tools.FuzzyDate import FuzzyTime
4 from ServiceReference import ServiceReference
5 from Components.MultiContent import MultiContentEntryText, RT_HALIGN_LEFT, RT_HALIGN_RIGHT
7 from enigma import eListboxPythonMultiContent, eListbox, gFont, iServiceInformation
9 from enigma import eServiceReference, eServiceCenter, \
10 eServiceCenterPtr, iListableServicePtr, \
11 iStaticServiceInformationPtr
13 class MovieList(HTMLComponent, GUIComponent):
14 def __init__(self, root):
15 GUIComponent.__init__(self)
16 self.l = eListboxPythonMultiContent()
19 self.l.setFont(0, gFont("Regular", 22))
20 self.l.setFont(1, gFont("Regular", 18))
21 self.l.setFont(2, gFont("Regular", 16))
22 self.l.setBuildFunc(self.buildMovieListEntry)
27 def buildMovieListEntry(self, serviceref, info, begin, len):
28 if serviceref.flags & eServiceReference.mustDescent:
32 len = "%d:%02d" % (len / 60, len % 60)
38 res.append(MultiContentEntryText(pos=(0, 0), size=(420, 30), font = 0, flags = RT_HALIGN_LEFT, text = info.getName(serviceref)))
39 service = ServiceReference(info.getInfoString(serviceref, iServiceInformation.sServiceref))
40 if service is not None:
41 res.append(MultiContentEntryText(pos=(420, 0), size=(140, 30), font = 2, flags = RT_HALIGN_RIGHT, text = service.getServiceName()))
43 description = info.getInfoString(serviceref, iServiceInformation.sDescription)
48 begin_string = t[0] + ", " + t[1]
50 res.append(MultiContentEntryText(pos=(0, 30), size=(560, 20), font=1, flags=RT_HALIGN_LEFT, text=description))
51 res.append(MultiContentEntryText(pos=(0, 50), size=(270, 20), font=1, flags=RT_HALIGN_LEFT, text=begin_string))
52 res.append(MultiContentEntryText(pos=(290, 50), size=(270, 20), font=1, flags=RT_HALIGN_RIGHT, text=len))
56 def moveToIndex(self, index):
57 self.instance.moveSelectionTo(index)
59 def getCurrentIndex(self):
60 return self.instance.getCurrentIndex()
63 l = self.l.getCurrentSelection()
66 def GUIcreate(self, parent):
67 self.instance = eListbox(parent)
68 self.instance.setContent(self.l)
69 self.instance.setItemHeight(75)
72 self.instance.setContent(None)
75 def reload(self, root = None):
80 self.l.setList(self.list)
82 def removeService(self, service):
83 for l in self.list[:]:
86 self.l.setList(self.list)
91 def updateLengthOfIndex(self, index):
92 if len(self.list) > index:
94 self.list[index] = (x[0], x[1], x[2], x[1].getLength(x[0]))
95 self.l.invalidateEntry(index)
98 # this lists our root service, then building a
104 self.serviceHandler = eServiceCenter.getInstance()
105 list = self.serviceHandler.list(root)
108 raise "listing of movies failed"
111 serviceref = list.getNext()
112 if not serviceref.valid():
114 if serviceref.flags & eServiceReference.mustDescent:
116 info = self.serviceHandler.info(serviceref)
119 begin = info.getInfo(serviceref, iServiceInformation.sTimeCreate)
120 self.list.append((serviceref, info, begin, -1))
122 self.list.sort(key=lambda x: -x[2])
124 def moveTo(self, serviceref):
128 if x[0] == serviceref:
131 self.instance.moveSelectionTo(found)
134 self.instance.moveSelection(self.instance.moveDown)