X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=skin.py;h=a269b4f166e4d22e6eeaf3525f62fb94beb26d17;hp=5fcaa11094c05d4295cc25092748ee212cc76dfc;hb=f2b1a7e86c4143b6112a119bd00a2adcc0844b71;hpb=c68943c97eeb0107f724ec96aae311e319c750a9 diff --git a/skin.py b/skin.py old mode 100644 new mode 100755 index 5fcaa11..a269b4f --- a/skin.py +++ b/skin.py @@ -28,7 +28,7 @@ class SkinError(Exception): self.msg = message def __str__(self): - return "{%s}: %s" % (config.skin.primary_skin, self.msg) + return "{%s}: %s" % (config.skin.primary_skin.value, self.msg) dom_skins = [ ] @@ -119,7 +119,7 @@ def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]): value = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix) if attrib not in ignore: - skinAttributes.append((attrib, value)) + skinAttributes.append((attrib, value.encode("utf-8"))) def loadPixmap(path, desktop): cached = False @@ -148,6 +148,8 @@ 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 == 'itemHeight': + guiObject.setItemHeight(int(value)) elif attrib in ("pixmap", "backgroundPixmap", "selectionPixmap"): ptr = loadPixmap(value, desktop) # this should already have been filename-resolved. if attrib == "pixmap": @@ -239,6 +241,8 @@ def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1) guiObject.setShadowOffset(parsePosition(value, scale)) elif attrib == 'noWrap': guiObject.setNoWrap(1) + elif attrib == 'id': + pass else: raise SkinError("unsupported attribute " + attrib + "=" + value) except int: @@ -393,12 +397,14 @@ def loadSkinData(desktop): for (path, dom_skin) in skins: loadSingleSkinData(desktop, dom_skin, path) -def lookupScreen(name): +def lookupScreen(name, style_id = None): for (path, skin) in dom_skins: # first, find the corresponding screen element for x in skin.findall("screen"): if x.attrib.get('name', '') == name: - return x, path + screen_style_id = int(x.attrib.get('id', None) or '0') + if style_id is None or screen_style_id == style_id: + return x, path return None, None class additionalWidget: @@ -410,9 +416,11 @@ def readSkin(screen, skin, names, desktop): name = "" % screen.__class__.__name__ + style_id = desktop.getStyleID(); + # try all skins, first existing one have priority for n in names: - myscreen, path = lookupScreen(n) + myscreen, path = lookupScreen(n, style_id) if myscreen is not None: # use this name for debug output name = n @@ -425,7 +433,13 @@ def readSkin(screen, skin, names, desktop): # try uncompiled embedded skin if myscreen is None and getattr(screen, "skin", None): print "Looking for embedded skin" - myscreen = screen.parsedSkin = xml.etree.cElementTree.fromstring(screen.skin) + skin_tuple = screen.skin + if not isinstance(skin_tuple, tuple): + skin_tuple = (skin_tuple,) + for sskin in skin_tuple: + parsedSkin = xml.etree.cElementTree.fromstring(sskin) + if style_id != 2 or parsedSkin.attrib.get('id', 0) == 2: + myscreen = screen.parsedSkin = parsedSkin #assert myscreen is not None, "no skin for screen '" + repr(names) + "' found!" if myscreen is None: