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 from enigma import quitMainloop
11 import xml.dom.minidom
12 from xml.dom import EMPTY_NAMESPACE
13 from skin import elementsWithTag
15 from Screens.Satconfig import NimSelection
17 from Tools import XMLTools
21 screen["clock"] = Clock()
24 # <item text="TV-Mode">self.setModeTV()</item>
25 # <item text="Radio-Mode">self.setModeRadio()</item>
26 # <item text="File-Mode">self.setModeFile()</item>
27 # <item text="Scart">self.openDialog(ScartLoopThrough)</item>
28 # <item text="Sleep Timer"></item>
33 # first we search in the current path
34 menufile = file('data/menu.xml', 'r')
36 # if not found in the current path, we use the global datadir-path
37 menufile = file('/usr/share/enigma2/menu.xml', 'r')
38 mdom = xml.dom.minidom.parseString(menufile.read())
43 def getValbyAttr(x, attr):
44 for p in range(x.attributes.length):
45 a = x.attributes.item(p)
54 def __init__(self, fnc, *args):
61 def okbuttonClick(self):
63 selection = self["menu"].getCurrent()
66 def evalText(self, text):
69 def nothing(self): #dummy
72 def openDialog(self, dialog): # in every layer needed
73 self.session.open(dialog)
75 def openSetup(self, dialog):
76 self.session.open(Setup, dialog)
78 def addMenu(self, destList, node):
79 MenuTitle = getValbyAttr(node, "text")
80 if MenuTitle != "": #check for title
81 a = boundFunction(self.session.open, Menu, node, node.childNodes)
82 #TODO add check if !empty(node.childNodes)
83 destList.append((MenuTitle, a))
85 def addItem(self, destList, node):
86 ItemText = getValbyAttr(node, "text")
87 if ItemText != "": #check for name
88 b = XMLTools.mergeText(node.childNodes)
89 if b != "": #check for function
90 destList.append((ItemText,boundFunction(self.evalText,b)))
92 destList.append((ItemText,self.nothing)) #use dummy as function
94 def __init__(self, session, parent, childNode):
95 Screen.__init__(self, session)
99 for x in childNode: #walk through the actual nodelist
100 if x.nodeType != xml.dom.minidom.Element.nodeType:
102 elif x.tagName == 'item':
103 self.addItem(list, x)
104 elif x.tagName == 'menu':
105 self.addMenu(list, x)
107 self["menu"] = MenuList(list)
109 self["actions"] = ActionMap(["OkCancelActions"],
111 "ok": self.okbuttonClick,
115 a = getValbyAttr(parent, "title")
116 if a == "": #if empty use name
117 a = getValbyAttr(parent, "text")
118 self["title"] = Header(a)
120 class MainMenu(Menu):
121 #add file load functions for the xml-file
123 def __init__(self, *x):
124 Menu.__init__(self, *x)
125 self.skinName = "Menu"
127 def openDialog(self, dialog):
128 self.session.open(dialog)
130 def openSetup(self, dialog):
131 self.session.open(Setup, dialog)
134 print "set Mode to TV"
137 def setModeRadio(self):
138 print "set Mode to Radio"
141 def setModeFile(self):
142 print "set Mode to File"