sorry, i REALLY don't know, how to fix it other than using a try/except block
[enigma2.git] / skin.py
diff --git a/skin.py b/skin.py
index bf8de72a34de82c6a71d4b1801e87ddc9edfc362..d11cce02f5ee6101cdf93547795ced9694a67675 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -16,11 +16,14 @@ def dump(x, i=0):
 
 # read the skin
 try:
-       skinfile = file('/usr/share/enigma2/skin.xml', 'r')
-       dom = xml.dom.minidom.parseString(skinfile.read())
-       skinfile.close()
+       # first we search in the current path
+       skinfile = file('data/skin.xml', 'r')
 except:
-       print "Error opening skin.xml"
+       # 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()
+
 
 def parsePosition(str):
        x, y = str.split(',')
@@ -63,11 +66,13 @@ 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):
@@ -77,6 +82,19 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                        desktop.makeCompatiblePixmap(ptr)
                        guiObject.setPixmap(ptr)
                        # 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(
@@ -108,6 +126,10 @@ 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 != 'name':
                        print "unsupported attribute " + attrib + "=" + value
        except int:
@@ -143,6 +165,9 @@ 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"):
@@ -179,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)
@@ -233,5 +266,4 @@ def readSkin(screen, skin, name, desktop):
                
                # applyAttributes(guiObject, widget, desktop)
                # guiObject.thisown = 0
-               print screen.additionalWidgets
                screen.additionalWidgets.append(w)