- fixed console input mode restore
[enigma2.git] / skin.py
diff --git a/skin.py b/skin.py
index 2996edb02e4cf8f467533f9f244c9b76ba3ae620..936dcc965ab96dacd18f81d805e4f9111aec6462 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -13,16 +13,28 @@ def dump(x, i=0):
 dom = xml.dom.minidom.parseString(
        """
        <skin>
 dom = xml.dom.minidom.parseString(
        """
        <skin>
-               <screen name="testDialog">
-                       <widget name="okbutton" position="10,120" size="280,40" />
+               <screen name="mainMenu" position="300,100" size="300,300" title="real main menu">
+                       <widget name="okbutton" position="10,190" size="280,50" />
                        <widget name="title" position="10,10" size="280,20" />
                        <widget name="title" position="10,10" size="280,20" />
-                       <widget name="menu" position="10,30" size="280,90" />
+                       <widget name="menu" position="10,30" size="280,140" />
                </screen>
                <screen name="clockDisplay" position="300,100" size="300,300">
                        <widget name="okbutton" position="10,10" size="280,40" />
                        <widget name="title" position="10,120" size="280,50" />
                        <widget name="theClock" position="10,60" size="280,50" />
                </screen>
                </screen>
                <screen name="clockDisplay" position="300,100" size="300,300">
                        <widget name="okbutton" position="10,10" size="280,40" />
                        <widget name="title" position="10,120" size="280,50" />
                        <widget name="theClock" position="10,60" size="280,50" />
                </screen>
+               <screen name="infoBar" position="100,100" size="300,400" title="InfoBar">
+                       <widget name="channelSwitcher" position="10,190" size="280,50" />
+               </screen>
+               <screen name="channelSelection" position="300,100" size="300,300" title="Channel Selection">
+                       <widget name="okbutton" position="10,190" size="280,50" />
+                       <widget name="list" position="10,30" size="280,140" />
+               </screen>
+               <screen name="serviceScan" position="150,100" size="300,200" title="Service Scan">
+                       <widget name="scan_progress" position="10,10" size="280,50" />
+                       <widget name="scan_state" position="10,60" size="280,30" />
+                       <widget name="okbutton" position="10,100" size="280,40" />
+               </screen>
        </skin>
 """)
 
        </skin>
 """)
 
@@ -41,15 +53,23 @@ def applyAttributes(guiObject, node):
        for p in range(node.attributes.length):
                a = node.attributes.item(p)
                
        for p in range(node.attributes.length):
                a = node.attributes.item(p)
                
+               # convert to string (was: unicode)
+               attrib = str(a.name)
+               # TODO: proper UTF8 translation?! (for value)
+               # TODO: localization? as in e1?
+               value = str(a.value)
+               
                # and set attributes
                # and set attributes
-               if a.name == 'position':
-                       guiObject.move(parsePosition(a.value))
-               elif a.name == 'size':
-                       guiObject.resize(parseSize(a.value))
-               elif a.name != 'name':
-                       print "unsupported attribute " + a.name
+               if attrib == 'position':
+                       guiObject.move(parsePosition(value))
+               elif attrib == 'size':
+                       guiObject.resize(parseSize(value))
+               elif attrib == 'title':
+                       guiObject.setTitle(value)
+               elif attrib != 'name':
+                       print "unsupported attribute " + attrib + "=" + value
 
 
-def applyGUIskin(screen, skin, name):
+def applyGUIskin(screen, parent, skin, name):
        
        myscreen = None
        
        
        myscreen = None
        
@@ -61,17 +81,21 @@ def applyGUIskin(screen, skin, name):
                if x.getAttribute('name') == name:
                        myscreen = x
        
                if x.getAttribute('name') == name:
                        myscreen = x
        
-       assert myscreen != None, "no skin for screen " + name + " found!"
+       assert myscreen != None, "no skin for screen '" + name + "' found!"
        
        
-       print "ok, found screen.."
+       applyAttributes(parent, myscreen)
        
        # now walk all widgets
        for widget in myscreen.getElementsByTagName("widget"):
        
        # now walk all widgets
        for widget in myscreen.getElementsByTagName("widget"):
-               name = widget.getAttribute('name')
-               if name == None:
+               wname = widget.getAttribute('name')
+               if wname == None:
                        print "widget has no name!"
                        continue
                
                # get corresponding gui object
                        print "widget has no name!"
                        continue
                
                # get corresponding gui object
-               guiObject = screen.data[name]["instance"]
+               try:
+                       guiObject = screen.data[wname]["instance"]
+               except:
+                       raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
+               
                applyAttributes(guiObject, widget)
                applyAttributes(guiObject, widget)