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 configBoolean
5 from Components.ConfigList import ConfigList
6 from Components.Label import Label
9 from xml.dom import EMPTY_NAMESPACE
10 from skin import elementsWithTag
12 from Tools import XMLTools
16 # first we search in the current path
17 setupfile = file('data/setup.xml', 'r')
19 # if not found in the current path, we use the global datadir-path
20 setupfile = file('/usr/share/enigma2/setup.xml', 'r')
21 setupdom = xml.dom.minidom.parseString(setupfile.read())
24 def getValbyAttr(x, attr):
25 for p in range(x.attributes.length):
26 a = x.attributes.item(p)
36 def addItems(self, list, childNode):
38 if x.nodeType != xml.dom.minidom.Element.nodeType:
40 elif x.tagName == 'item':
41 ItemText = getValbyAttr(x, "text")
42 b = eval(XMLTools.mergeText(x.childNodes));
43 print "item " + ItemText + " " + b.configPath
47 item = b.controlType(b)
49 # the first b is the item itself, ignored by the configList.
50 # the second one is converted to string.
51 list.append( (ItemText, item) )
54 self["config"].handleKey(0)
56 self["config"].handleKey(1)
58 self["config"].handleKey(2)
61 print "save requested"
62 for x in self["config"].list:
67 print "cancel requested"
68 for x in self["config"].list:
72 def __init__(self, session, setup):
73 Screen.__init__(self, session)
75 print "request setup for " + setup
77 xmldata = setupdom.childNodes[0]
79 entries = xmldata.childNodes
83 for x in entries: #walk through the actual nodelist
84 if x.nodeType != xml.dom.minidom.Element.nodeType:
86 elif x.tagName == 'setup':
87 ItemText = getValbyAttr(x, "key")
90 self.addItems(list, x.childNodes);
92 #check for list.entries > 0 else self.close
94 self["config"] = ConfigList(list)
96 self["ok"] = Label("OK")
97 self["cancel"] = Label("Cancel")
99 self["actions"] = ActionMap(["SetupActions"],
101 "cancel": self.keyCancel,
103 "left": self.keyLeft,
104 "right": self.keyRight,