+ scale = 100
+ is_replacement = get_attr("replacement") and True or False
+ resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
+ if not fileExists(resolved_font): #when font is not available look at current skin path
+ skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
+ if fileExists(skin_path):
+ resolved_font = skin_path
+ addFont(resolved_font, name, scale, is_replacement)
+ #print "Font: ", resolved_font, name, scale, is_replacement
+
+ for c in skin.findall("subtitles"):
+ from enigma import eWidget, eSubtitleWidget
+ scale = ((1,1),(1,1))
+ for substyle in c.findall("sub"):
+ get_attr = substyle.attrib.get
+ font = parseFont(get_attr("font"), scale)
+ col = get_attr("foregroundColor")
+ if col:
+ foregroundColor = parseColor(col)
+ haveColor = 1
+ else:
+ foregroundColor = gRGB(0xFFFFFF)
+ haveColor = 0
+ col = get_attr("shadowColor")
+ if col:
+ shadowColor = parseColor(col)
+ else:
+ shadowColor = gRGB(0)
+ shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
+ face = eSubtitleWidget.__dict__[get_attr("name")]
+ eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset)
+
+ for windowstyle in skin.findall("windowstyle"):
+ style = eWindowStyleSkinned()
+ id = windowstyle.attrib.get("id")
+ if id:
+ id = int(id)
+ else:
+ id = 0
+ #print "windowstyle:", id
+
+ # defaults
+ font = gFont("Regular", 20)
+ offset = eSize(20, 5)
+
+ for title in windowstyle.findall("title"):
+ get_attr = title.attrib.get
+ offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
+ font = parseFont(get_attr("font"), ((1,1),(1,1)))
+
+ style.setTitleFont(font);
+ style.setTitleOffset(offset)
+ #print " ", font, offset
+
+ for borderset in windowstyle.findall("borderset"):
+ bsName = str(borderset.attrib.get("name"))
+ for pixmap in borderset.findall("pixmap"):
+ get_attr = pixmap.attrib.get
+ bpName = get_attr("pos")
+ filename = get_attr("filename")
+ if filename and bpName:
+ png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
+ style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
+ #print " borderset:", bpName, filename
+
+ for color in windowstyle.findall("color"):
+ get_attr = color.attrib.get
+ colorType = get_attr("name")
+ color = parseColor(get_attr("color"))
+ try:
+ style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
+ except:
+ raise SkinError("Unknown color %s" % (colorType))
+ #pass
+
+ #print " color:", type, color
+
+ x = eWindowStyleManager.getInstance()
+ x.setStyle(id, style)
+
+def loadSkinData(desktop):
+ skins = dom_skins[:]
+ skins.reverse()
+ for (path, dom_skin) in skins:
+ loadSingleSkinData(desktop, dom_skin, path)
+
+def lookupScreen(name):
+ 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
+ return None, None
+
+class additionalWidget:
+ pass
+
+def readSkin(screen, skin, names, desktop):
+ if not isinstance(names, list):
+ names = [names]
+
+ name = "<embedded-in-'%s'>" % screen.__class__.__name__
+
+ # try all skins, first existing one have priority
+ for n in names:
+ myscreen, path = lookupScreen(n)
+ if myscreen is not None:
+ # use this name for debug output
+ name = n
+ break
+
+ # otherwise try embedded skin
+ if myscreen is None:
+ myscreen = getattr(screen, "parsedSkin", None)
+
+ # 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)
+
+ #assert myscreen is not None, "no skin for screen '" + repr(names) + "' found!"
+ if myscreen is None:
+ print "No skin to read..."
+ emptySkin = "<screen></screen>"
+ myscreen = screen.parsedSkin = xml.etree.cElementTree.fromstring(emptySkin)
+
+ screen.skinAttributes = [ ]
+
+ skin_path_prefix = getattr(screen, "skin_path", path)
+
+ collectAttributes(screen.skinAttributes, myscreen, skin_path_prefix, ignore=["name"])
+
+ screen.additionalWidgets = [ ]
+ screen.renderer = [ ]
+
+ visited_components = set()
+