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="TV-Mode">self.setModeTV()</item>
51 <item text="Radio-Mode">self.setModeRadio()</item>
52 <item text="File-Mode">self.setModeFile()</item>
53 <item text="Scart">self.openDialog(ScartLoopThrough)</item>
54 <item text="Timer"></item>
56 <menu text="Service Organising">
57 <item text="New Bouquets"></item>
58 <item text="Add to Bouquets"></item>
59 <item text="Edit Bouquets"></item>
61 <menu text="Service Searching">
62 <item text="Satelliteconfig"></item>
63 <item text="Satfinder"></item>
64 <item text="Rotor Control"></item>
65 <item text="Edit Transponder"></item>
66 <item text="Automatic Scan">self.openDialog(serviceScan)</item>
67 <item text="Automatic 'Multisat' Scan"></item>
68 <item text="Manual Scan"></item>
71 <item text="Time Date"></item>
72 <item text="Video Audio"></item>
73 <item text="UHF Modulator"></item>
74 <item text="Harddisk"></item>
75 <item text="Keyboard"></item>
76 <item text="OSD">self.openDialog(configOSD)</item>
77 <item text="Language"></item>
78 <item text="LCD"></item>
80 <item text="Common Interface"></item>
81 <item text="Parental Control"></item>
82 <item text="Expert"></item>
84 <item text="Games"></item>
85 <item text="Information"></item>
87 <item text="PowerOff"></item>
88 <item text="Restart"></item>
89 <item text="Standby"></item>
90 <item text="Sleep Timer">self.goSetup()</item>
92 <item text="Standby debug">quitMainloop()</item>
95 def getText(nodelist):
98 if node.nodeType == node.TEXT_NODE:
102 def getValbyAttr(x, attr):
103 for p in range(x.attributes.length):
104 a = x.attributes.item(p)
113 def __init__(self, fnc, *args):
119 class configOSD(Screen):
120 #this needs focus handling - so not useable
122 def okbuttonClick(self):
125 def __init__(self, session):
126 Screen.__init__(self, session)
128 self["actions"] = ActionMap(["OkCancelActions"],
130 "ok": self.okbuttonClick,
134 self["okbutton"] = Button("Save")
136 self["txt_alpha"] = Label("Alpha:")
137 self["sld_alpha"] = ProgressBar()
138 self["sld_alpha"].setValue(50)
140 self["txt_brightness"] = Label("Brightness:")
141 self["sld_brightness"] = ProgressBar()
142 self["sld_brightness"].setValue(50)
144 self["txt_gamma"] = Label("Contrast:")
145 self["sld_gamma"] = ProgressBar()
146 self["sld_gamma"].setValue(50)
149 class ScartLoopThrough(Screen):
150 def __init__(self, session):
151 Screen.__init__(self, session)
153 self["actions"] = ActionMap(["OkCancelActions"],
158 class ConfigMenu(Screen):
159 #create a generic class for view/edit settings
160 #all stuff come from xml file
161 #configtype / datasource / validate-call / ...
163 def __init__(self, session):
164 Screen.__init__(self, session)
166 self["actions"] = ActionMap(["OkCancelActions"],
168 #"ok": self.okbuttonClick,
172 class configTest(Screen):
174 def __init__(self, session):
175 Screen.__init__(self, session)
178 self["config"] = ConfigList(
180 configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN"),
181 configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN"),
184 self["actions"] = ActionMap(["OkCancelActions"],
186 "ok": self["config"].toggle,
192 #add file load functions for the xml-file
193 #remove old code (i.e. goScan / goClock...)
195 def openDialog(self, dialog):
196 self.session.open(dialog)
199 self.session.open(configTest)
202 print "set Mode to TV"
205 def setModeRadio(self):
206 print "set Mode to Radio"
209 def setModeFile(self):
210 print "set Mode to File"
214 self.session.open(serviceScan)
217 self.session.open(clockDisplay, Clock())
219 def okbuttonClick(self):
220 selection = self["menu"].getCurrent()
223 def evalText(self, text):
226 def nothing(self): #dummy
229 def addMenu(self, destList, node):
230 MenuTitle = getValbyAttr(node, "text")
231 if MenuTitle != "": #check for title
232 a = boundFunction(self.session.open, Menu, node, node.childNodes)
233 #TODO add check if !empty(node.childNodes)
234 destList.append((MenuTitle, a))
236 def addItem(self, destList, node):
237 ItemText = getValbyAttr(node, "text")
238 if ItemText != "": #check for name
239 b = getText(node.childNodes)
240 if b != "": #check for function
241 destList.append((ItemText,boundFunction(self.evalText,b)))
243 destList.append((ItemText,self.nothing)) #use dummy as function
245 def __init__(self, session, parent, childNode):
246 Screen.__init__(self, session)
250 for x in childNode: #walk through the actual nodelist
251 if x.nodeType != xml.dom.minidom.Element.nodeType:
253 elif x.tagName == 'item':
254 self.addItem(list, x)
255 elif x.tagName == 'menu':
256 self.addMenu(list, x)
258 self["menu"] = MenuList(list)
260 self["actions"] = ActionMap(["OkCancelActions"],
262 "ok": self.okbuttonClick,
266 a = getValbyAttr(parent, "title")
267 if a == "": #if empty use name
268 a = getValbyAttr(parent, "text")
269 self["title"] = Header(a)
271 class channelSelection(Screen):
272 def __init__(self, session):
273 Screen.__init__(self, session)
275 self["key_red"] = Button("red")
276 self["key_green"] = Button("green")
277 self["key_yellow"] = Button("yellow")
278 self["key_blue"] = Button("blue")
280 self["list"] = ServiceList()
281 self["list"].setRoot(eServiceReference("""1:0:1:0:0:0:0:0:0:0:(provider=="ARD") && (type == 1)"""))
283 #self["okbutton"] = Button("ok", [self.channelSelected])
285 class ChannelActionMap(ActionMap):
286 def action(self, contexts, action):
287 if action[:7] == "bouquet":
288 print "setting root to " + action[8:]
289 self.csel["list"].setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:" + action[8:]))
291 ActionMap.action(self, contexts, action)
293 self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions"],
295 "cancel": self.close,
296 "ok": self.channelSelected,
299 self["actions"].csel = self
302 ref = self["list"].getCurrent()
303 if self["list"].isMarked(ref):
304 self["list"].removeMarked(ref)
306 self["list"].addMarked(ref)
308 def channelSelected(self):
309 self.session.nav.playService(self["list"].getCurrent())
314 self["list"].moveUp()
315 self.session.nav.playService(self["list"].getCurrent())
318 self["list"].moveDown()
319 self.session.nav.playService(self["list"].getCurrent())
321 class infoBar(Screen):
322 def __init__(self, session):
323 Screen.__init__(self, session)
326 self["ServiceList"] = self.session.instantiateDialog(channelSelection)
328 self["actions"] = ActionMap( [ "InfobarActions" ],
330 "switchChannel": self.switchChannel,
331 "mainMenu": self.mainMenu,
333 "zapDown": self.zapDown
335 self["okbutton"] = Button("mainMenu", [self.mainMenu])
337 self["CurrentTime"] = Clock()
339 self["ServiceName"] = ServiceName(self.session.nav)
341 self["Event_Now"] = EventInfo(self.session.nav, EventInfo.Now)
342 self["Event_Next"] = EventInfo(self.session.nav, EventInfo.Next)
344 self["Event_Now_Duration"] = EventInfo(self.session.nav, EventInfo.Now_Duration)
345 self["Event_Next_Duration"] = EventInfo(self.session.nav, EventInfo.Next_Duration)
348 print "loading mainmenu XML..."
349 menu = mdom.childNodes[0]
350 assert menu.tagName == "menu", "root element in menu must be 'menu'!"
351 self.session.open(Menu, menu, menu.childNodes)
353 def switchChannel(self):
354 self.session.execDialog(self["ServiceList"])
357 self["ServiceList"].zapUp()
360 self["ServiceList"].zapDown()
362 # a clock display dialog
363 class clockDisplay(Screen):
367 def __init__(self, session, clock):
368 Screen.__init__(self, session)
369 self["theClock"] = clock
371 b.onClick = [ self.okbutton ]
373 self["title"] = Header("clock dialog: here you see the current uhrzeit!")
375 class serviceScan(Screen):
378 if self["scan"].isDone():
382 print "cancel not yet implemented ;)"
384 def __init__(self, session):
385 Screen.__init__(self, session)
387 self["scan_progress"] = ProgressBar()
388 self["scan_state"] = Label("scan state")
389 self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"])
391 self["actions"] = ActionMap(["OkCancelActions"],
394 "cancel": self.cancel