+ print "illegal flag %s!" % f
+ elif attrib == "backgroundColor":
+ guiObject.setBackgroundColor(parseColor(value))
+ elif attrib == "backgroundColorSelected":
+ guiObject.setBackgroundColorSelected(parseColor(value))
+ elif attrib == "foregroundColor":
+ guiObject.setForegroundColor(parseColor(value))
+ elif attrib == "foregroundColorSelected":
+ guiObject.setForegroundColorSelected(parseColor(value))
+ elif attrib == "shadowColor":
+ guiObject.setShadowColor(parseColor(value))
+ elif attrib == "selectionDisabled":
+ guiObject.setSelectionEnable(0)
+ elif attrib == "transparent":
+ guiObject.setTransparent(int(value))
+ elif attrib == "borderColor":
+ guiObject.setBorderColor(parseColor(value))
+ elif attrib == "borderWidth":
+ guiObject.setBorderWidth(int(value))
+ elif attrib == "scrollbarMode":
+ guiObject.setScrollbarMode(
+ { "showOnDemand": guiObject.showOnDemand,
+ "showAlways": guiObject.showAlways,
+ "showNever": guiObject.showNever
+ }[value])
+ elif attrib == "enableWrapAround":
+ guiObject.setWrapAround(True)
+ elif attrib == "pointer" or attrib == "seek_pointer":
+ (name, pos) = value.split(':')
+ pos = parsePosition(pos)
+ ptr = loadPixmap(name, desktop)
+ guiObject.setPointer({"pointer": 0, "seek_pointer": 1}[attrib], ptr, pos)
+ elif attrib == 'shadowOffset':
+ guiObject.setShadowOffset(parsePosition(value))
+ elif attrib == 'noWrap':
+ guiObject.setNoWrap(1)
+ else:
+ raise SkinError("unsupported attribute " + attrib + "=" + value)
+ except int:
+# AttributeError:
+ print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
+
+def applyAllAttributes(guiObject, desktop, attributes):
+ for (attrib, value) in attributes:
+ applySingleAttribute(guiObject, desktop, attrib, value)
+
+def loadSingleSkinData(desktop, dom_skin, path_prefix):
+ """loads skin data like colors, windowstyle etc."""
+ skin = dom_skin.getroot()
+ assert skin.tag == "skin", "root element in skin must be 'skin'!"
+
+ #print "***SKIN: ", path_prefix
+
+ for c in skin.getiterator("output"):
+ id = int(c.get('id') or "0")
+ if id == 0: # framebuffer
+ for res in c.getiterator("resolution"):
+ xres = int(res.get("xres" or "720"))
+ yres = int(res.get("yres" or "576"))
+ bpp = int(res.get("bpp" or "32"))
+
+ #print "Resolution:", xres,yres,bpp
+
+ from enigma import gFBDC
+ i = gFBDC.getInstance()
+ i.setResolution(xres, yres)
+
+ if bpp != 32:
+ # load palette (not yet implemented)
+ pass
+
+ for c in skin.getiterator("colors"):
+ for color in c.getiterator("color"):
+ name = str(color.get("name"))
+ color = str(color.get("value"))
+
+ if not len(color):
+ raise ("need color and name, got %s %s" % (name, color))
+
+ colorNames[name] = parseColor(color)
+ #print "Color:", name, color
+
+ for c in skin.getiterator("fonts"):
+ for font in c.getiterator("font"):
+ filename = str(font.attrib.get("filename", "<NONAME>"))
+ name = str(font.get("name", "Regular"))
+ scale = int(font.get("scale", "100"))
+ is_replacement = font.get("replacement") != ""
+ 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 windowstyle in skin.getiterator("windowstyle"):
+ style = eWindowStyleSkinned()
+ id = int(windowstyle.attrib.get("id","0"))
+
+ #print "windowstyle:", id
+
+ # defaults
+ font = gFont("Regular", 20)
+ offset = eSize(20, 5)
+
+ for title in windowstyle.getiterator("title"):
+ offset = parseSize(title.get("offset"))
+ font = parseFont(str(title.get("font")))
+
+ style.setTitleFont(font);
+ style.setTitleOffset(offset)
+ #print " ", font, offset
+
+ for borderset in windowstyle.getiterator("borderset"):
+ bsName = str(borderset.get("name"))
+ for pixmap in borderset.getiterator("pixmap"):
+ bpName = str(pixmap.get("pos"))
+ filename = str(pixmap.get("filename"))
+
+ 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.getiterator("color"):
+ type = str(color.get("name"))
+ color = parseColor(color.get("color"))
+
+ try:
+ style.setColor(eWindowStyleSkinned.__dict__["col" + type], color)
+ except:
+ raise ("Unknown color %s" % (type))
+ #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, dom_skin) in dom_skins:
+ # first, find the corresponding screen element
+ skin = dom_skin.getroot()
+ for x in skin.getiterator("screen"):
+ if x.get('name') == name:
+ return x, path
+ return None, None
+
+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
+ myscreen = myscreen or 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()
+