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.... dynamically importing all screens
10 from __init__ import __all__
13 if (i is not "Menu" ):
14 exec "from " + i + " import *"
16 from enigma import quitMainloop
18 import xml.dom.minidom
19 from xml.dom import EMPTY_NAMESPACE
20 from skin import elementsWithTag
22 from Tools import XMLTools
26 screen["clock"] = Clock()
29 # <item text="TV-Mode">self.setModeTV()</item>
30 # <item text="Radio-Mode">self.setModeRadio()</item>
31 # <item text="File-Mode">self.setModeFile()</item>
32 # <item text="Scart">self.openDialog(ScartLoopThrough)</item>
33 # <item text="Sleep Timer"></item>
38 # first we search in the current path
39 menufile = file('data/menu.xml', 'r')
41 # if not found in the current path, we use the global datadir-path
42 menufile = file('/usr/share/enigma2/menu.xml', 'r')
43 mdom = xml.dom.minidom.parseString(menufile.read())
48 def getValbyAttr(x, attr):
49 for p in range(x.attributes.length):
50 a = x.attributes.item(p)
59 def __init__(self, fnc, *args):
66 def okbuttonClick(self):
68 selection = self["menu"].getCurrent()
71 def evalText(self, text):
74 def nothing(self): #dummy
77 def openDialog(self, dialog): # in every layer needed
78 self.session.open(dialog)
80 def openSetup(self, dialog):
81 self.session.open(Setup, dialog)
83 def addMenu(self, destList, node):
84 MenuTitle = getValbyAttr(node, "text")
85 if MenuTitle != "": #check for title
86 a = boundFunction(self.session.open, Menu, node, node.childNodes)
87 #TODO add check if !empty(node.childNodes)
88 destList.append((MenuTitle, a))
90 def addItem(self, destList, node):
91 ItemText = getValbyAttr(node, "text")
92 if ItemText != "": #check for name
93 b = XMLTools.mergeText(node.childNodes)
94 if b != "": #check for function
95 destList.append((ItemText,boundFunction(self.evalText,b)))
97 destList.append((ItemText,self.nothing)) #use dummy as function
99 def __init__(self, session, parent, childNode):
100 Screen.__init__(self, session)
104 for x in childNode: #walk through the actual nodelist
105 if x.nodeType != xml.dom.minidom.Element.nodeType:
107 elif x.tagName == 'item':
108 self.addItem(list, x)
109 elif x.tagName == 'menu':
110 self.addMenu(list, x)
112 self["menu"] = MenuList(list)
114 self["actions"] = ActionMap(["OkCancelActions"],
116 "ok": self.okbuttonClick,
120 a = getValbyAttr(parent, "title")
121 if a == "": #if empty use name
122 a = getValbyAttr(parent, "text")
123 self["title"] = Header(a)
125 class FixedMenu(Screen):
126 def okbuttonClick(self):
127 selection = self["menu"].getCurrent()
130 def __init__(self, session, title, list):
131 Screen.__init__(self, session)
133 self["menu"] = MenuList(list)
135 self["actions"] = ActionMap(["OkCancelActions"],
137 "ok": self.okbuttonClick,
141 self["title"] = Header(title)
144 class MainMenu(Menu):
145 #add file load functions for the xml-file
147 def __init__(self, *x):
148 Menu.__init__(self, *x)
149 self.skinName = "Menu"
151 def openDialog(self, dialog):
152 self.session.open(dialog)
154 def openSetup(self, dialog):
155 self.session.open(Setup, dialog)
158 print "set Mode to TV"
161 def setModeRadio(self):
162 print "set Mode to Radio"
165 def setModeFile(self):
166 print "set Mode to File"