1 from components import *
3 from enigma import quitMainloop
6 from xml.dom import EMPTY_NAMESPACE
7 from skin import elementsWithTag
12 screen["clock"] = Clock()
14 class Screen(dict, HTMLSkin, GUISkin):
17 def __init__(self, session):
18 self.skinName = self.__class__.__name__
19 self.session = session
20 GUISkin.__init__(self)
23 # assert self.session == None, "a screen can only exec one per time"
24 # self.session = session
25 for (name, val) in self.items():
29 for (name, val) in self.items():
31 # assert self.session != None, "execEnd on non-execing screen!"
34 # never call this directly - it will be called from the session!
39 for (name, val) in self.items():
40 print "%s -> %d" % (name, sys.getrefcount(val))
43 def close(self, retval=None):
47 mdom = xml.dom.minidom.parseString(
49 <menu text="Mainmenu" title="the real Mainmenu">
50 <item text="Standby debug">quitMainloop()</item>
51 <item text="Automatic Scan">self.openDialog(serviceScan)</item>
53 <item text="TV-Mode">self.setModeTV()</item>
54 <item text="Radio-Mode">self.setModeRadio()</item>
55 <item text="File-Mode">self.setModeFile()</item>
56 <item text="Scart">self.openDialog(ScartLoopThrough)</item>
57 <item text="Timer"></item>
59 <menu text="Service Organising">
60 <item text="New Bouquets"></item>
61 <item text="Add to Bouquets"></item>
62 <item text="Edit Bouquets"></item>
64 <menu text="Service Searching">
65 <item text="Satelliteconfig"></item>
66 <item text="Satfinder"></item>
67 <item text="Rotor Control"></item>
68 <item text="Edit Transponder"></item>
69 <item text="Automatic Scan">self.openDialog(serviceScan)</item>
70 <item text="Automatic 'Multisat' Scan"></item>
71 <item text="Manual Scan"></item>
74 <item text="Time Date"></item>
75 <item text="Video Audio"></item>
76 <item text="UHF Modulator"></item>
77 <item text="Harddisk"></item>
78 <item text="Keyboard"></item>
79 <item text="OSD">self.openDialog(configOSD)</item>
80 <item text="Language"></item>
81 <item text="LCD"></item>
83 <item text="Common Interface"></item>
84 <item text="Parental Control"></item>
85 <item text="Expert"></item>
87 <item text="Games"></item>
88 <item text="Information"></item>
90 <item text="PowerOff"></item>
91 <item text="Restart"></item>
92 <item text="Standby"></item>
93 <item text="Sleep Timer">self.goSetup()</item>
97 def getText(nodelist):
100 if node.nodeType == node.TEXT_NODE:
104 def getValbyAttr(x, attr):
105 for p in range(x.attributes.length):
106 a = x.attributes.item(p)
115 def __init__(self, fnc, *args):
121 class configOSD(Screen):
122 #this needs focus handling - so not useable
124 def okbuttonClick(self):
127 def __init__(self, session):
128 Screen.__init__(self, session)
130 self["actions"] = ActionMap(["OkCancelActions"],
132 "ok": self.okbuttonClick,
136 self["okbutton"] = Button("Save")
138 self["txt_alpha"] = Label("Alpha:")
139 self["sld_alpha"] = ProgressBar()
140 self["sld_alpha"].setValue(50)
142 self["txt_brightness"] = Label("Brightness:")
143 self["sld_brightness"] = ProgressBar()
144 self["sld_brightness"].setValue(50)
146 self["txt_gamma"] = Label("Contrast:")
147 self["sld_gamma"] = ProgressBar()
148 self["sld_gamma"].setValue(50)
151 class ScartLoopThrough(Screen):
152 def __init__(self, session):
153 Screen.__init__(self, session)
155 self["actions"] = ActionMap(["OkCancelActions"],
160 class ConfigMenu(Screen):
161 #create a generic class for view/edit settings
162 #all stuff come from xml file
163 #configtype / datasource / validate-call / ...
165 def __init__(self, session):
166 Screen.__init__(self, session)
168 self["actions"] = ActionMap(["OkCancelActions"],
170 #"ok": self.okbuttonClick,
174 class configTest(Screen):
176 def __init__(self, session):
177 Screen.__init__(self, session)
180 self["config"] = ConfigList(
182 configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN"),
183 configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN"),
186 self["actions"] = ActionMap(["OkCancelActions"],
188 "ok": self["config"].toggle,
194 #add file load functions for the xml-file
195 #remove old code (i.e. goScan / goClock...)
197 def openDialog(self, dialog):
198 self.session.open(dialog)
201 self.session.open(configTest)
204 print "set Mode to TV"
207 def setModeRadio(self):
208 print "set Mode to Radio"
211 def setModeFile(self):
212 print "set Mode to File"
216 self.session.open(serviceScan)
219 self.session.open(clockDisplay, Clock())
221 def okbuttonClick(self):
222 selection = self["menu"].getCurrent()
225 def evalText(self, text):
228 def nothing(self): #dummy
231 def addMenu(self, destList, node):
232 MenuTitle = getValbyAttr(node, "text")
233 if MenuTitle != "": #check for title
234 a = boundFunction(self.session.open, Menu, node, node.childNodes)
235 #TODO add check if !empty(node.childNodes)
236 destList.append((MenuTitle, a))
238 def addItem(self, destList, node):
239 ItemText = getValbyAttr(node, "text")
240 if ItemText != "": #check for name
241 b = getText(node.childNodes)
242 if b != "": #check for function
243 destList.append((ItemText,boundFunction(self.evalText,b)))
245 destList.append((ItemText,self.nothing)) #use dummy as function
247 def __init__(self, session, parent, childNode):
248 Screen.__init__(self, session)
252 for x in childNode: #walk through the actual nodelist
253 if x.nodeType != xml.dom.minidom.Element.nodeType:
255 elif x.tagName == 'item':
256 self.addItem(list, x)
257 elif x.tagName == 'menu':
258 self.addMenu(list, x)
260 self["menu"] = MenuList(list)
262 self["actions"] = ActionMap(["OkCancelActions"],
264 "ok": self.okbuttonClick,
268 a = getValbyAttr(parent, "title")
269 if a == "": #if empty use name
270 a = getValbyAttr(parent, "text")
271 self["title"] = Header(a)
273 class channelSelection(Screen):
274 def __init__(self, session):
275 Screen.__init__(self, session)
277 self["key_red"] = Button("red")
278 self["key_green"] = Button("green")
279 self["key_yellow"] = Button("yellow")
280 self["key_blue"] = Button("blue")
282 self["list"] = ServiceList()
283 self["list"].setRoot(eServiceReference("""1:0:1:0:0:0:0:0:0:0:(provider=="ARD") && (type == 1)"""))
285 #self["okbutton"] = Button("ok", [self.channelSelected])
287 class ChannelActionMap(ActionMap):
288 def action(self, contexts, action):
289 if action[:7] == "bouquet":
290 print "setting root to " + action[8:]
291 self.csel["list"].setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:" + action[8:]))
293 ActionMap.action(self, contexts, action)
295 self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions"],
297 "cancel": self.close,
298 "ok": self.channelSelected,
301 self["actions"].csel = self
304 ref = self["list"].getCurrent()
305 if self["list"].isMarked(ref):
306 self["list"].removeMarked(ref)
308 self["list"].addMarked(ref)
310 def channelSelected(self):
311 self.session.nav.playService(self["list"].getCurrent())
316 self["list"].moveUp()
317 self.session.nav.playService(self["list"].getCurrent())
320 self["list"].moveDown()
321 self.session.nav.playService(self["list"].getCurrent())
323 class infoBar(Screen):
324 def __init__(self, session):
325 Screen.__init__(self, session)
328 self.servicelist = self.session.instantiateDialog(channelSelection)
330 self["actions"] = ActionMap( [ "InfobarActions" ],
332 "switchChannel": self.switchChannel,
333 "mainMenu": self.mainMenu,
335 "zapDown": self.zapDown,
336 "instantRecord": self.instantRecord
338 self["okbutton"] = Button("mainMenu", [self.mainMenu])
340 self["CurrentTime"] = Clock()
342 self["ServiceName"] = ServiceName(self.session.nav)
344 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
345 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
347 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
348 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
353 print "loading mainmenu XML..."
354 menu = mdom.childNodes[0]
355 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
356 self.session.open(Menu, menu, menu.childNodes)
358 def switchChannel(self):
359 self.session.execDialog(self.servicelist)
362 self.servicelist.zapUp()
365 self.servicelist.zapDown()
367 def instantRecord(self):
369 self.session.nav.endRecording()
372 self.session.nav.recordService(self.session.nav.getCurrentlyPlayingServiceReference())
375 # a clock display dialog
376 class clockDisplay(Screen):
380 def __init__(self, session, clock):
381 Screen.__init__(self, session)
382 self["theClock"] = clock
384 b.onClick = [ self.okbutton ]
386 self["title"] = Header("clock dialog: here you see the current uhrzeit!")
388 class serviceScan(Screen):
391 if self["scan"].isDone():
395 print "cancel not yet implemented ;)"
397 def __init__(self, session):
398 Screen.__init__(self, session)
400 self["scan_progress"] = ProgressBar()
401 self["scan_state"] = Label("scan state")
402 self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"])
404 self["actions"] = ActionMap(["OkCancelActions"],
407 "cancel": self.cancel