1 from Screen import Screen
2 from Components.ActionMap import NumberActionMap
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 def __init__(self, session, setup):
82 Screen.__init__(self, session)
84 print "request setup for " + setup
86 xmldata = setupdom.childNodes[0]
88 entries = xmldata.childNodes
92 for x in entries: #walk through the actual nodelist
93 if x.nodeType != xml.dom.minidom.Element.nodeType:
95 elif x.tagName == 'setup':
96 ItemText = getValbyAttr(x, "key")
99 self.addItems(list, x.childNodes);
100 myTitle = getValbyAttr(x, "title")
102 #check for list.entries > 0 else self.close
104 self["config"] = ConfigList(list)
106 self["title"] = Label(myTitle);
108 self["ok"] = Label("OK")
109 self["cancel"] = Label("Cancel")
111 self["actions"] = NumberActionMap(["SetupActions"],
113 "cancel": self.keyCancel,
115 "left": self.keyLeft,
116 "right": self.keyRight,
117 "save": self.keySave,
118 "1": self.keyNumberGlobal,
119 "2": self.keyNumberGlobal,
120 "3": self.keyNumberGlobal,
121 "4": self.keyNumberGlobal,
122 "5": self.keyNumberGlobal,
123 "6": self.keyNumberGlobal,
124 "7": self.keyNumberGlobal,
125 "8": self.keyNumberGlobal,
126 "9": self.keyNumberGlobal,
127 "0": self.keyNumberGlobal