1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.config import config #global config instance
4 from Components.config import configEntry
5 from Components.config import configBoolean
6 from Components.ConfigList import ConfigList
7 from Components.Label import Label
10 from xml.dom import EMPTY_NAMESPACE
11 from skin import elementsWithTag
13 from Tools import XMLTools
17 # first we search in the current path
18 setupfile = file('data/menu.xml', 'r')
20 # if not found in the current path, we use the global datadir-path
21 setupfile = file('/usr/share/enigma2/setup.xml', 'r')
22 setupdom = xml.dom.minidom.parseString(setupfile.read())
26 def getValbyAttr(x, attr):
27 for p in range(x.attributes.length):
28 a = x.attributes.item(p)
38 def addItems(self, list, childNode):
40 if x.nodeType != xml.dom.minidom.Element.nodeType:
42 elif x.tagName == 'item':
43 ItemText = getValbyAttr(x, "text")
44 b = eval(XMLTools.mergeText(x.childNodes));
45 print "item " + ItemText + " " + b.configPath
49 item = b.controlType(b)
51 # the first b is the item itself, ignored by the configList.
52 # the second one is converted to string.
53 list.append( (ItemText, item) )
56 self["config"].handleKey(0)
58 self["config"].handleKey(1)
60 self["config"].handleKey(2)
63 print "save requested"
64 for x in self["config"]:
65 selection = self["config"].getCurrent()
68 def __init__(self, session, setup):
69 Screen.__init__(self, session)
71 print "request setup for " + setup
73 xmldata = setupdom.childNodes[0]
75 entries = xmldata.childNodes
79 for x in entries: #walk through the actual nodelist
80 if x.nodeType != xml.dom.minidom.Element.nodeType:
82 elif x.tagName == 'setup':
83 ItemText = getValbyAttr(x, "key")
86 self.addItems(list, x.childNodes);
88 #check for list.entries > 0 else self.close
90 self["config"] = ConfigList(list)
92 self["ok"] = Label("OK")
93 self["cancel"] = Label("Cancel")
95 self["actions"] = ActionMap(["SetupActions"],
100 "right": self.keyRight,