X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/44433f650cd3e5f9f66253b74d194fcb01578595..da40b2aac3c7b8efdc9061aadf9038306f44789c:/skin.py diff --git a/skin.py b/skin.py index 73d4b02d..9de0a722 100644 --- a/skin.py +++ b/skin.py @@ -2,6 +2,9 @@ from enigma import * import xml.dom.minidom from xml.dom import EMPTY_NAMESPACE + +colorNames = dict() + def dump(x, i=0): print " " * i + str(x) try: @@ -12,8 +15,26 @@ def dump(x, i=0): dom = xml.dom.minidom.parseString( """ + + + + + + + + + + + - + + + + + + + + @@ -25,10 +46,30 @@ dom = xml.dom.minidom.parseString( - - + + - + + + + + + + + + + + + + + + + + + + + + @@ -36,24 +77,27 @@ dom = xml.dom.minidom.parseString( - + - - - - - - + + + + + + - - - + + + + + + + - """) @@ -86,7 +130,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 +215,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 +240,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)