X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/44433f650cd3e5f9f66253b74d194fcb01578595..2e74b767faf7548c6f6aae3a12506d46d3edd6c0:/skin.py?ds=sidebyside diff --git a/skin.py b/skin.py index 73d4b02d..72cef1a9 100644 --- a/skin.py +++ b/skin.py @@ -2,6 +2,10 @@ from enigma import * import xml.dom.minidom from xml.dom import EMPTY_NAMESPACE +from Tools.XMLTools import elementsWithTag + +colorNames = dict() + def dump(x, i=0): print " " * i + str(x) try: @@ -12,8 +16,26 @@ def dump(x, i=0): dom = xml.dom.minidom.parseString( """ + + + + + + + + + + + - + + + + + + + + @@ -25,53 +47,72 @@ dom = xml.dom.minidom.parseString( - - + + - + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - - - + + + + + + + - + - + + + + + + + + """) -# filters all elements of childNode with the specified function -# example: nodes = elementsWithTag(childNodes, lambda x: x == "bla") -def elementsWithTag(el, tag): - - # fiiixme! (works but isn't nice) - if tag.__class__ == "".__class__: - str = tag - tag = lambda x: x == str - - for x in el: - if x.nodeType != xml.dom.minidom.Element.nodeType: - continue - if tag(x.tagName): - yield x - def parsePosition(str): x, y = str.split(',') return ePoint(int(x), int(y)) @@ -86,7 +127,10 @@ def parseFont(str): def parseColor(str): if str[0] != '#': - raise "color must be #aarrggbb" + try: + return colorNames[str] + except: + raise ("color '%s' must be #aarrggbb or valid named color" % (str)) return gRGB(int(str[1:], 0x10)) def applyAttributes(guiObject, node, desktop): @@ -168,6 +212,16 @@ def loadSkin(): skin = dom.childNodes[0] assert skin.tagName == "skin", "root element in skin must be 'skin'!" + for c in elementsWithTag(skin.childNodes, "colors"): + for color in elementsWithTag(c.childNodes, "color"): + name = str(color.getAttribute("name")) + color = str(color.getAttribute("value")) + + if not len(color): + raise ("need color and name, got %s %s" % (name, color)) + + colorNames[name] = parseColor(color) + for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"): style = eWindowStyleSkinned() @@ -183,10 +237,10 @@ def loadSkin(): type = str(color.getAttribute("name")) color = parseColor(color.getAttribute("color")) - if type == "defaultBackground": - style.setDefaultBackgroundColor(color) - else: - raise "unknown color %s" % (type) + try: + style.setColor(eWindowStyleSkinned.__dict__["col" + type], color) + except: + raise ("Unknown color %s" % (type)) x = eWindowStyleManagerPtr() eWindowStyleManager.getInstance(x)