+ guiObject.setTitle(_(value))
+ elif attrib == 'text':
+ guiObject.setText(_(value))
+ elif attrib == 'font':
+ guiObject.setFont(parseFont(value, scale))
+ elif attrib == 'zPosition':
+ guiObject.setZPosition(int(value))
+ elif attrib in ("pixmap", "backgroundPixmap", "selectionPixmap"):
+ ptr = loadPixmap(value, desktop) # this should already have been filename-resolved.
+ if attrib == "pixmap":
+ guiObject.setPixmap(ptr)
+ elif attrib == "backgroundPixmap":
+ guiObject.setBackgroundPicture(ptr)
+ elif attrib == "selectionPixmap":
+ guiObject.setSelectionPicture(ptr)
+ # guiObject.setPixmapFromFile(value)
+ elif attrib == "alphatest": # used by ePixmap
+ guiObject.setAlphatest(
+ { "on": 1,
+ "off": 0,
+ "blend": 2,
+ }[value])
+ elif attrib == "orientation": # used by eSlider
+ try:
+ guiObject.setOrientation(*
+ { "orVertical": (guiObject.orVertical, False),
+ "orTopToBottom": (guiObject.orVertical, False),
+ "orBottomToTop": (guiObject.orVertical, True),
+ "orHorizontal": (guiObject.orHorizontal, False),
+ "orLeftToRight": (guiObject.orHorizontal, False),
+ "orRightToLeft": (guiObject.orHorizontal, True),
+ }[value])
+ except KeyError:
+ print "oprientation must be either orVertical or orHorizontal!"
+ elif attrib == "valign":
+ try:
+ guiObject.setVAlign(
+ { "top": guiObject.alignTop,
+ "center": guiObject.alignCenter,
+ "bottom": guiObject.alignBottom
+ }[value])
+ except KeyError:
+ print "valign must be either top, center or bottom!"
+ elif attrib == "halign":
+ try:
+ guiObject.setHAlign(
+ { "left": guiObject.alignLeft,
+ "center": guiObject.alignCenter,
+ "right": guiObject.alignRight,
+ "block": guiObject.alignBlock
+ }[value])
+ except KeyError:
+ print "halign must be either left, center, right or block!"
+ elif attrib == "flags":
+ flags = value.split(',')
+ for f in flags:
+ try:
+ fv = eWindow.__dict__[f]
+ guiObject.setFlag(fv)
+ except KeyError:
+ 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, scale)
+ ptr = loadPixmap(name, desktop)
+ guiObject.setPointer({"pointer": 0, "seek_pointer": 1}[attrib], ptr, pos)
+ elif attrib == 'shadowOffset':
+ guiObject.setShadowOffset(parsePosition(value, scale))
+ 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, scale):
+ for (attrib, value) in attributes:
+ applySingleAttribute(guiObject, desktop, attrib, value, scale)
+
+def loadSingleSkinData(desktop, skin, path_prefix):
+ """loads skin data like colors, windowstyle etc."""
+ assert skin.tag == "skin", "root element in skin must be 'skin'!"
+
+ #print "***SKIN: ", path_prefix
+
+ for c in skin.findall("output"):
+ id = c.attrib.get('id')
+ if id:
+ id = int(id)
+ else:
+ id = 0
+ if id == 0: # framebuffer
+ for res in c.findall("resolution"):
+ get_attr = res.attrib.get
+ xres = get_attr("xres")
+ if xres:
+ xres = int(xres)
+ else:
+ xres = 720
+ yres = get_attr("yres")
+ if yres:
+ yres = int(yres)
+ else:
+ yres = 576
+ bpp = get_attr("bpp")
+ if bpp:
+ bpp = int(bpp)
+ else:
+ bpp = 32
+ #print "Resolution:", xres,yres,bpp
+ from enigma import gFBDC
+ gFBDC.getInstance().setResolution(xres, yres)
+ desktop.resize(eSize(xres, yres))
+ if bpp != 32:
+ # load palette (not yet implemented)
+ pass
+
+ for c in skin.findall("colors"):
+ for color in c.findall("color"):
+ get_attr = color.attrib.get
+ name = get_attr("name")
+ color = get_attr("value")
+ if name and color:
+ colorNames[name] = parseColor(color)
+ #print "Color:", name, color
+ else:
+ raise SkinError("need color and name, got %s %s" % (name, color))
+
+ for c in skin.findall("fonts"):
+ for font in c.findall("font"):
+ get_attr = font.attrib.get
+ filename = get_attr("filename", "<NONAME>")
+ name = get_attr("name", "Regular")
+ scale = get_attr("scale")
+ if scale:
+ scale = int(scale)
+ else:
+ 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 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
+ type = get_attr("name")
+ color = parseColor(get_attr("color"))
+ try:
+ style.setColor(eWindowStyleSkinned.__dict__["col" + type], color)
+ except:
+ raise SkinError("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, 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()
+