1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
3 from skin import parseColor, parseFont
5 from enigma import eListboxServiceContent, eListbox, eServiceCenter, eServiceReference, gFont, eRect
6 from Tools.LoadPixmap import LoadPixmap
8 from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN
10 from Components.config import config
12 class ServiceList(HTMLComponent, GUIComponent):
17 GUIComponent.__init__(self)
18 self.l = eListboxServiceContent()
20 pic = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/folder.png"))
22 self.l.setPixmap(self.l.picFolder, pic)
24 pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/marker.png"))
26 self.l.setPixmap(self.l.picMarker, pic)
28 pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_dvb_s-fs8.png"))
30 self.l.setPixmap(self.l.picDVB_S, pic)
32 pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_dvb_c-fs8.png"))
34 self.l.setPixmap(self.l.picDVB_C, pic)
36 pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_dvb_t-fs8.png"))
38 self.l.setPixmap(self.l.picDVB_T, pic)
40 pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "ico_service_group-fs8.png"))
42 self.l.setPixmap(self.l.picServiceGroup, pic)
45 self.mode = self.MODE_NORMAL
47 self.ServiceNameFont = parseFont("Regular;22", ((1,1),(1,1)))
48 self.ServiceInfoFont = parseFont("Regular;18", ((1,1),(1,1)))
49 self.ServiceNumberFont = parseFont("Regular;20", ((1,1),(1,1)))
50 self.onSelectionChanged = [ ]
52 def applySkin(self, desktop, parent):
54 if self.skinAttributes is not None:
56 for (attrib, value) in self.skinAttributes:
57 if attrib == "foregroundColorMarked":
58 self.l.setColor(eListboxServiceContent.markedForeground, parseColor(value))
59 elif attrib == "foregroundColorMarkedSelected":
60 self.l.setColor(eListboxServiceContent.markedForegroundSelected, parseColor(value))
61 elif attrib == "backgroundColorMarked":
62 self.l.setColor(eListboxServiceContent.markedBackground, parseColor(value))
63 elif attrib == "backgroundColorMarkedSelected":
64 self.l.setColor(eListboxServiceContent.markedBackgroundSelected, parseColor(value))
65 elif attrib == "foregroundColorServiceNotAvail":
66 self.l.setColor(eListboxServiceContent.serviceNotAvail, parseColor(value))
67 elif attrib == "colorEventProgressbar":
68 self.l.setColor(eListboxServiceContent.serviceEventProgressbarColor, parseColor(value))
69 elif attrib == "colorEventProgressbarSelected":
70 self.l.setColor(eListboxServiceContent.serviceEventProgressbarColorSelected, parseColor(value))
71 elif attrib == "colorEventProgressbarBorder":
72 self.l.setColor(eListboxServiceContent.serviceEventProgressbarBorderColor, parseColor(value))
73 elif attrib == "colorEventProgressbarBorderSelected":
74 self.l.setColor(eListboxServiceContent.serviceEventProgressbarBorderColorSelected, parseColor(value))
75 elif attrib == "colorServiceDescription":
76 self.l.setColor(eListboxServiceContent.serviceDescriptionColor, parseColor(value))
77 elif attrib == "colorServiceDescriptionSelected":
78 self.l.setColor(eListboxServiceContent.serviceDescriptionColorSelected, parseColor(value))
79 elif attrib == "picServiceEventProgressbar":
80 pic = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, value))
82 self.l.setPixmap(self.l.picServiceEventProgressbar, pic)
83 elif attrib == "serviceItemHeight":
84 self.ItemHeight = int(value)
85 elif attrib == "serviceNameFont":
86 self.ServiceNameFont = parseFont(value, ((1,1),(1,1)))
87 elif attrib == "serviceInfoFont":
88 self.ServiceInfoFont = parseFont(value, ((1,1),(1,1)))
89 elif attrib == "serviceNumberFont":
90 self.ServiceNumberFont = parseFont(value, ((1,1),(1,1)))
92 attribs.append((attrib, value))
93 self.skinAttributes = attribs
94 return GUIComponent.applySkin(self, desktop, parent)
96 def connectSelChanged(self, fnc):
97 if not fnc in self.onSelectionChanged:
98 self.onSelectionChanged.append(fnc)
100 def disconnectSelChanged(self, fnc):
101 if fnc in self.onSelectionChanged:
102 self.onSelectionChanged.remove(fnc)
104 def selectionChanged(self):
105 for x in self.onSelectionChanged:
108 def setCurrent(self, ref):
109 self.l.setCurrent(ref)
111 def getCurrent(self):
112 r = eServiceReference()
117 return self.instance.atBegin()
120 return self.instance.atEnd()
123 self.instance.moveSelection(self.instance.moveUp)
126 self.instance.moveSelection(self.instance.moveDown)
128 def moveToChar(self, char):
129 # TODO fill with life
131 index = self.l.getNextBeginningWithChar(char)
132 indexup = self.l.getNextBeginningWithChar(char.upper())
134 if (index > indexup or index == 0):
137 self.instance.moveSelectionTo(index)
138 print "Moving to character " + str(char)
140 def moveToNextMarker(self):
141 idx = self.l.getNextMarkerPos()
142 self.instance.moveSelectionTo(idx)
144 def moveToPrevMarker(self):
145 idx = self.l.getPrevMarkerPos()
146 self.instance.moveSelectionTo(idx)
148 def moveToIndex(self, index):
149 self.instance.moveSelectionTo(index)
151 def getCurrentIndex(self):
152 return self.instance.getCurrentIndex()
154 GUI_WIDGET = eListbox
156 def postWidgetCreate(self, instance):
157 instance.setWrapAround(True)
158 instance.setContent(self.l)
159 instance.selectionChanged.get().append(self.selectionChanged)
160 self.setMode(self.mode)
162 def preWidgetRemove(self, instance):
163 instance.setContent(None)
164 instance.selectionChanged.get().remove(self.selectionChanged)
169 def getRootServices(self):
170 serviceHandler = eServiceCenter.getInstance()
171 list = serviceHandler.list(self.root)
177 dest.append(s.toString())
182 def setNumberOffset(self, offset):
183 self.l.setNumberOffset(offset)
185 def setPlayableIgnoreService(self, ref):
186 self.l.setIgnoreService(ref)
188 def setRoot(self, root, justSet=False):
190 self.l.setRoot(root, justSet)
193 self.selectionChanged()
195 def removeCurrent(self):
196 self.l.removeCurrent()
198 def addService(self, service, beforeCurrent=False):
199 self.l.addService(service, beforeCurrent)
201 def finishFill(self):
202 self.l.FillFinished()
205 # stuff for multiple marks (edit mode / later multiepg)
206 def clearMarks(self):
209 def isMarked(self, ref):
210 return self.l.isMarked(ref)
212 def addMarked(self, ref):
213 self.l.addMarked(ref)
215 def removeMarked(self, ref):
216 self.l.removeMarked(ref)
221 ref = eServiceReference()
223 while i.markedQueryNext(ref) == 0:
224 marked.append(ref.toString())
225 ref = eServiceReference()
228 #just for movemode.. only one marked entry..
229 def setCurrentMarked(self, state):
230 self.l.setCurrentMarked(state)
232 def setMode(self, mode):
234 self.l.setItemHeight(self.ItemHeight)
235 self.l.setVisualMode(eListboxServiceContent.visModeComplex)
236 if mode == self.MODE_NORMAL:
237 if config.usage.show_event_progress_in_servicelist.value:
238 self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(0, 0, 52, self.ItemHeight))
240 self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(0, 0, 0, 0))
241 self.l.setElementFont(self.l.celServiceName, self.ServiceNameFont)
242 self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), self.ItemHeight))
243 self.l.setElementFont(self.l.celServiceInfo, self.ServiceInfoFont)
245 if config.usage.show_event_progress_in_servicelist.value:
246 self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(60, 0, 52, self.ItemHeight))
248 self.l.setElementPosition(self.l.celServiceEventProgressbar, eRect(60, 0, 0, 0))
249 self.l.setElementFont(self.l.celServiceNumber, self.ServiceNumberFont)
250 self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 50, self.ItemHeight))
251 self.l.setElementFont(self.l.celServiceName, self.ServiceNameFont)
252 self.l.setElementPosition(self.l.celServiceName, eRect(60, 0, self.instance.size().width()-60, self.ItemHeight))
253 self.l.setElementFont(self.l.celServiceInfo, self.ServiceInfoFont)