X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4621e2ba14ebc9c955e3bf669a5c8799f65f46e1..c5bb99fa2019da12a8fbaa1766189af520b9e79a:/skin.py?ds=sidebyside diff --git a/skin.py b/skin.py index dd107905..a37716f1 100644 --- a/skin.py +++ b/skin.py @@ -10,12 +10,10 @@ from enigma import eSize, ePoint, gFont, eWindow, eLabel, ePixmap, eWindowStyleM from Components.config import ConfigSubsection, ConfigText, config from Components.Converter.Converter import Converter from Components.Sources.Source import Source, ObsoleteSource -from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS, SCOPE_CURRENT_SKIN, fileExists +from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS, SCOPE_CURRENT_SKIN, SCOPE_CONFIG, fileExists from Tools.Import import my_import from Tools.LoadPixmap import LoadPixmap -from Tools.XMLTools import mergeText - colorNames = dict() def dump(x, i=0): @@ -28,16 +26,16 @@ def dump(x, i=0): class SkinError(Exception): def __init__(self, message): - self.message = message + self.msg = message def __str__(self): - return self.message + return "{%s}: %s" % (config.skin.primary_skin, self.msg) dom_skins = [ ] -def loadSkin(name): +def loadSkin(name, scope = SCOPE_SKIN): # read the skin - filename = resolveFilename(SCOPE_SKIN, name) + filename = resolveFilename(scope, name) mpath = path.dirname(filename) + "/" dom_skins.append((mpath, xml.etree.cElementTree.parse(filename).getroot())) @@ -56,6 +54,11 @@ config.skin = ConfigSubsection() config.skin.primary_skin = ConfigText(default = "skin.xml") profile("LoadSkin") +try: + loadSkin('skin_user.xml', SCOPE_CONFIG) +except (SkinError, IOError, AssertionError), err: + print "not loading user skin: ", err + try: loadSkin(config.skin.primary_skin.value) except (SkinError, IOError, AssertionError), err: @@ -95,7 +98,7 @@ def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]): attrib = a[0] value = a[1] - if attrib in ["pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"]: + if attrib in ("pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"): value = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix) if attrib not in ignore: @@ -128,7 +131,7 @@ def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1) guiObject.setFont(parseFont(value, scale)) elif attrib == 'zPosition': guiObject.setZPosition(int(value)) - elif attrib in ["pixmap", "backgroundPixmap", "selectionPixmap"]: + elif attrib in ("pixmap", "backgroundPixmap", "selectionPixmap"): ptr = loadPixmap(value, desktop) # this should already have been filename-resolved. if attrib == "pixmap": guiObject.setPixmap(ptr) @@ -147,11 +150,11 @@ def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1) try: guiObject.setOrientation(* { "orVertical": (guiObject.orVertical, False), - "orTopToBottom": (guiObject.olVertical, False), + "orTopToBottom": (guiObject.orVertical, False), "orBottomToTop": (guiObject.orVertical, True), "orHorizontal": (guiObject.orHorizontal, False), "orLeftToRight": (guiObject.orHorizontal, False), - "orRightToRight": (guiObject.orHorizontal, True), + "orRightToLeft": (guiObject.orHorizontal, True), }[value]) except KeyError: print "oprientation must be either orVertical or orHorizontal!" @@ -274,7 +277,7 @@ def loadSingleSkinData(desktop, skin, path_prefix): colorNames[name] = parseColor(color) #print "Color:", name, color else: - raise ("need color and name, got %s %s" % (name, color)) + raise SkinError("need color and name, got %s %s" % (name, color)) for c in skin.findall("fonts"): for font in c.findall("font"): @@ -335,7 +338,7 @@ def loadSingleSkinData(desktop, skin, path_prefix): try: style.setColor(eWindowStyleSkinned.__dict__["col" + type], color) except: - raise ("Unknown color %s" % (type)) + raise SkinError("Unknown color %s" % (type)) #pass #print " color:", type, color @@ -474,13 +477,12 @@ def readSkin(screen, skin, names, desktop): ctype = converter.get('type') assert ctype, "'convert'-tag needs a 'type'-attribute" #print "Converter:", ctype - #parms = mergeText(converter.childNodes).strip() try: parms = converter.text.strip() except: parms = "" - #print "Params:", ctype - converter_class = my_import('.'.join(["Components", "Converter", ctype])).__dict__.get(ctype) + #print "Params:", parms + converter_class = my_import('.'.join(("Components", "Converter", ctype))).__dict__.get(ctype) c = None @@ -497,7 +499,7 @@ def readSkin(screen, skin, names, desktop): source = c - renderer_class = my_import('.'.join(["Components", "Renderer", wrender])).__dict__.get(wrender) + renderer_class = my_import('.'.join(("Components", "Renderer", wrender))).__dict__.get(wrender) renderer = renderer_class() # instantiate renderer