X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/a6f385788cf6331d35b5cd2350eb8144e81567fb..4cc1f7a05166715c19c965e3bbbe74a43835a754:/skin.py diff --git a/skin.py b/skin.py index c28d484a..8535dc81 100644 --- a/skin.py +++ b/skin.py @@ -14,136 +14,16 @@ def dump(x, i=0): except: None -dom = xml.dom.minidom.parseString( - """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - """ """ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# this should be factored out into some helper code, but currently demonstrated applets. -from enigma import eSize, ePoint - -orgwidth = self.instance.size().width() -orgpos = self.instance.position() -textsize = self["text"].getSize() - -# y size still must be fixed in font stuff... -textsize = (textsize[0], textsize[1] + 20) -wsize = (textsize[0] + 20, textsize[1] + 20) - -# resize -self.instance.resize(eSize(*wsize)) +# read the skin +try: + # first we search in the current path + skinfile = file('data/skin.xml', 'r') +except: + # if not found in the current path, we use the global datadir-path + skinfile = file('/usr/share/enigma2/skin.xml', 'r') +dom = xml.dom.minidom.parseString(skinfile.read()) +skinfile.close() -# resize label -self["text"].instance.resize(eSize(*textsize)) - -# center window -newwidth = wsize[0] -self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) - - - """) def parsePosition(str): x, y = str.split(',') @@ -186,20 +66,31 @@ def applySingleAttribute(guiObject, desktop, attrib, value): elif attrib == 'size': guiObject.resize(parseSize(value)) elif attrib == 'title': - guiObject.setTitle(value) + guiObject.setTitle(_(value)) elif attrib == 'text': guiObject.setText(value) elif attrib == 'font': guiObject.setFont(parseFont(value)) + elif attrib == 'zPosition': + guiObject.setZPosition(int(value)) elif attrib == "pixmap": - ptr = gPixmapPtr() - if loadPNG(ptr, value): - raise "loading PNG failed!" - x = ptr - ptr = ptr.__deref__() - desktop.makeCompatiblePixmap(ptr) - guiObject.setPixmap(ptr) + ptr = loadPNG(value) + desktop.makeCompatiblePixmap(ptr.__deref__()) + guiObject.setPixmap(ptr.__deref__()) # guiObject.setPixmapFromFile(value) + elif attrib == "alphatest": # used by ePixmap + guiObject.setAlphatest( + { "on": True, + "off": False + }[value]) + elif attrib == "orientation": # used by eSlider + try: + guiObject.setOrientation( + { "orVertical": guiObject.orVertical, + "orHorizontal": guiObject.orHorizontal + }[value]) + except KeyError: + print "oprientation must be either orVertical or orHorizontal!" elif attrib == "valign": try: guiObject.setVAlign( @@ -231,6 +122,20 @@ def applySingleAttribute(guiObject, desktop, attrib, value): guiObject.setBackgroundColor(parseColor(value)) elif attrib == "foregroundColor": guiObject.setForegroundColor(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 != 'name': print "unsupported attribute " + attrib + "=" + value except int: @@ -244,12 +149,6 @@ def applyAllAttributes(guiObject, desktop, attributes): def loadSkin(desktop): 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'!" @@ -266,17 +165,20 @@ def loadSkin(desktop): for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"): style = eWindowStyleSkinned() + style.setTitleFont(gFont("Arial", 20)); + style.setTitleOffset(eSize(20, 5)); + for borderset in elementsWithTag(windowstyle.childNodes, "borderset"): bsName = str(borderset.getAttribute("name")) for pixmap in elementsWithTag(borderset.childNodes, "pixmap"): bpName = str(pixmap.getAttribute("pos")) filename = str(pixmap.getAttribute("filename")) - png = getPNG(filename) + png = loadPNG(filename) # adapt palette - desktop.makeCompatiblePixmap(png) - style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png) + desktop.makeCompatiblePixmap(png.__deref__()) + style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png.__deref__()) for color in elementsWithTag(windowstyle.childNodes, "color"): type = str(color.getAttribute("name")) @@ -302,7 +204,15 @@ def readSkin(screen, skin, name, desktop): myscreen = x del skin - assert myscreen != None, "no skin for screen '" + name + "' found!" + if myscreen is None: + # try embedded skin + print screen.__dict__ + if "parsedSkin" in screen.__dict__: + myscreen = screen.parsedSkin + elif "skin" in screen.__dict__: + myscreen = screen.parsedSkin = xml.dom.minidom.parseString(screen.skin).childNodes[0] + + assert myscreen is not None, "no skin for screen '" + name + "' found!" screen.skinAttributes = [ ] collectAttributes(screen.skinAttributes, myscreen) @@ -356,5 +266,4 @@ def readSkin(screen, skin, name, desktop): # applyAttributes(guiObject, widget, desktop) # guiObject.thisown = 0 - print screen.additionalWidgets screen.additionalWidgets.append(w)