X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/ba02fb4aced5868d047a5bffbd2ed87583daee4d..54bd4123728628a6f77bad2584b70d1353a91666:/skin.py
diff --git a/skin.py b/skin.py
index 415f3412..936dcc96 100644
--- a/skin.py
+++ b/skin.py
@@ -1,5 +1,6 @@
from enigma import *
import xml.dom.minidom
+from xml.dom import EMPTY_NAMESPACE
def dump(x, i=0):
print " " * i + str(x)
@@ -10,19 +11,91 @@ def dump(x, i=0):
None
dom = xml.dom.minidom.parseString(
- " \
- \
- \
- \
- ")
-
-def applyGUIskin(screen, skin, name):
- dump(dom[screen])
- screen.data["okbutton"]["instance"].move(ePoint(10, 10))
- screen.data["okbutton"]["instance"].resize(eSize(280, 40))
-
- screen.data["theClock"]["instance"].move(ePoint(10, 60))
- screen.data["theClock"]["instance"].resize(eSize(280, 50))
-
- screen.data["title"]["instance"].move(ePoint(10, 120))
- screen.data["title"]["instance"].resize(eSize(280, 50))
+ """
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+""")
+
+
+
+def parsePosition(str):
+ x, y = str.split(',')
+ return ePoint(int(x), int(y))
+
+def parseSize(str):
+ x, y = str.split(',')
+ return eSize(int(x), int(y))
+
+def applyAttributes(guiObject, node):
+ # walk all attributes
+ for p in range(node.attributes.length):
+ a = node.attributes.item(p)
+
+ # convert to string (was: unicode)
+ attrib = str(a.name)
+ # TODO: proper UTF8 translation?! (for value)
+ # TODO: localization? as in e1?
+ value = str(a.value)
+
+ # and set attributes
+ if attrib == 'position':
+ guiObject.move(parsePosition(value))
+ elif attrib == 'size':
+ guiObject.resize(parseSize(value))
+ elif attrib == 'title':
+ guiObject.setTitle(value)
+ elif attrib != 'name':
+ print "unsupported attribute " + attrib + "=" + value
+
+def applyGUIskin(screen, parent, skin, name):
+
+ myscreen = None
+
+ # first, find the corresponding screen element
+ skin = dom.getElementsByTagName("skin")[0]
+ screens = skin.getElementsByTagName("screen")
+ del skin
+ for x in screens:
+ if x.getAttribute('name') == name:
+ myscreen = x
+
+ assert myscreen != None, "no skin for screen '" + name + "' found!"
+
+ applyAttributes(parent, myscreen)
+
+ # now walk all widgets
+ for widget in myscreen.getElementsByTagName("widget"):
+ wname = widget.getAttribute('name')
+ if wname == None:
+ print "widget has no name!"
+ continue
+
+ # get corresponding gui object
+ try:
+ guiObject = screen.data[wname]["instance"]
+ except:
+ raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
+
+ applyAttributes(guiObject, widget)