-dom = xml.dom.minidom.parseString(
- """<skin>
- <windowstyle type="skinned">
- <color name="defaultBackground" color="#4075a7" />
- <borderset name="bsWindow">
- <pixmap pos="bpTopLeft" filename="data/b_w_tl.png" />
- <pixmap pos="bpTop" filename="data/b_w_t.png" />
- <pixmap pos="bpTopRight" filename="data/b_w_tr.png" />
- <pixmap pos="bpLeft" filename="data/b_w_l.png" />
- <pixmap pos="bpRight" filename="data/b_w_r.png" />
- <pixmap pos="bpBottomLeft" filename="data/b_w_bl.png" />
- <pixmap pos="bpBottom" filename="data/b_w_b.png" />
- <pixmap pos="bpBottomRight" filename="data/b_w_br.png" />
- </borderset>
- </windowstyle>
- <screen name="mainMenu" position="300,100" size="300,300" title="real main menu">
- <widget name="okbutton" position="10,190" size="280,50" font="Arial;20" valign="center" halign="center" />
- <widget name="title" position="10,10" size="280,20" />
- <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 name="infoBar" position="0,380" size="720,151" title="InfoBar" flags="wfNoBorder">
- <ePixmap position="0,0" size="720,151" pixmap="info-bg.png" />
-
- <widget name="ServiceName" position="69,30" size="427,26" valign="center" font="Arial;32" />
- <widget name="CurrentTime" position="575,10" size="66,30" />
- <widget name="Event_Now" position="273,68" size="282,30" font="Arial;29" backgroundColor="#586D88" />
- <widget name="Event_Next" position="273,98" size="282,30" font="Arial;29" />
- <widget name="Event_Now_Duration" position="555,68" size="70,26" font="Arial;26" />
- <widget name="Event_Next_Duration" position="555,98" size="70,26" font="Arial;26" />
-<!-- <eLabel position="70,0" size="300,30" text=".oO skin Oo." font="Arial;20" /> -->
- </screen>
- <screen name="channelSelection" position="100,80" size="500,240" title="Channel Selection">
- <widget name="list" position="20,50" size="300,150" />
- <widget name="okbutton" position="340,50" size="140,30" />
- </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>""")
-
-# filters all elements of childNode with the specified function
-# example: nodes = elementsWithTag(childNodes, lambda x: x == "bla")
-def elementsWithTag(el, tag):
-
- # fiiixme! (works but isn't nice)
- if tag.__class__ == "".__class__:
- str = tag
- tag = lambda x: x == str
-
- for x in el:
- if x.nodeType != xml.dom.minidom.Element.nodeType:
- continue
- if tag(x.tagName):
- yield x
+class SkinError(Exception):
+ def __init__(self, message):
+ self.message = message
+
+ def __str__(self):
+ return self.message
+
+dom_skins = [ ]
+
+def loadSkin(name):
+ # read the skin
+ filename = resolveFilename(SCOPE_SKIN, name)
+ mpath = path.dirname(filename) + "/"
+ dom_skins.append((mpath, xml.dom.minidom.parse(filename)))
+
+# we do our best to always select the "right" value
+# skins are loaded in order of priority: skin with
+# highest priority is loaded last, usually the user-provided
+# skin.
+
+# currently, loadSingleSkinData (colors, bordersets etc.)
+# are applied one-after-each, in order of ascending priority.
+# the dom_skin will keep all screens in descending priority,
+# so the first screen found will be used.
+
+# example: loadSkin("nemesis_greenline/skin.xml")
+config.skin = ConfigSubsection()
+config.skin.primary_skin = ConfigText(default = "skin.xml")
+
+try:
+ loadSkin(config.skin.primary_skin.value)
+except (SkinError, IOError, AssertionError), err:
+ print "SKIN ERROR:", err
+ print "defaulting to standard skin..."
+ loadSkin('skin.xml')
+loadSkin('skin_default.xml')