1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
4 from enigma import loadPNG, eListboxServiceContent, eListbox, eServiceCenter, eServiceReference, gFont, eRect
6 from string import upper
8 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
10 class ServiceList(HTMLComponent, GUIComponent):
15 GUIComponent.__init__(self)
16 self.l = eListboxServiceContent()
18 pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "folder.png"))
20 self.l.setPixmap(self.l.picFolder, pic)
22 pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "marker-fs8.png"))
24 self.l.setPixmap(self.l.picMarker, pic)
26 pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_s-fs8.png"))
28 self.l.setPixmap(self.l.picDVB_S, pic)
30 pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_c-fs8.png"))
32 self.l.setPixmap(self.l.picDVB_C, pic)
34 pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_dvb_t-fs8.png"))
36 self.l.setPixmap(self.l.picDVB_T, pic)
38 pic = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "ico_service_group-fs8.png"))
40 self.l.setPixmap(self.l.picServiceGroup, pic)
43 self.mode = self.MODE_NORMAL
44 self.onSelectionChanged = [ ]
46 def connectSelChanged(self, fnc):
47 if not fnc in self.onSelectionChanged:
48 self.onSelectionChanged.append(fnc)
50 def disconnectSelChanged(self, fnc):
51 if fnc in self.onSelectionChanged:
52 self.onSelectionChanged.remove(fnc)
54 def selectionChanged(self):
55 for x in self.onSelectionChanged:
58 def setCurrent(self, ref):
59 self.l.setCurrent(ref)
62 r = eServiceReference()
67 return self.instance.atBegin()
70 return self.instance.atEnd()
73 self.instance.moveSelection(self.instance.moveUp)
76 self.instance.moveSelection(self.instance.moveDown)
78 def moveToChar(self, char):
81 index = self.l.getNextBeginningWithChar(char)
82 indexup = self.l.getNextBeginningWithChar(upper(char))
84 if (index > indexup or index == 0):
87 self.instance.moveSelectionTo(index)
88 print "Moving to character " + str(char)
90 def moveToNextMarker(self):
91 idx = self.l.getNextMarkerPos()
92 self.instance.moveSelectionTo(idx)
94 def moveToPrevMarker(self):
95 idx = self.l.getPrevMarkerPos()
96 self.instance.moveSelectionTo(idx)
98 def moveToIndex(self, index):
99 self.instance.moveSelectionTo(index)
101 def getCurrentIndex(self):
102 return self.instance.getCurrentIndex()
104 GUI_WIDGET = eListbox
106 def postWidgetCreate(self, instance):
107 instance.setWrapAround(True)
108 instance.setContent(self.l)
109 instance.selectionChanged.get().append(self.selectionChanged)
110 self.setMode(self.mode)
115 def getRootServices(self):
116 serviceHandler = eServiceCenter.getInstance()
117 list = serviceHandler.list(self.root)
123 dest.append(s.toString())
128 def setNumberOffset(self, offset):
129 self.l.setNumberOffset(offset)
131 def setPlayableIgnoreService(self, ref):
132 self.l.setIgnoreService(ref)
134 def setRoot(self, root, justSet=False):
136 self.l.setRoot(root, justSet)
139 self.selectionChanged()
141 def removeCurrent(self):
142 self.l.removeCurrent()
144 def addService(self, service, beforeCurrent=False):
145 self.l.addService(service, beforeCurrent)
147 def finishFill(self):
148 self.l.FillFinished()
151 # stuff for multiple marks (edit mode / later multiepg)
152 def clearMarks(self):
155 def isMarked(self, ref):
156 return self.l.isMarked(ref)
158 def addMarked(self, ref):
159 self.l.addMarked(ref)
161 def removeMarked(self, ref):
162 self.l.removeMarked(ref)
167 ref = eServiceReference()
169 while i.markedQueryNext(ref) == 0:
170 marked.append(ref.toString())
171 ref = eServiceReference()
174 #just for movemode.. only one marked entry..
175 def setCurrentMarked(self, state):
176 self.l.setCurrentMarked(state)
178 def setMode(self, mode):
181 if mode == self.MODE_NORMAL:
182 self.l.setItemHeight(28)
183 self.l.setVisualMode(eListboxServiceContent.visModeComplex)
184 self.l.setElementFont(self.l.celServiceName, gFont("Regular", 22))
185 self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), 28))
186 self.l.setElementFont(self.l.celServiceInfo, gFont("Regular", 18))
188 self.l.setItemHeight(28)
189 self.l.setVisualMode(eListboxServiceContent.visModeComplex)
190 self.l.setElementFont(self.l.celServiceNumber, gFont("Regular", 20))
191 self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 50, 28))
192 self.l.setElementFont(self.l.celServiceName, gFont("Regular", 22))
193 self.l.setElementPosition(self.l.celServiceName, eRect(60, 0, self.instance.size().width()-60, 28))
194 self.l.setElementFont(self.l.celServiceInfo, gFont("Regular", 18))