2 from Components.MenuList import MenuList
3 from Components.ActionMap import ActionMap
4 from Components.Header import Header
6 # hack ... must be made dynamic
7 from Screens.Setup import Setup
8 from ServiceScan import ServiceScan
9 from ScartLoopThrough import ScartLoopThrough
10 from HarddiskSetup import HarddiskSelection
11 from Components.Button import Button
12 from Components.Label import Label
13 from Components.ProgressBar import ProgressBar
14 from ConfigMenu import *
18 from TimerEdit import *
20 from enigma import quitMainloop
22 import xml.dom.minidom
23 from xml.dom import EMPTY_NAMESPACE
24 from skin import elementsWithTag
26 from Tools import XMLTools
30 screen["clock"] = Clock()
33 # <item text="TV-Mode">self.setModeTV()</item>
34 # <item text="Radio-Mode">self.setModeRadio()</item>
35 # <item text="File-Mode">self.setModeFile()</item>
36 # <item text="Scart">self.openDialog(ScartLoopThrough)</item>
37 # <item text="Sleep Timer"></item>
42 # first we search in the current path
43 menufile = file('data/menu.xml', 'r')
45 # if not found in the current path, we use the global datadir-path
46 menufile = file('/usr/share/enigma2/menu.xml', 'r')
47 mdom = xml.dom.minidom.parseString(menufile.read())
52 def getValbyAttr(x, attr):
53 for p in range(x.attributes.length):
54 a = x.attributes.item(p)
63 def __init__(self, fnc, *args):
69 class configOSD(Screen):
70 #this needs focus handling - so not useable
72 def okbuttonClick(self):
75 def __init__(self, session):
76 Screen.__init__(self, session)
78 self["actions"] = ActionMap(["OkCancelActions"],
80 "ok": self.okbuttonClick,
84 self["okbutton"] = Button("Save")
86 self["txt_alpha"] = Label("Alpha:")
87 self["sld_alpha"] = ProgressBar()
88 self["sld_alpha"].setValue(50)
90 self["txt_brightness"] = Label("Brightness:")
91 self["sld_brightness"] = ProgressBar()
92 self["sld_brightness"].setValue(50)
94 self["txt_gamma"] = Label("Contrast:")
95 self["sld_gamma"] = ProgressBar()
96 self["sld_gamma"].setValue(50)
99 def okbuttonClick(self):
100 print "okbuttonClick"
101 selection = self["menu"].getCurrent()
104 def evalText(self, text):
107 def nothing(self): #dummy
110 def openDialog(self, dialog): # in every layer needed
111 self.session.open(dialog)
113 def openSetup(self, dialog):
114 self.session.open(Setup, dialog)
116 def addMenu(self, destList, node):
117 MenuTitle = getValbyAttr(node, "text")
118 if MenuTitle != "": #check for title
119 a = boundFunction(self.session.open, Menu, node, node.childNodes)
120 #TODO add check if !empty(node.childNodes)
121 destList.append((MenuTitle, a))
123 def addItem(self, destList, node):
124 ItemText = getValbyAttr(node, "text")
125 if ItemText != "": #check for name
126 b = XMLTools.mergeText(node.childNodes)
127 if b != "": #check for function
128 destList.append((ItemText,boundFunction(self.evalText,b)))
130 destList.append((ItemText,self.nothing)) #use dummy as function
132 def __init__(self, session, parent, childNode):
133 Screen.__init__(self, session)
137 for x in childNode: #walk through the actual nodelist
138 if x.nodeType != xml.dom.minidom.Element.nodeType:
140 elif x.tagName == 'item':
141 self.addItem(list, x)
142 elif x.tagName == 'menu':
143 self.addMenu(list, x)
145 self["menu"] = MenuList(list)
147 self["actions"] = ActionMap(["OkCancelActions"],
149 "ok": self.okbuttonClick,
153 a = getValbyAttr(parent, "title")
154 if a == "": #if empty use name
155 a = getValbyAttr(parent, "text")
156 self["title"] = Header(a)
158 class FixedMenu(Screen):
159 def okbuttonClick(self):
160 selection = self["menu"].getCurrent()
163 def __init__(self, session, title, list):
164 Screen.__init__(self, session)
166 self["menu"] = MenuList(list)
168 self["actions"] = ActionMap(["OkCancelActions"],
170 "ok": self.okbuttonClick,
174 self["title"] = Header(title)
177 class MainMenu(Menu):
178 #add file load functions for the xml-file
179 #remove old code (i.e. goScan / goClock...)
181 def __init__(self, *x):
182 Menu.__init__(self, *x)
183 self.skinName = "Menu"
185 def openDialog(self, dialog):
186 self.session.open(dialog)
188 def openSetup(self, dialog):
189 self.session.open(Setup, dialog)
192 self.session.open(configTest)
195 print "set Mode to TV"
198 def setModeRadio(self):
199 print "set Mode to Radio"
202 def setModeFile(self):
203 print "set Mode to File"
207 self.session.open(ServiceScan)
210 self.session.open(clockDisplay, Clock())