else: foregroundColor = gRGB(0xFFFFFF) haveColor = 0 col = get_attr("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr("borderWidth") if borderwidth is None: # default: use a subtitle border borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall("windowstyle"): style = eWindowStyleSkinned() style_id = windowstyle.attrib.get("id") if style_id: style_id = int(style_id) else: style_id = 0 # 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)))
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"):
foregroundColor = gRGB(0xFFFFFF) haveColor = 0 col = get_attr("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr("borderWidth") if borderwidth is None: # default: use a subtitle border borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall("windowstyle"): style = eWindowStyleSkinned() style_id = windowstyle.attrib.get("id") if style_id: style_id = int(style_id) else: style_id = 0 # 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)))
def loadSingleSkinData(desktop, 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: 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 from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: pass for skininclude in skin.findall('include'): filename = skininclude.attrib.get('filename') if filename: skinfile = resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix) if not fileExists(skinfile): skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) if fileExists(skinfile): print '[SKIN] loading include:', skinfile loadSkin(skinfile) 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) 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 render = get_attr('render') if render: render = int(render) else: render = 0 resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix) if not fileExists(resolved_font): skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename) if fileExists(skin_path): resolved_font = skin_path addFont(resolved_font, name, scale, is_replacement, render) for alias in c.findall('alias'): get = alias.attrib.get try: name = get('name') font = get('font') size = int(get('size')) height = int(get('height', size)) width = int(get('width', size)) fonts[name] = (font, size, height, width) except Exception as ex: print '[SKIN] bad font alias', ex for c in skin.findall('parameters'): for parameter in c.findall('parameter'): get = parameter.attrib.get try: name = get('name') value = get('value') parameters[name] = map(int, value.split(',')) except Exception as ex: print '[SKIN] bad parameter', ex 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(16777215) haveColor = 0 col = get_attr('borderColor') if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr('borderWidth') if borderwidth is None: borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr('name')] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall('windowstyle'): style = eWindowStyleSkinned() style_id = windowstyle.attrib.get('id') if style_id: style_id = int(style_id) else: style_id = 0 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) 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_CURRENT_SKIN, filename, path_prefix=path_prefix), desktop) style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) 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) x = eWindowStyleManager.getInstance() x.setStyle(style_id, style) for margin in skin.findall('margin'): style_id = margin.attrib.get('id') if style_id: style_id = int(style_id) else: style_id = 0 r = eRect(0, 0, 0, 0) v = margin.attrib.get('left') if v: r.setLeft(int(v)) v = margin.attrib.get('top') if v: r.setTop(int(v)) v = margin.attrib.get('right') if v: r.setRight(int(v)) v = margin.attrib.get('bottom') if v: r.setBottom(int(v)) getDesktop(style_id).setMargins(r)
def loadSingleSkinData(desktop, screenID, domSkin, pathSkin, scope=SCOPE_CURRENT_SKIN): """Loads skin data like colors, windowstyle etc.""" assert domSkin.tag == "skin", "root element in skin must be 'skin'!" global colors, fonts, menus, parameters, setups, switchPixmap for tag in domSkin.findall("output"): id = tag.attrib.get("id") if id: id = int(id) else: id = GUI_SKIN_ID if id == GUI_SKIN_ID: for res in tag.findall("resolution"): xres = res.attrib.get("xres") xres = int(xres) if xres else 720 yres = res.attrib.get("yres") yres = int(yres) if yres else 576 bpp = res.attrib.get("bpp") bpp = int(bpp) if bpp else 32 # print "[Skin] DEBUG: Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp) from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: pass # Load palette (Not yet implemented!) for tag in domSkin.findall("include"): filename = tag.attrib.get("filename") if filename: filename = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(filename): loadSkin(filename, scope=scope, desktop=desktop, screenID=screenID) else: raise SkinError("Included file '%s' not found" % filename) for tag in domSkin.findall("switchpixmap"): for pixmap in tag.findall("pixmap"): name = pixmap.attrib.get("name") if not name: raise SkinError("Pixmap needs name attribute") filename = pixmap.attrib.get("filename") if not filename: raise SkinError("Pixmap needs filename attribute") resolved = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(resolved): switchPixmap[name] = LoadPixmap(resolved, cached=True) else: raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved)) for tag in domSkin.findall("colors"): for color in tag.findall("color"): name = color.attrib.get("name") color = color.attrib.get("value") if name and color: colors[name] = parseColor(color) # print "[Skin] DEBUG: Color name='%s', color='%s'." % (name, color) else: raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color)) for tag in domSkin.findall("fonts"): for font in tag.findall("font"): filename = font.attrib.get("filename", "<NONAME>") name = font.attrib.get("name", "Regular") scale = font.attrib.get("scale") scale = int(scale) if scale else 100 isReplacement = font.attrib.get("replacement") and True or False render = font.attrib.get("render") if render: render = int(render) else: render = 0 filename = resolveFilename(SCOPE_FONTS, filename, path_prefix=pathSkin) if isfile(filename): addFont(filename, name, scale, isReplacement, render) # Log provided by C++ addFont code. # print "[Skin] Add font: Font path='%s', name='%s', scale=%d, isReplacement=%s, render=%d." % (filename, name, scale, isReplacement, render) else: raise SkinError("Font file '%s' not found" % filename) fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=pathSkin) if isfile(fallbackFont): addFont(fallbackFont, "Fallback", 100, -1, 0) # else: # As this is optional don't raise an error. # raise SkinError("Fallback font '%s' not found" % fallbackFont) for alias in tag.findall("alias"): try: name = alias.attrib.get("name") font = alias.attrib.get("font") size = int(alias.attrib.get("size")) height = int(alias.attrib.get("height", size)) # To be calculated some day. width = int(alias.attrib.get("width", size)) fonts[name] = (font, size, height, width) # print "[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width) except Exception as err: raise SkinError("Bad font alias: '%s'" % str(err)) for tag in domSkin.findall("parameters"): for parameter in tag.findall("parameter"): try: name = parameter.attrib.get("name") value = parameter.attrib.get("value") parameters[name] = map(parseParameter, [x.strip() for x in value.split(",")]) if "," in value else parseParameter(value) except Exception as err: raise SkinError("Bad parameter: '%s'" % str(err)) for tag in domSkin.findall("menus"): for setup in tag.findall("menu"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: menus[key] = image # print "[Skin] DEBUG: Menu key='%s', image='%s'." % (key, image) else: raise SkinError("Tag menu needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("setups"): for setup in tag.findall("setup"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: setups[key] = image # print "[Skin] DEBUG: Setup key='%s', image='%s'." % (key, image) else: raise SkinError("Tag setup needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("constant-widgets"): for constant_widget in tag.findall("constant-widget"): name = constant_widget.attrib.get("name") if name: constantWidgets[name] = constant_widget for tag in domSkin.findall("variables"): for parameter in tag.findall("variable"): name = parameter.attrib.get("name") value = parameter.attrib.get("value") x, y = value.split(",") if value and name: variables[name] = "%s,%s" % (str(x), str(y)) for tag in domSkin.findall("subtitles"): from enigma import eSubtitleWidget scale = ((1, 1), (1, 1)) for substyle in tag.findall("sub"): font = parseFont(substyle.attrib.get("font"), scale) col = substyle.attrib.get("foregroundColor") if col: foregroundColor = parseColor(col) haveColor = 1 else: foregroundColor = gRGB(0xFFFFFF) haveColor = 0 col = substyle.attrib.get("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = substyle.attrib.get("borderWidth") if borderwidth is None: borderWidth = 3 # Default: Use a subtitle border. else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[substyle.attrib.get("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for tag in domSkin.findall("windowstyle"): style = eWindowStyleSkinned() styleId = tag.attrib.get("id") if styleId: styleId = int(styleId) else: styleId = GUI_SKIN_ID font = gFont("Regular", 20) # Default offset = eSize(20, 5) # Default for title in tag.findall("title"): offset = parseSize(title.attrib.get("offset"), ((1, 1), (1, 1))) font = parseFont(title.attrib.get("font"), ((1, 1), (1, 1))) style.setTitleFont(font) style.setTitleOffset(offset) # print "[Skin] DEBUG: WindowStyle font, offset -", font, offset for borderset in tag.findall("borderset"): bsName = str(borderset.attrib.get("name")) for pixmap in borderset.findall("pixmap"): bpName = pixmap.attrib.get("pos") filename = pixmap.attrib.get("filename") if filename and bpName: png = loadPixmap(resolveFilename(scope, filename, path_prefix=pathSkin), desktop) try: style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) except Exception: pass # print "[Skin] DEBUG: WindowStyle borderset name, filename -", bpName, filename for color in tag.findall("color"): colorType = color.attrib.get("name") color = parseColor(color.attrib.get("color")) try: style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color) except Exception: raise SkinError("Unknown color type '%s'" % colorType) # print "[Skin] DEBUG: WindowStyle color type, color -", type, color x = eWindowStyleManager.getInstance() x.setStyle(styleId, style) for tag in domSkin.findall("margin"): styleId = tag.attrib.get("id") if styleId: styleId = int(styleId) else: styleId = GUI_SKIN_ID r = eRect(0, 0, 0, 0) v = tag.attrib.get("left") if v: r.setLeft(int(v)) v = tag.attrib.get("top") if v: r.setTop(int(v)) v = tag.attrib.get("right") if v: r.setRight(int(v)) v = tag.attrib.get("bottom") if v: r.setBottom(int(v)) # The "desktop" parameter is hard-coded to the GUI screen, so we must ask # for the one that this actually applies to. getDesktop(styleId).setMargins(r)
def loadSingleSkinData(desktop, screenID, domSkin, pathSkin, scope=SCOPE_CURRENT_SKIN): """Loads skin data like colors, windowstyle etc.""" assert domSkin.tag == "skin", "root element in skin must be 'skin'!" global colors, fonts, menus, parameters, setups, switchPixmap for tag in domSkin.findall("output"): scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) if scrnID == GUI_SKIN_ID: for res in tag.findall("resolution"): xres = res.attrib.get("xres") xres = int(xres) if xres else 720 yres = res.attrib.get("yres") yres = int(yres) if yres else 576 bpp = res.attrib.get("bpp") bpp = int(bpp) if bpp else 32 # print("[Skin] DEBUG: Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp)) from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: pass # Load palette (Not yet implemented!) if yres >= 1080: parameters["AboutHddSplit"] = 1 parameters["AutotimerListChannels"] = (2, 60, 4, 32) parameters["AutotimerListDays"] = (1, 40, 5, 25) parameters["AutotimerListHasTimespan"] = (154, 4, 150, 25) parameters["AutotimerListIcon"] = (3, -1, 36, 36) parameters["AutotimerListRectypeicon"] = (39, 4, 30, 30) parameters["AutotimerListTimerName"] = (76, 4, 26, 32) parameters["AutotimerListTimespan"] = (2, 40, 5, 25) parameters["ChoicelistDash"] = (0, 3, 1000, 30) parameters["ChoicelistIcon"] = (7, 0, 52, 38) parameters["ChoicelistName"] = (68, 3, 1000, 32) parameters["ChoicelistNameSingle"] = (7, 3, 1000, 32) parameters["ConfigListSeperator"] = 500 parameters["DreamexplorerIcon"] = (15, 4, 30, 30) parameters["DreamexplorerName"] = (62, 0, 1200, 38) parameters["FileListIcon"] = (7, 4, 52, 37) parameters["FileListMultiIcon"] = (45, 4, 30, 30) parameters["FileListMultiLock"] = (2, 0, 36, 36) parameters["FileListMultiName"] = (90, 3, 1000, 32) parameters["FileListName"] = (68, 4, 1000, 34) parameters["HelpMenuListExtHlp0"] = (0, 0, 900, 39) parameters["HelpMenuListExtHlp1"] = (0, 42, 900, 30) parameters["HelpMenuListHlp"] = (0, 0, 900, 42) parameters["PartnerBoxBouquetListName"] = (0, 0, 45) parameters["PartnerBoxChannelListName"] = (0, 0, 45) parameters["PartnerBoxChannelListTime"] = (0, 78, 225, 30) parameters["PartnerBoxChannelListTitle"] = (0, 42, 30) parameters["PartnerBoxE1TimerState"] = (255, 78, 255, 30) parameters["PartnerBoxE1TimerTime"] = (0, 78, 255, 30) parameters["PartnerBoxE2TimerIcon"] = (1050, 8, 20, 20) parameters["PartnerBoxE2TimerIconRepeat"] = (1050, 38, 20, 20) parameters["PartnerBoxE2TimerState"] = (225, 78, 225, 30) parameters["PartnerBoxE2TimerTime"] = (0, 78, 225, 30) parameters["PartnerBoxEntryListIP"] = (180, 2, 225, 38) parameters["PartnerBoxEntryListName"] = (8, 2, 225, 38) parameters["PartnerBoxEntryListPort"] = (405, 2, 150, 38) parameters["PartnerBoxEntryListType"] = (615, 2, 150, 38) parameters["PartnerBoxTimerName"] = (0, 42, 30) parameters["PartnerBoxTimerServicename"] = (0, 0, 45) parameters["PicturePlayerThumb"] = (30, 285, 45, 300, 30, 25) parameters["PlayListIcon"] = (7, 7, 24, 24) parameters["PlayListName"] = (38, 2, 1000, 34) parameters["PluginBrowserDescr"] = (180, 42, 25) parameters["PluginBrowserDownloadDescr"] = (120, 42, 25) parameters["PluginBrowserDownloadIcon"] = (15, 0, 90, 76) parameters["PluginBrowserDownloadName"] = (120, 8, 38) parameters["PluginBrowserIcon"] = (15, 8, 150, 60) parameters["PluginBrowserName"] = (180, 8, 38) parameters["SHOUTcastListItem"] = (30, 27, 35, 96, 35, 33, 60, 32) parameters["SelectionListDescr"] = (45, 6, 1000, 45) parameters["SelectionListLock"] = (0, 2, 36, 36) parameters["ServiceInfoLeft"] = (0, 0, 450, 45) parameters["ServiceInfoRight"] = (450, 0, 1000, 45) parameters["VirtualKeyBoard"] = (68, 68) parameters["VirtualKeyBoardAlignment"] = (0, 0) parameters["VirtualKeyBoardPadding"] = (7, 7) parameters["VirtualKeyBoardShiftColors"] = (0x00ffffff, 0x00ffffff, 0x0000ffff, 0x00ff00ff) for tag in domSkin.findall("include"): filename = tag.attrib.get("filename") if filename: filename = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(filename): loadSkin(filename, scope=scope, desktop=desktop, screenID=screenID) else: raise SkinError("Included file '%s' not found" % filename) for tag in domSkin.findall("switchpixmap"): for pixmap in tag.findall("pixmap"): name = pixmap.attrib.get("name") if not name: raise SkinError("Pixmap needs name attribute") filename = pixmap.attrib.get("filename") if not filename: raise SkinError("Pixmap needs filename attribute") resolved = resolveFilename(scope, filename, path_prefix=pathSkin) if isfile(resolved): switchPixmap[name] = LoadPixmap(resolved, cached=True) else: raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved)) for tag in domSkin.findall("colors"): for color in tag.findall("color"): name = color.attrib.get("name") color = color.attrib.get("value") if name and color: colors[name] = parseColor(color) # print("[Skin] DEBUG: Color name='%s', color='%s'." % (name, color)) else: raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color)) for tag in domSkin.findall("fonts"): for font in tag.findall("font"): filename = font.attrib.get("filename", "<NONAME>") name = font.attrib.get("name", "Regular") scale = font.attrib.get("scale") scale = int(scale) if scale else 100 isReplacement = font.attrib.get("replacement") and True or False render = font.attrib.get("render") if render: render = int(render) else: render = 0 filename = resolveFilename(SCOPE_FONTS, filename, path_prefix=pathSkin) # Log provided by C++ addFont code. # print("[Skin] Add font: Font path='%s', name='%s', scale=%d, isReplacement=%s, render=%d." % (filename, name, scale, isReplacement, render)) if not fileExists(filename): # When font is not available look at current skin path filename = resolveFilename(SCOPE_CURRENT_SKIN, filename) if not fileExists(filename) and fileExists(resolveFilename(SCOPE_CURRENT_LCDSKIN, filename)): filename = resolveFilename(SCOPE_CURRENT_LCDSKIN, filename) addFont(filename, name, scale, isReplacement, render) fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=pathSkin) if isfile(fallbackFont): addFont(fallbackFont, "Fallback", 100, -1, 0) # else: # As this is optional don't raise an error. # raise SkinError("Fallback font '%s' not found" % fallbackFont) for alias in tag.findall("alias"): try: name = alias.attrib.get("name") font = alias.attrib.get("font") size = int(alias.attrib.get("size")) height = int(alias.attrib.get("height", size)) # To be calculated some day. width = int(alias.attrib.get("width", size)) fonts[name] = (font, size, height, width) # print("[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width)) except Exception as err: raise SkinError("Bad font alias: '%s'" % str(err)) for tag in domSkin.findall("parameters"): for parameter in tag.findall("parameter"): try: name = parameter.attrib.get("name") value = parameter.attrib.get("value") parameters[name] = list(map(parseParameter, [x.strip() for x in value.split(",")]) if "," in value else parseParameter(value)) except Exception as err: raise SkinError("Bad parameter: '%s'" % str(err)) for tag in domSkin.findall("menus"): for setup in tag.findall("menu"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: menus[key] = image # print("[Skin] DEBUG: Menu key='%s', image='%s'." % (key, image)) else: raise SkinError("Tag menu needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("setups"): for setup in tag.findall("setup"): key = setup.attrib.get("key") image = setup.attrib.get("image") if key and image: setups[key] = image # print("[Skin] DEBUG: Setup key='%s', image='%s'." % (key, image)) else: raise SkinError("Tag setup needs key and image, got key='%s' and image='%s'" % (key, image)) for tag in domSkin.findall("subtitles"): from enigma import eSubtitleWidget scale = ((1, 1), (1, 1)) for substyle in tag.findall("sub"): font = parseFont(substyle.attrib.get("font"), scale) col = substyle.attrib.get("foregroundColor") if col: foregroundColor = parseColor(col) haveColor = 1 else: foregroundColor = gRGB(0xFFFFFF) haveColor = 0 col = substyle.attrib.get("borderColor" and "shadowColor") if col: borderColor = shadowColor = parseColor(col) else: borderColor = shadowColor = gRGB(0) borderwidth = substyle.attrib.get("borderWidth") if borderwidth is None: borderWidth = 3 # Default: Use a subtitle border. else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[substyle.attrib.get("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for tag in domSkin.findall("windowstyle"): style = eWindowStyleSkinned() scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) font = gFont("Regular", 20) # Default offset = eSize(20, 5) # Default for title in tag.findall("title"): offset = parseSize(title.attrib.get("offset"), ((1, 1), (1, 1))) font = parseFont(title.attrib.get("font"), ((1, 1), (1, 1))) style.setTitleFont(font) style.setTitleOffset(offset) # print("[Skin] DEBUG: WindowStyle font, offset - '%s' '%s'." % (str(font), str(offset))) for borderset in tag.findall("borderset"): bsName = str(borderset.attrib.get("name")) for pixmap in borderset.findall("pixmap"): bpName = pixmap.attrib.get("pos") filename = pixmap.attrib.get("filename") if filename and bpName: png = loadPixmap(resolveFilename(scope, filename, path_prefix=pathSkin), desktop) try: style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) except Exception: pass # print("[Skin] DEBUG: WindowStyle borderset name, filename - '%s' '%s'." % (bpName, filename)) for color in tag.findall("color"): colorType = color.attrib.get("name") color = parseColor(color.attrib.get("color")) try: style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color) except Exception: raise SkinError("Unknown color type '%s'" % colorType) # print("[Skin] DEBUG: WindowStyle color type, color -" % (colorType, str(color))) x = eWindowStyleManager.getInstance() x.setStyle(scrnID, style) for tag in domSkin.findall("margin"): scrnID = int(tag.attrib.get("id", GUI_SKIN_ID)) r = eRect(0, 0, 0, 0) v = tag.attrib.get("left") if v: r.setLeft(int(v)) v = tag.attrib.get("top") if v: r.setTop(int(v)) v = tag.attrib.get("right") if v: r.setRight(int(v)) v = tag.attrib.get("bottom") if v: r.setBottom(int(v)) # The "desktop" parameter is hard-coded to the GUI screen, so we must ask # for the one that this actually applies to. getDesktop(scrnID).setMargins(r)
def loadSingleSkinData(desktop, skin, path_prefix): """loads skin data like colors, windowstyle etc.""" assert skin.tag == "skin", "root element in skin must be 'skin'!" 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("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 render = get_attr("render") if render: render = int(render) else: render = 0 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, render) #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("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr("borderWidth") if borderwidth is None: # default: use a subtitle border borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) 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)
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("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)
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)
def loadSingleSkinData(desktop, skin, path_prefix): """loads skin data like colors, windowstyle etc.""" assert skin.tag == "skin", "root element in skin must be 'skin'!" 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 skininclude in skin.findall("include"): filename = skininclude.attrib.get("filename") if filename: skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if not fileExists(skinfile): skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) if fileExists(skinfile): print("[SKIN] loading include:", skinfile) loadSkin(skinfile) 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("parameters"): for parameter in c.findall("parameter"): get = parameter.attrib.get try: name = get("name") value = get("value") if name.find('Font') != -1: font = value.split(";") if isinstance(font, list) and len(font) == 2: parameters[name] = (str(font[0]), int(font[1])) else: parameters[name] = list(map(int, value.split(","))) except Exception as ex: print("[SKIN] bad parameter", ex) 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 render = get_attr("render") if render: render = int(render) else: render = 0 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 resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename) if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)): resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename) elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)): resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename) addFont(resolved_font, name, scale, is_replacement, render) #print "Font: ", resolved_font, name, scale, is_replacement for alias in c.findall("alias"): get = alias.attrib.get try: name = get("name") font = get("font") size = int(get("size")) height = int(get("height", size)) # to be calculated some day width = int(get("width", size)) global fonts fonts[name] = (font, size, height, width) except Exception as ex: print("[SKIN] bad font alias", ex) 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("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr("borderWidth") if borderwidth is None: # default: use a subtitle border borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall("windowstyle"): style = eWindowStyleSkinned() style_id = windowstyle.attrib.get("id") if style_id: style_id = int(style_id) else: style_id = 0 # 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: pngfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if fileExists(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)): pngfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) png = loadPixmap(pngfile, desktop) try: style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) except: pass #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(style_id, style) for margin in skin.findall("margin"): style_id = margin.attrib.get("id") if style_id: style_id = int(style_id) else: style_id = 0 r = eRect(0,0,0,0) v = margin.attrib.get("left") if v: r.setLeft(int(v)) v = margin.attrib.get("top") if v: r.setTop(int(v)) v = margin.attrib.get("right") if v: r.setRight(int(v)) v = margin.attrib.get("bottom") if v: r.setBottom(int(v)) # the "desktop" parameter is hardcoded to the UI screen, so we must ask # for the one that this actually applies to. getDesktop(style_id).setMargins(r)
def loadSingleSkinData(desktop, 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: 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 from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: pass for skininclude in skin.findall('include'): filename = skininclude.attrib.get('filename') if filename: skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if not fileExists(skinfile): skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) if fileExists(skinfile): print '[SKIN] loading include:', skinfile loadSkin(skinfile) 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) 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 render = get_attr('render') if render: render = int(render) else: render = 0 resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix) if not fileExists(resolved_font): resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename) if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)): resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename) elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)): resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename) addFont(resolved_font, name, scale, is_replacement, render) for alias in c.findall('alias'): get = alias.attrib.get try: name = get('name') font = get('font') size = int(get('size')) height = int(get('height', size)) width = int(get('width', size)) fonts[name] = (font, size, height, width) except Exception as ex: print '[SKIN] bad font alias', ex for c in skin.findall('parameters'): for parameter in c.findall('parameter'): get = parameter.attrib.get try: name = get('name') value = get('value') parameters[name] = map(int, value.split(',')) except Exception as ex: print '[SKIN] bad parameter', ex 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(16777215) haveColor = 0 col = get_attr('borderColor') if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr('borderWidth') if borderwidth is None: borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr('name')] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall('windowstyle'): style = eWindowStyleSkinned() style_id = windowstyle.attrib.get('id') if style_id: style_id = int(style_id) else: style_id = 0 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) 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: pngfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if fileExists(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)): pngfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) png = loadPixmap(pngfile, desktop) style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) 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) x = eWindowStyleManager.getInstance() x.setStyle(style_id, style) for margin in skin.findall('margin'): style_id = margin.attrib.get('id') if style_id: style_id = int(style_id) else: style_id = 0 r = eRect(0, 0, 0, 0) v = margin.attrib.get('left') if v: r.setLeft(int(v)) v = margin.attrib.get('top') if v: r.setTop(int(v)) v = margin.attrib.get('right') if v: r.setRight(int(v)) v = margin.attrib.get('bottom') if v: r.setBottom(int(v)) getDesktop(style_id).setMargins(r)
def loadSingleSkinData(desktop, 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: 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 from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: pass for skininclude in skin.findall("include"): filename = skininclude.attrib.get("filename") if filename: skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if not fileExists(skinfile): skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) if fileExists(skinfile): print "[SKIN] loading include:", skinfile loadSkin(skinfile) 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) 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 render = get_attr("render") if render: render = int(render) else: render = 0 resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix) if not fileExists(resolved_font): resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename) if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)): resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename) elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)): resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename) addFont(resolved_font, name, scale, is_replacement, render) for alias in c.findall("alias"): get = alias.attrib.get try: name = get("name") font = get("font") size = int(get("size")) height = int(get("height", size)) width = int(get("width", size)) fonts[name] = (font, size, height, width) except Exception as ex: print "[SKIN] bad font alias", ex for c in skin.findall("parameters"): for parameter in c.findall("parameter"): get = parameter.attrib.get try: name = get("name") value = get("value") parameters[name] = map(int, value.split(",")) except Exception as ex: print "[SKIN] bad parameter", ex 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(16777215) haveColor = 0 col = get_attr("borderColor") if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr("borderWidth") if borderwidth is None: borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr("name")] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall("windowstyle"): style = eWindowStyleSkinned() style_id = windowstyle.attrib.get("id") if style_id: style_id = int(style_id) else: style_id = 0 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) 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: pngfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix) if fileExists(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)): pngfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix) png = loadPixmap(pngfile, desktop) style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) 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) x = eWindowStyleManager.getInstance() x.setStyle(style_id, style) for margin in skin.findall("margin"): style_id = margin.attrib.get("id") if style_id: style_id = int(style_id) else: style_id = 0 r = eRect(0, 0, 0, 0) v = margin.attrib.get("left") if v: r.setLeft(int(v)) v = margin.attrib.get("top") if v: r.setTop(int(v)) v = margin.attrib.get("right") if v: r.setRight(int(v)) v = margin.attrib.get("bottom") if v: r.setBottom(int(v)) getDesktop(style_id).setMargins(r) return
def loadSingleSkinData(desktop, 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: 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 from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: 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) if color[0] != '#': for key in colorNames: if key == color: colorNamesHuman[name] = colorNamesHuman[key] break else: humancolor = color[1:] if len(humancolor) >= 6: colorNamesHuman[name] = int(humancolor, 16) 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): skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename) if fileExists(skin_path): resolved_font = skin_path addFont(resolved_font, name, scale, is_replacement) for c in skin.findall('parameters'): for parameter in c.findall('parameter'): get = parameter.attrib.get try: name = get('name') value = get('value') if name.find('Font') != -1: font = value.split(';') if isinstance(font, list) and len(font) == 2: parameters[name] = (str(font[0]), int(font[1])) else: parameters[name] = map(int, value.split(',')) except Exception as ex: print '[SKIN] bad parameter', ex for c in skin.findall('constant-widgets'): for constant_widget in c.findall('constant-widget'): get = constant_widget.attrib.get name = get('name') if name: constant_widgets[name] = constant_widget for c in skin.findall('variables'): for parameter in c.findall('variable'): get = parameter.attrib.get name = get('name') value = get('value') x, y = value.split(',') if value and name: variables[name] = str(x) + ',' + str(y) 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(16777215) haveColor = 0 col = get_attr('borderColor') if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr('borderWidth') if borderwidth is None: borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr('name')] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall('windowstyle'): style = eWindowStyleSkinned() id = windowstyle.attrib.get('id') if id: id = int(id) else: id = 0 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) 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) 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) x = eWindowStyleManager.getInstance() x.setStyle(id, style)
def loadSingleSkinData(desktop, 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: 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 from enigma import gMainDC gMainDC.getInstance().setResolution(xres, yres) desktop.resize(eSize(xres, yres)) if bpp != 32: 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) if color[0] != '#': for key in colorNames: if key == color: colorNamesHuman[name] = colorNamesHuman[key] break else: humancolor = color[1:] if len(humancolor) >= 6: colorNamesHuman[name] = int(humancolor, 16) 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): skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename) if fileExists(skin_path): resolved_font = skin_path addFont(resolved_font, name, scale, is_replacement) for c in skin.findall('parameters'): for parameter in c.findall('parameter'): get = parameter.attrib.get try: name = get('name') value = get('value') if name.find('Font') != -1: font = value.split(';') if isinstance(font, list) and len(font) == 2: parameters[name] = (str(font[0]), int(font[1])) else: parameters[name] = map(int, value.split(',')) except Exception as ex: print '[SKIN] bad parameter', ex for c in skin.findall('constant-widgets'): for constant_widget in c.findall('constant-widget'): get = constant_widget.attrib.get name = get('name') if name: constant_widgets[name] = constant_widget for c in skin.findall('variables'): for parameter in c.findall('variable'): get = parameter.attrib.get name = get('name') value = get('value') x, y = value.split(',') if value and name: variables[name] = str(x) + ',' + str(y) 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(16777215) haveColor = 0 col = get_attr('borderColor') if col: borderColor = parseColor(col) else: borderColor = gRGB(0) borderwidth = get_attr('borderWidth') if borderwidth is None: borderWidth = 3 else: borderWidth = int(borderwidth) face = eSubtitleWidget.__dict__[get_attr('name')] eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth) for windowstyle in skin.findall('windowstyle'): style = eWindowStyleSkinned() id = windowstyle.attrib.get('id') if id: id = int(id) else: id = 0 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) 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) 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) x = eWindowStyleManager.getInstance() x.setStyle(id, style)