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 configSelection
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 if (self["config"].getCurrent()[1].parent.enabled == True):
55 self["config"].handleKey(config.key["choseElement"])
57 if (self["config"].getCurrent()[1].parent.enabled == True):
58 self["config"].handleKey(config.key["prevElement"])
60 if (self["config"].getCurrent()[1].parent.enabled == True):
61 self["config"].handleKey(config.key["nextElement"])
64 print "save requested"
65 for x in self["config"].list:
70 print "cancel requested"
71 for x in self["config"].list:
75 def keyNumberGlobal(self, number):
76 print "You pressed number " + str(number)
77 if (self["config"].getCurrent()[1].parent.enabled == True):
78 self["config"].handleKey(config.key[str(number)])
81 # TODO ugly as hell. any better ideas?
83 self.keyNumberGlobal(1)
85 self.keyNumberGlobal(2)
87 self.keyNumberGlobal(3)
89 self.keyNumberGlobal(4)
91 self.keyNumberGlobal(5)
93 self.keyNumberGlobal(6)
95 self.keyNumberGlobal(7)
97 self.keyNumberGlobal(8)
99 self.keyNumberGlobal(9)
100 def keyNumber0(self):
101 self.keyNumberGlobal(0)
105 def __init__(self, session, setup):
106 Screen.__init__(self, session)
108 print "request setup for " + setup
110 xmldata = setupdom.childNodes[0]
112 entries = xmldata.childNodes
116 for x in entries: #walk through the actual nodelist
117 if x.nodeType != xml.dom.minidom.Element.nodeType:
119 elif x.tagName == 'setup':
120 ItemText = getValbyAttr(x, "key")
121 if ItemText != setup:
123 self.addItems(list, x.childNodes);
124 myTitle = getValbyAttr(x, "title")
126 #check for list.entries > 0 else self.close
128 self["config"] = ConfigList(list)
130 self["title"] = Label(myTitle);
132 self["ok"] = Label("OK")
133 self["cancel"] = Label("Cancel")
135 self["actions"] = ActionMap(["SetupActions"],
137 "cancel": self.keyCancel,
139 "left": self.keyLeft,
140 "right": self.keyRight,
141 "save": self.keySave,
142 "1": self.keyNumber1,
143 "2": self.keyNumber2,
144 "3": self.keyNumber3,
145 "4": self.keyNumber4,
146 "5": self.keyNumber5,
147 "6": self.keyNumber6,
148 "7": self.keyNumber7,
149 "8": self.keyNumber8,
150 "9": self.keyNumber9,