- 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 != 'name':
- print "unsupported attribute " + attrib + "=" + value
- except AttributeError:
- print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
-
-def loadSkin():
- print "loading skin..."
-
- def getPNG(x):
- g = gPixmapPtr()
- loadPNG(g, x)
- g = g.grabRef()
- return g
-
- skin = dom.childNodes[0]
- assert skin.tagName == "skin", "root element in skin must be 'skin'!"
-
- for c in elementsWithTag(skin.childNodes, "colors"):
- for color in elementsWithTag(c.childNodes, "color"):
- name = str(color.getAttribute("name"))
- color = str(color.getAttribute("value"))
-
- if not len(color):
- raise ("need color and name, got %s %s" % (name, color))
-
- colorNames[name] = parseColor(color)
-
- for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"):
+ 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"):