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/setup.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())
25 def getValbyAttr(x, attr):
26 for p in range(x.attributes.length):
27 a = x.attributes.item(p)
37 def addItems(self, list, childNode):
39 if x.nodeType != xml.dom.minidom.Element.nodeType:
41 elif x.tagName == 'item':
42 ItemText = getValbyAttr(x, "text")
43 b = eval(XMLTools.mergeText(x.childNodes));
44 print "item " + ItemText + " " + b.configPath
48 item = b.controlType(b)
50 # the first b is the item itself, ignored by the configList.
51 # the second one is converted to string.
52 list.append( (ItemText, item) )
55 self["config"].handleKey(0)
57 self["config"].handleKey(1)
59 self["config"].handleKey(2)
62 print "save requested"
63 for x in self["config"].list:
68 print "cancel requested"
69 for x in self["config"].list:
73 def __init__(self, session, setup):
74 Screen.__init__(self, session)
76 print "request setup for " + setup
78 xmldata = setupdom.childNodes[0]
80 entries = xmldata.childNodes
84 for x in entries: #walk through the actual nodelist
85 if x.nodeType != xml.dom.minidom.Element.nodeType:
87 elif x.tagName == 'setup':
88 ItemText = getValbyAttr(x, "key")
91 self.addItems(list, x.childNodes);
93 #check for list.entries > 0 else self.close
95 self["config"] = ConfigList(list)
97 self["ok"] = Label("OK")
98 self["cancel"] = Label("Cancel")
100 self["actions"] = ActionMap(["SetupActions"],
102 "cancel": self.keyCancel,
104 "left": self.keyLeft,
105 "right": self.keyRight,