+ # convert to string (was: unicode)
+ attrib = str(a.name)
+ # TODO: localization? as in e1?
+ value = a.value.encode("utf-8")
+
+ 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:
+ skinAttributes.append((attrib, value))
+
+def loadPixmap(path, desktop):
+ cached = False
+ option = path.find("#")
+ if option != -1:
+ options = path[option+1:].split(',')
+ path = path[:option]
+ cached = "cached" in options
+ ptr = LoadPixmap(path, desktop, cached)
+ if ptr is None:
+ raise SkinError("pixmap file %s not found!" % (path))
+ return ptr
+
+def applySingleAttribute(guiObject, desktop, attrib, value):
+ # and set attributes
+ try:
+ if attrib == 'position':
+ guiObject.move(parsePosition(value))
+ elif attrib == 'size':
+ guiObject.resize(parseSize(value))
+ elif attrib == 'title':
+ guiObject.setTitle(_(value))
+ elif attrib == 'text':
+ guiObject.setText(_(value))
+ elif attrib == 'font':
+ guiObject.setFont(parseFont(value))
+ 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,
+ "orHorizontal": guiObject.orHorizontal
+ }[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)
+ 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."""