2 from Components.MenuList import MenuList
3 from Components.ActionMap import ActionMap
4 from Components.Header import Header
5 from Components.Button import Button
6 from Components.Label import Label
7 from Components.ProgressBar import ProgressBar
9 # hack ... must be made dynamic
10 #from Screens.Setup import Setup
11 #from ServiceScan import ServiceScan
12 #from ScartLoopThrough import ScartLoopThrough
13 #from HarddiskSetup import HarddiskSelection
14 #from ConfigMenu import *
18 #from Network import *
20 #from TimerEdit import *
22 # hack.... dynamically importing all screens
23 from __init__ import __all__
26 if (i is not "Menu" ):
27 exec "from " + i + " import *"
29 from enigma import quitMainloop
31 import xml.dom.minidom
32 from xml.dom import EMPTY_NAMESPACE
33 from skin import elementsWithTag
35 from Tools import XMLTools
39 screen["clock"] = Clock()
42 # <item text="TV-Mode">self.setModeTV()</item>
43 # <item text="Radio-Mode">self.setModeRadio()</item>
44 # <item text="File-Mode">self.setModeFile()</item>
45 # <item text="Scart">self.openDialog(ScartLoopThrough)</item>
46 # <item text="Sleep Timer"></item>
51 # first we search in the current path
52 menufile = file('data/menu.xml', 'r')
54 # if not found in the current path, we use the global datadir-path
55 menufile = file('/usr/share/enigma2/menu.xml', 'r')
56 mdom = xml.dom.minidom.parseString(menufile.read())
61 def getValbyAttr(x, attr):
62 for p in range(x.attributes.length):
63 a = x.attributes.item(p)
72 def __init__(self, fnc, *args):
78 class configOSD(Screen):
79 #this needs focus handling - so not useable
81 def okbuttonClick(self):
84 def __init__(self, session):
85 Screen.__init__(self, session)
87 self["actions"] = ActionMap(["OkCancelActions"],
89 "ok": self.okbuttonClick,
93 self["okbutton"] = Button("Save")
95 self["txt_alpha"] = Label("Alpha:")
96 self["sld_alpha"] = ProgressBar()
97 self["sld_alpha"].setValue(50)
99 self["txt_brightness"] = Label("Brightness:")
100 self["sld_brightness"] = ProgressBar()
101 self["sld_brightness"].setValue(50)
103 self["txt_gamma"] = Label("Contrast:")
104 self["sld_gamma"] = ProgressBar()
105 self["sld_gamma"].setValue(50)
108 def okbuttonClick(self):
109 print "okbuttonClick"
110 selection = self["menu"].getCurrent()
113 def evalText(self, text):
116 def nothing(self): #dummy
119 def openDialog(self, dialog): # in every layer needed
120 self.session.open(dialog)
122 def openSetup(self, dialog):
123 self.session.open(Setup, dialog)
125 def addMenu(self, destList, node):
126 MenuTitle = getValbyAttr(node, "text")
127 if MenuTitle != "": #check for title
128 a = boundFunction(self.session.open, Menu, node, node.childNodes)
129 #TODO add check if !empty(node.childNodes)
130 destList.append((MenuTitle, a))
132 def addItem(self, destList, node):
133 ItemText = getValbyAttr(node, "text")
134 if ItemText != "": #check for name
135 b = XMLTools.mergeText(node.childNodes)
136 if b != "": #check for function
137 destList.append((ItemText,boundFunction(self.evalText,b)))
139 destList.append((ItemText,self.nothing)) #use dummy as function
141 def __init__(self, session, parent, childNode):
142 Screen.__init__(self, session)
146 for x in childNode: #walk through the actual nodelist
147 if x.nodeType != xml.dom.minidom.Element.nodeType:
149 elif x.tagName == 'item':
150 self.addItem(list, x)
151 elif x.tagName == 'menu':
152 self.addMenu(list, x)
154 self["menu"] = MenuList(list)
156 self["actions"] = ActionMap(["OkCancelActions"],
158 "ok": self.okbuttonClick,
162 a = getValbyAttr(parent, "title")
163 if a == "": #if empty use name
164 a = getValbyAttr(parent, "text")
165 self["title"] = Header(a)
167 class FixedMenu(Screen):
168 def okbuttonClick(self):
169 selection = self["menu"].getCurrent()
172 def __init__(self, session, title, list):
173 Screen.__init__(self, session)
175 self["menu"] = MenuList(list)
177 self["actions"] = ActionMap(["OkCancelActions"],
179 "ok": self.okbuttonClick,
183 self["title"] = Header(title)
186 class MainMenu(Menu):
187 #add file load functions for the xml-file
188 #remove old code (i.e. goScan / goClock...)
190 def __init__(self, *x):
191 Menu.__init__(self, *x)
192 self.skinName = "Menu"
194 def openDialog(self, dialog):
195 self.session.open(dialog)
197 def openSetup(self, dialog):
198 self.session.open(Setup, 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())