1 from components import *
3 from enigma import quitMainloop
6 from xml.dom import EMPTY_NAMESPACE
7 from skin import elementsWithTag
13 screen["clock"] = Clock()
15 class Screen(dict, HTMLSkin, GUISkin):
18 def __init__(self, session):
19 self.skinName = self.__class__.__name__
20 self.session = session
21 GUISkin.__init__(self)
24 # assert self.session == None, "a screen can only exec one per time"
25 # self.session = session
26 for (name, val) in self.items():
30 for (name, val) in self.items():
32 # assert self.session != None, "execEnd on non-execing screen!"
35 # never call this directly - it will be called from the session!
40 for (name, val) in self.items():
41 print "%s -> %d" % (name, sys.getrefcount(val))
44 def close(self, retval=None):
48 mdom = xml.dom.minidom.parseString(
50 <menu text="Mainmenu" title="the real Mainmenu">
51 <item text="Standby debug">quitMainloop()</item>
52 <item text="Automatic Scan">self.openDialog(serviceScan)</item>
54 <item text="TV-Mode">self.setModeTV()</item>
55 <item text="Radio-Mode">self.setModeRadio()</item>
56 <item text="File-Mode">self.setModeFile()</item>
57 <item text="Scart">self.openDialog(ScartLoopThrough)</item>
58 <item text="Timer"></item>
60 <menu text="Service Organising">
61 <item text="New Bouquets"></item>
62 <item text="Add to Bouquets"></item>
63 <item text="Edit Bouquets"></item>
65 <menu text="Service Searching">
66 <item text="Satelliteconfig"></item>
67 <item text="Satfinder"></item>
68 <item text="Rotor Control"></item>
69 <item text="Edit Transponder"></item>
70 <item text="Automatic Scan">self.openDialog(serviceScan)</item>
71 <item text="Automatic 'Multisat' Scan"></item>
72 <item text="Manual Scan"></item>
75 <item text="Time Date"></item>
76 <item text="Video Audio"></item>
77 <item text="UHF Modulator"></item>
78 <item text="Harddisk"></item>
79 <item text="Keyboard"></item>
80 <item text="OSD">self.openDialog(configOSD)</item>
81 <item text="Language"></item>
82 <item text="LCD"></item>
84 <item text="Common Interface"></item>
85 <item text="Parental Control"></item>
86 <item text="Expert"></item>
88 <item text="Games"></item>
89 <item text="Information"></item>
91 <item text="PowerOff"></item>
92 <item text="Restart"></item>
93 <item text="Standby"></item>
94 <item text="Sleep Timer">self.goSetup()</item>
98 def getText(nodelist):
100 for node in nodelist:
101 if node.nodeType == node.TEXT_NODE:
105 def getValbyAttr(x, attr):
106 for p in range(x.attributes.length):
107 a = x.attributes.item(p)
116 def __init__(self, fnc, *args):
122 class configOSD(Screen):
123 #this needs focus handling - so not useable
125 def okbuttonClick(self):
128 def __init__(self, session):
129 Screen.__init__(self, session)
131 self["actions"] = ActionMap(["OkCancelActions"],
133 "ok": self.okbuttonClick,
137 self["okbutton"] = Button("Save")
139 self["txt_alpha"] = Label("Alpha:")
140 self["sld_alpha"] = ProgressBar()
141 self["sld_alpha"].setValue(50)
143 self["txt_brightness"] = Label("Brightness:")
144 self["sld_brightness"] = ProgressBar()
145 self["sld_brightness"].setValue(50)
147 self["txt_gamma"] = Label("Contrast:")
148 self["sld_gamma"] = ProgressBar()
149 self["sld_gamma"].setValue(50)
152 class ScartLoopThrough(Screen):
153 def __init__(self, session):
154 Screen.__init__(self, session)
156 self["actions"] = ActionMap(["OkCancelActions"],
161 class ConfigMenu(Screen):
162 #create a generic class for view/edit settings
163 #all stuff come from xml file
164 #configtype / datasource / validate-call / ...
166 def __init__(self, session):
167 Screen.__init__(self, session)
169 self["actions"] = ActionMap(["OkCancelActions"],
171 #"ok": self.okbuttonClick,
175 class configTest(Screen):
177 def __init__(self, session):
178 Screen.__init__(self, session)
181 self["config"] = ConfigList(
183 configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN"),
184 configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN"),
187 self["actions"] = ActionMap(["OkCancelActions"],
189 "ok": self["config"].toggle,
195 #add file load functions for the xml-file
196 #remove old code (i.e. goScan / goClock...)
198 def openDialog(self, dialog):
199 self.session.open(dialog)
202 self.session.open(configTest)
205 print "set Mode to TV"
208 def setModeRadio(self):
209 print "set Mode to Radio"
212 def setModeFile(self):
213 print "set Mode to File"
217 self.session.open(serviceScan)
220 self.session.open(clockDisplay, Clock())
222 def okbuttonClick(self):
223 selection = self["menu"].getCurrent()
226 def evalText(self, text):
229 def nothing(self): #dummy
232 def addMenu(self, destList, node):
233 MenuTitle = getValbyAttr(node, "text")
234 if MenuTitle != "": #check for title
235 a = boundFunction(self.session.open, Menu, node, node.childNodes)
236 #TODO add check if !empty(node.childNodes)
237 destList.append((MenuTitle, a))
239 def addItem(self, destList, node):
240 ItemText = getValbyAttr(node, "text")
241 if ItemText != "": #check for name
242 b = getText(node.childNodes)
243 if b != "": #check for function
244 destList.append((ItemText,boundFunction(self.evalText,b)))
246 destList.append((ItemText,self.nothing)) #use dummy as function
248 def __init__(self, session, parent, childNode):
249 Screen.__init__(self, session)
253 for x in childNode: #walk through the actual nodelist
254 if x.nodeType != xml.dom.minidom.Element.nodeType:
256 elif x.tagName == 'item':
257 self.addItem(list, x)
258 elif x.tagName == 'menu':
259 self.addMenu(list, x)
261 self["menu"] = MenuList(list)
263 self["actions"] = ActionMap(["OkCancelActions"],
265 "ok": self.okbuttonClick,
269 a = getValbyAttr(parent, "title")
270 if a == "": #if empty use name
271 a = getValbyAttr(parent, "text")
272 self["title"] = Header(a)
274 class channelSelection(Screen):
275 def __init__(self, session):
276 Screen.__init__(self, session)
278 self["key_red"] = Button("red")
279 self["key_green"] = Button("green")
280 self["key_yellow"] = Button("yellow")
281 self["key_blue"] = Button("blue")
283 self["list"] = ServiceList()
284 self["list"].setRoot(eServiceReference("""1:0:1:0:0:0:0:0:0:0:(provider=="ARD") && (type == 1)"""))
286 #self["okbutton"] = Button("ok", [self.channelSelected])
288 class ChannelActionMap(ActionMap):
289 def action(self, contexts, action):
290 if action[:7] == "bouquet":
291 print "setting root to " + action[8:]
292 self.csel["list"].setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:" + action[8:]))
294 ActionMap.action(self, contexts, action)
296 self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions"],
298 "cancel": self.close,
299 "ok": self.channelSelected,
302 self["actions"].csel = self
305 ref = self["list"].getCurrent()
306 if self["list"].isMarked(ref):
307 self["list"].removeMarked(ref)
309 self["list"].addMarked(ref)
311 def channelSelected(self):
312 self.session.nav.playService(self["list"].getCurrent())
317 self["list"].moveUp()
318 self.session.nav.playService(self["list"].getCurrent())
321 self["list"].moveDown()
322 self.session.nav.playService(self["list"].getCurrent())
324 class infoBar(Screen):
325 def __init__(self, session):
326 Screen.__init__(self, session)
329 self.servicelist = self.session.instantiateDialog(channelSelection)
331 self["actions"] = ActionMap( [ "InfobarActions" ],
333 "switchChannel": self.switchChannel,
334 "mainMenu": self.mainMenu,
336 "zapDown": self.zapDown,
337 "instantRecord": self.instantRecord
339 self["okbutton"] = Button("mainMenu", [self.mainMenu])
341 self["CurrentTime"] = Clock()
343 self["ServiceName"] = ServiceName(self.session.nav)
345 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
346 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
348 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
349 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
351 self.recording = None
354 print "loading mainmenu XML..."
355 menu = mdom.childNodes[0]
356 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
357 self.session.open(Menu, menu, menu.childNodes)
359 def switchChannel(self):
360 self.session.execDialog(self.servicelist)
363 self.servicelist.zapUp()
366 self.servicelist.zapDown()
368 def instantRecord(self):
369 if self.recording != None:
371 self.session.nav.RecordTimer.removeEntry(self.recording)
372 self.recording = None
374 serviceref = self.session.nav.getCurrentlyPlayingServiceReference()
376 # try to get event info
378 service = self.session.nav.getCurrentService()
380 info = iServiceInformationPtr()
381 if not service.info(info):
382 ev = eServiceEventPtr()
383 if info.getEvent(ev, 0) == 0:
386 self.recording = self.session.nav.recordWithTimer(time.time(), time.time() + 30, serviceref, epg)
387 print "got entry: %s" % (str(self.recording))
389 # a clock display dialog
390 class clockDisplay(Screen):
394 def __init__(self, session, clock):
395 Screen.__init__(self, session)
396 self["theClock"] = clock
398 b.onClick = [ self.okbutton ]
400 self["title"] = Header("clock dialog: here you see the current uhrzeit!")
402 class serviceScan(Screen):
405 if self["scan"].isDone():
409 print "cancel not yet implemented ;)"
411 def __init__(self, session):
412 Screen.__init__(self, session)
414 self["scan_progress"] = ProgressBar()
415 self["scan_state"] = Label("scan state")
416 self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"])
418 self["actions"] = ActionMap(["OkCancelActions"],
421 "cancel": self.cancel