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 gMainDC gMainDC.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("listboxcontent"): for offset in c.findall("offset"): get_attr = offset.attrib.get name = get_attr("name") value = get_attr("value") if name and value: if name == "left": eListboxPythonStringContent.setLeftOffset(parseValue(value)) elif name == "right": eListboxPythonStringContent.setRightOffset(parseValue(value)) else: raise SkinError("got listboxcontent offset '%s'' but 'left' or 'right' is allowed only" % name) for font in c.findall("font"): get_attr = font.attrib.get name = get_attr("name") font = get_attr("font") if name and font: if name == "string": eListboxPythonStringContent.setFont(parseFont(font, ((1,1),(1,1)))) elif name == "config_description": eListboxPythonConfigContent.setDescriptionFont(parseFont(font, ((1,1),(1,1)))) elif name == "config_value": eListboxPythonConfigContent.setValueFont(parseFont(font, ((1,1),(1,1)))) else: raise SkinError("got listboxcontent font '%s' but 'string', 'config_description' or 'config_value' is allowed only" % name) for value in c.findall("value"): get_attr = value.attrib.get name = get_attr("name") value = get_attr("value") if name and value: if name == "string_item_height": eListboxPythonStringContent.setItemHeight(parseValue(value)) elif name == "config_item_height": eListboxPythonConfigContent.setItemHeight(parseValue(value)) else: raise SkinError("got listboxcontent value '%s' but 'string_item_height' or 'config_item_height' is allowed only" % name) 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 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) for windowstylescrollbar in skin.findall("windowstylescrollbar"): style = eWindowStyleScrollbar() id = windowstylescrollbar.attrib.get("id") if id: id = int(id) else: id = 4 for value in windowstylescrollbar.findall("value"): get_attr = value.attrib.get vType = get_attr("name") v = get_attr("value") if vType == "BackgroundPixmapTopHeight": style.setBackgroundPixmapTopHeight(int(v)) elif vType == "BackgroundPixmapBottomHeight": style.setBackgroundPixmapBottomHeight(int(v)) elif vType == "ValuePixmapTopHeight": style.setValuePixmapTopHeight(int(v)) elif vType == "ValuePixmapBottomHeight": style.setValuePixmapBottomHeight(int(v)) elif vType == "ScrollbarWidth": style.setScrollbarWidth(int(v)) elif vType == "ScrollbarBorderWidth": style.setScrollbarBorderWidth(int(v)) for pixmap in windowstylescrollbar.findall("pixmap"): get_attr = pixmap.attrib.get vType = get_attr("name") filename = get_attr("filename") if filename: if vType == "BackgroundPixmap": png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop) style.setBackgroundPixmap(png) elif vType == "ValuePixmap": png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop) style.setValuePixmap(png) x = eWindowStyleManager.getInstance() x.setStyle(id, style)
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"): xres = int(res.get("xres", "720")) yres = int(res.get("yres", "576")) bpp = int(res.get("bpp", "32")) from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres, bpp) desktop.resize(eSize(xres, yres)) break 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("listboxcontent"): for offset in c.findall("offset"): get_attr = offset.attrib.get name = get_attr("name") value = get_attr("value") if name and value: if name == "left": eListboxPythonStringContent.setLeftOffset( parseValue(value)) elif name == "right": eListboxPythonStringContent.setRightOffset( parseValue(value)) else: raise SkinError( "got listboxcontent offset '%s'' but 'left' or 'right' is allowed only" % name) for font in c.findall("font"): get_attr = font.attrib.get name = get_attr("name") font = get_attr("font") if name and font: if name == "string": eListboxPythonStringContent.setFont( parseFont(font, ((1, 1), (1, 1)))) elif name == "config_description": eListboxPythonConfigContent.setDescriptionFont( parseFont(font, ((1, 1), (1, 1)))) elif name == "config_value": eListboxPythonConfigContent.setValueFont( parseFont(font, ((1, 1), (1, 1)))) else: raise SkinError( "got listboxcontent font '%s' but 'string', 'config_description' or 'config_value' is allowed only" % name) for value in c.findall("value"): get_attr = value.attrib.get name = get_attr("name") value = get_attr("value") if name and value: if name == "string_item_height": eListboxPythonStringContent.setItemHeight( parseValue(value)) elif name == "config_item_height": eListboxPythonConfigContent.setItemHeight( parseValue(value)) else: raise SkinError( "got listboxcontent value '%s' but 'string_item_height' or 'config_item_height' is allowed only" % name) for cfgpm in c.findall("config"): onPath = cfgpm.attrib.get("onPixmap") if not fileExists(onPath): onPath = resolveFilename(SCOPE_CURRENT_SKIN, onPath) offPath = cfgpm.attrib.get("offPixmap") if not fileExists(offPath): offPath = resolveFilename(SCOPE_CURRENT_SKIN, offPath) pixmapSize = cfgpm.attrib.get("size") if pixmapSize: pixmapSize = parseSize(pixmapSize, ((1, 1), (1, 1))) else: pixmapSize = eSize() ConfigBoolean.setOnOffPixmaps( loadPixmap(onPath, desktop, pixmapSize), loadPixmap(offPath, desktop, pixmapSize)) 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 c in skin.findall("subtitles"): from enigma import 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") if "filename" in pixmap.attrib: 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) elif "color" in pixmap.attrib: color = parseColor(get_attr("color")) size = int(get_attr("size")) Log.w("%s: %s @ %s" % (bpName, color.argb(), size)) style.setColorBorder(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], color, size) 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)) for listfont in windowstyle.findall("listfont"): get_attr = listfont.attrib.get fontType = get_attr("type") fontSize = int(get_attr("size")) fontFace = get_attr("font") try: Log.i("########### ADDING %s: %s" % (fontType, fontSize)) style.setListFont( eWindowStyleSkinned.__dict__["listFont" + fontType], fontSize, fontFace) except: raise SkinError("Unknown listFont %s" % (fontType)) x = eWindowStyleManager.getInstance() x.setStyle(id, style) for windowstylescrollbar in skin.findall("windowstylescrollbar"): style = eWindowStyleScrollbar() id = windowstylescrollbar.attrib.get("id") if id: id = int(id) else: id = 4 for value in windowstylescrollbar.findall("value"): get_attr = value.attrib.get vType = get_attr("name") v = get_attr("value") if vType in ("BackgroundPixmapTopHeight", "BackgroundPixmapBeginSize"): style.setBackgroundPixmapTopHeight(int(v)) elif vType in ("BackgroundPixmapBottomHeight", "BackgroundPixmapEndSize"): style.setBackgroundPixmapBottomHeight(int(v)) elif vType in ("ValuePixmapTopHeight", "ValuePixmapBeginSize"): style.setValuePixmapTopHeight(int(v)) elif vType in ("ValuePixmapBottomHeight", "ValuePixmapEndSize"): style.setValuePixmapBottomHeight(int(v)) elif vType == "ScrollbarWidth": style.setScrollbarWidth(int(v)) elif vType == "ScrollbarBorderWidth": style.setScrollbarBorderWidth(int(v)) for pixmap in windowstylescrollbar.findall("pixmap"): get_attr = pixmap.attrib.get vType = get_attr("name") filename = get_attr("filename") if filename: if vType == "BackgroundPixmap": png = loadPixmap( resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop) style.setBackgroundPixmap(png) elif vType == "ValuePixmap": png = loadPixmap( resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop) style.setValuePixmap(png) x = eWindowStyleManager.getInstance() x.setStyle(id, style) for g in skin.findall("globals"): for value in g.findall("value"): Log.i("Global skin value : %s" % (value.attrib, )) skinGlobals[value.attrib["name"]] = value.attrib["value"] for components in skin.findall("components"): for component in components.findall("component"): componentSizes.apply(component.attrib) for template in component.findall("template"): componentSizes.addTemplate(component.attrib, template.text) for l in skin.findall("layouts"): for layout in l.findall("layout"): layouts.apply(layout)
eListboxPythonStringContent.setRightOffset( parseValue(value)) else: raise SkinError( "got listboxcontent offset '%s'' but 'left' or 'right' is allowed only" % name) for font in c.findall("font"): get_attr = font.attrib.get name = get_attr("name") font = get_attr("font") if name and font: if name == "string": eListboxPythonStringContent.setFont( parseFont(font, ((1, 1), (1, 1)))) elif name == "config_description": eListboxPythonConfigContent.setDescriptionFont( parseFont(font, ((1, 1), (1, 1)))) elif name == "config_value": eListboxPythonConfigContent.setValueFont( parseFont(font, ((1, 1), (1, 1)))) else: raise SkinError( "got listboxcontent font '%s' but 'string', 'config_description' or 'config_value' is allowed only" % name) for value in c.findall("value"): get_attr = value.attrib.get name = get_attr("name") value = get_attr("value") if name and value: if name == "string_item_height": eListboxPythonStringContent.setItemHeight( parseValue(value))