add xml stuff
[enigma2.git] / lib / python / Screens / Setup.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3
4 import xml.dom.minidom
5 from xml.dom import EMPTY_NAMESPACE
6 from skin import elementsWithTag
7
8 from Tools import XMLTools
9
10 setupdom = xml.dom.minidom.parseString(
11         """
12         <setup key="rc" title="RC Menu">
13                 <item text="Repeat Rate">config.inputDevices.repeat</item>
14                 <item text="Delay Rate">config.inputDevices.delay</item>
15         </setup>
16         """)
17
18 def getValbyAttr(x, attr):
19         for p in range(x.attributes.length):
20                 a = x.attributes.item(p)
21                 attrib = str(a.name)
22                 value = str(a.value)
23                 if attrib == attr:
24                         return value
25         
26         return ""
27
28 class Setup(Screen):
29
30         def createDialog(self, childNode):
31                 print "createDialog"
32                 for x in childNode:
33                         if x.nodeType != xml.dom.minidom.Element.nodeType:
34                                 continue
35                         elif x.tagName == 'item':
36                                 ItemText = getValbyAttr(x, "text")
37                                 b = XMLTools.mergeText(x.childNodes);
38                                 print "item " + ItemText + " " + b
39                                 #add to configlist
40                                 
41         def __init__(self, session, setup):
42                 Screen.__init__(self, session)
43
44                 print "request setup for " + setup
45                 
46                 entries = setupdom.childNodes
47                 
48                 for x in entries:             #walk through the actual nodelist
49                         if x.nodeType != xml.dom.minidom.Element.nodeType:
50                                 continue
51                         elif x.tagName == 'setup':
52                                 ItemText = getValbyAttr(x, "key")
53                                 if ItemText != setup:
54                                         continue
55                                 self.createDialog(x.childNodes);
56                                 
57
58                 self["actions"] = ActionMap(["OkCancelActions"], 
59                         {
60                                 #"ok": self.inc,
61                                 "cancel": self.close
62                         })