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
16 from Screens.Setup import *
18 from Tools import XMLTools
22 screen["clock"] = Clock()
25 # <item text="TV-Mode">self.setModeTV()</item>
26 # <item text="Radio-Mode">self.setModeRadio()</item>
27 # <item text="File-Mode">self.setModeFile()</item>
28 # <item text="Scart">self.openDialog(ScartLoopThrough)</item>
29 # <item text="Sleep Timer"></item>
34 # first we search in the current path
35 menufile = file('data/menu.xml', 'r')
37 # if not found in the current path, we use the global datadir-path
38 menufile = file('/usr/share/enigma2/menu.xml', 'r')
39 mdom = xml.dom.minidom.parseString(menufile.read())
44 def getValbyAttr(x, attr):
45 for p in range(x.attributes.length):
46 a = x.attributes.item(p)
55 def __init__(self, fnc, *args):
62 def okbuttonClick(self):
64 selection = self["menu"].getCurrent()
67 def evalText(self, text):
70 def nothing(self): #dummy
73 def openDialog(self, dialog): # in every layer needed
74 self.session.open(dialog)
76 def openSetup(self, dialog):
77 self.session.open(Setup, dialog)
79 def addMenu(self, destList, node):
80 MenuTitle = getValbyAttr(node, "text")
81 if MenuTitle != "": #check for title
82 a = boundFunction(self.session.open, Menu, node, node.childNodes)
83 #TODO add check if !empty(node.childNodes)
84 destList.append((MenuTitle, a))
86 def addItem(self, destList, node):
87 ItemText = getValbyAttr(node, "text")
88 if ItemText != "": #check for name
89 b = XMLTools.mergeText(node.childNodes)
90 if b != "": #check for function
91 destList.append((ItemText,boundFunction(self.evalText,b)))
93 destList.append((ItemText,self.nothing)) #use dummy as function
95 def __init__(self, session, parent, childNode):
96 Screen.__init__(self, session)
100 for x in childNode: #walk through the actual nodelist
101 if x.nodeType != xml.dom.minidom.Element.nodeType:
103 elif x.tagName == 'item':
104 self.addItem(list, x)
105 elif x.tagName == 'menu':
106 self.addMenu(list, x)
108 self["menu"] = MenuList(list)
110 self["actions"] = ActionMap(["OkCancelActions"],
112 "ok": self.okbuttonClick,
116 a = getValbyAttr(parent, "title")
117 if a == "": #if empty use name
118 a = getValbyAttr(parent, "text")
119 self["title"] = Header(a)
121 class MainMenu(Menu):
122 #add file load functions for the xml-file
124 def __init__(self, *x):
125 Menu.__init__(self, *x)
126 self.skinName = "Menu"
128 def openDialog(self, dialog):
129 self.session.open(dialog)
131 def openSetup(self, dialog):
132 self.session.open(Setup, dialog)
135 print "set Mode to TV"
138 def setModeRadio(self):
139 print "set Mode to Radio"
142 def setModeFile(self):
143 print "set Mode to File"