3 from xml.dom import EMPTY_NAMESPACE
11 for n in x.childNodes:
16 dom = xml.dom.minidom.parseString(
20 <color name="white" value="#ffffff" />
21 <color name="black" value="#000000" />
22 <color name="dark" value="#294a6b" />
24 <color name="red" value="#ff0000" />
25 <color name="green" value="#00ff00" />
26 <color name="blue" value="#0000ff" />
27 <color name="yellow" value="#c0c000" />
29 <windowstyle type="skinned">
30 <color name="Background" color="#4075a7" />
31 <color name="LabelForeground" color="#ffffff" />
32 <color name="ListboxBackground" color="#4075a7" />
33 <color name="ListboxForeground" color="#ffffff" />
34 <color name="ListboxSelectedBackground" color="#80ff80" />
35 <color name="ListboxSelectedForeground" color="#ffffff" />
36 <color name="ListboxMarkedBackground" color="#ff0000" />
37 <color name="ListboxMarkedForeground" color="#ffffff" />
38 <borderset name="bsWindow">
39 <pixmap pos="bpTopLeft" filename="data/b_w_tl.png" />
40 <pixmap pos="bpTop" filename="data/b_w_t.png" />
41 <pixmap pos="bpTopRight" filename="data/b_w_tr.png" />
42 <pixmap pos="bpLeft" filename="data/b_w_l.png" />
43 <pixmap pos="bpRight" filename="data/b_w_r.png" />
44 <pixmap pos="bpBottomLeft" filename="data/b_w_bl.png" />
45 <pixmap pos="bpBottom" filename="data/b_w_b.png" />
46 <pixmap pos="bpBottomRight" filename="data/b_w_br.png" />
49 <screen name="Menu" position="300,100" size="300,300" title="real main menu">
50 <!-- <widget name="okbutton" position="10,190" size="280,50" font="Arial;20" valign="center" halign="center" />-->
51 <widget name="title" position="10,10" size="280,20" />
52 <widget name="menu" position="10,30" size="280,200" />
54 <screen name="ScartLoopThrough" position="0,0" size="720,576">
56 <screen name="ConfigMenu" position="300,100" size="300,300" title="real main menu">
57 <widget name="txt_var_1" position="20,20" size="100,20" />
58 <widget name="btn_var_1" position="110,20" size="200,20" />
59 <widget name="txt_var_2" position="20,60" size="100,20" />
60 <widget name="btn_var_2" position="110,60" size="200,20" />
62 <screen name="configOSD" position="140,125" size="460,350" title="OSD Settings">
63 <widget name="okbutton" position="20,245" size="205,40" />
64 <widget name="txt_alpha" position="20,20" size="110,20" />
65 <widget name="sld_alpha" position="150,20" size="290,20" />
66 <widget name="txt_brightness" position="20,60" size="120,20" />
67 <widget name="sld_brightness" position="150,20" size="290,20" />
68 <widget name="txt_gamma" position="20,100" size="120,20" />
69 <widget name="sld_gamma" position="150,100" size="290,20" />
71 <screen name="configTest" position="300,100" size="300,300" title="config menu">
72 <widget name="config" position="10,30" size="280,140" />
74 <screen name="clockDisplay" position="300,100" size="300,300">
75 <widget name="okbutton" position="10,10" size="280,40" />
76 <widget name="title" position="10,120" size="280,50" />
77 <widget name="theClock" position="10,60" size="280,50" />
79 <screen name="InfoBar" position="0,380" size="720,151" title="InfoBar" flags="wfNoBorder">
80 <ePixmap position="0,0" size="720,151" pixmap="data/info-bg.png" />
82 <widget name="ServiceName" position="69,30" size="427,26" valign="center" font="Arial;32" backgroundColor="#101258" />
83 <widget name="CurrentTime" position="575,10" size="66,30" backgroundColor="dark" font="Arial;16" />
84 <widget name="Event_Now" position="273,68" size="282,30" font="Arial;29" backgroundColor="dark" />
85 <widget name="Event_Next" position="273,98" size="282,30" font="Arial;29" backgroundColor="dark" />
86 <widget name="Event_Now_Duration" position="555,68" size="70,26" font="Arial;26" backgroundColor="dark" />
87 <widget name="Event_Next_Duration" position="555,98" size="70,26" font="Arial;26" backgroundColor="dark" />
88 <!-- <eLabel position="70,0" size="300,30" text=".oO skin Oo." font="Arial;20" /> -->
90 <screen name="ChannelSelection" position="90,100" size="560,420" title="Channel Selection">
91 <widget name="list" position="0,50" size="560,340" />
92 <!-- <widget name="okbutton" position="340,50" size="140,30" />-->
93 <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" />
94 <widget name="key_green" position="140,0" size="140,40" backgroundColor="green" />
95 <widget name="key_yellow" position="280,0" size="140,40" backgroundColor="yellow" />
96 <widget name="key_blue" position="420,0" size="140,40" backgroundColor="blue" />
98 <screen name="ServiceScan" position="150,100" size="300,200" title="Service Scan">
99 <widget name="scan_progress" position="10,10" size="280,50" />
100 <widget name="scan_state" position="10,60" size="280,30" />
104 # filters all elements of childNode with the specified function
105 # example: nodes = elementsWithTag(childNodes, lambda x: x == "bla")
106 def elementsWithTag(el, tag):
108 # fiiixme! (works but isn't nice)
109 if tag.__class__ == "".__class__:
111 tag = lambda x: x == str
114 if x.nodeType != xml.dom.minidom.Element.nodeType:
119 def parsePosition(str):
120 x, y = str.split(',')
121 return ePoint(int(x), int(y))
124 x, y = str.split(',')
125 return eSize(int(x), int(y))
128 name, size = str.split(';')
129 return gFont(name, int(size))
134 return colorNames[str]
136 raise ("color '%s' must be #aarrggbb or valid named color" % (str))
137 return gRGB(int(str[1:], 0x10))
139 def applyAttributes(guiObject, node, desktop):
140 # walk all attributes
141 for p in range(node.attributes.length):
142 a = node.attributes.item(p)
144 # convert to string (was: unicode)
146 # TODO: proper UTF8 translation?! (for value)
147 # TODO: localization? as in e1?
152 if attrib == 'position':
153 guiObject.move(parsePosition(value))
154 elif attrib == 'size':
155 guiObject.resize(parseSize(value))
156 elif attrib == 'title':
157 guiObject.setTitle(value)
158 elif attrib == 'text':
159 guiObject.setText(value)
160 elif attrib == 'font':
161 guiObject.setFont(parseFont(value))
162 elif attrib == "pixmap":
164 if loadPNG(ptr, value):
165 raise "loading PNG failed!"
167 ptr = ptr.__deref__()
169 desktop.makeCompatiblePixmap(ptr)
170 guiObject.setPixmap(ptr)
171 # guiObject.setPixmapFromFile(value)
172 elif attrib == "valign":
175 { "top": guiObject.alignTop,
176 "center": guiObject.alignCenter,
177 "bottom": guiObject.alignBottom
180 print "valign must be either top, center or bottom!"
181 elif attrib == "halign":
184 { "left": guiObject.alignLeft,
185 "center": guiObject.alignCenter,
186 "right": guiObject.alignRight,
187 "block": guiObject.alignBlock
190 print "halign must be either left, center, right or block!"
191 elif attrib == "flags":
192 flags = value.split(',')
195 fv = eWindow.__dict__[f]
196 guiObject.setFlag(fv)
198 print "illegal flag %s!" % f
199 elif attrib == "backgroundColor":
200 guiObject.setBackgroundColor(parseColor(value))
201 elif attrib != 'name':
202 print "unsupported attribute " + attrib + "=" + value
203 except AttributeError:
204 print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
207 print "loading skin..."
215 skin = dom.childNodes[0]
216 assert skin.tagName == "skin", "root element in skin must be 'skin'!"
218 for c in elementsWithTag(skin.childNodes, "colors"):
219 for color in elementsWithTag(c.childNodes, "color"):
220 name = str(color.getAttribute("name"))
221 color = str(color.getAttribute("value"))
224 raise ("need color and name, got %s %s" % (name, color))
226 colorNames[name] = parseColor(color)
228 for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"):
229 style = eWindowStyleSkinned()
231 for borderset in elementsWithTag(windowstyle.childNodes, "borderset"):
232 bsName = str(borderset.getAttribute("name"))
233 for pixmap in elementsWithTag(borderset.childNodes, "pixmap"):
234 bpName = str(pixmap.getAttribute("pos"))
235 filename = str(pixmap.getAttribute("filename"))
237 style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], getPNG(filename))
239 for color in elementsWithTag(windowstyle.childNodes, "color"):
240 type = str(color.getAttribute("name"))
241 color = parseColor(color.getAttribute("color"))
244 style.setColor(eWindowStyleSkinned.__dict__["col" + type], color)
246 raise ("Unknown color %s" % (type))
248 x = eWindowStyleManagerPtr()
249 eWindowStyleManager.getInstance(x)
252 def applyGUIskin(screen, skin, name, desktop):
255 # first, find the corresponding screen element
256 skin = dom.childNodes[0]
258 for x in elementsWithTag(skin.childNodes, "screen"):
259 if x.getAttribute('name') == name:
263 assert myscreen != None, "no skin for screen '" + name + "' found!"
265 applyAttributes(screen.instance, myscreen, desktop)
267 # now walk all widgets
268 for widget in elementsWithTag(myscreen.childNodes, "widget"):
269 wname = widget.getAttribute('name')
271 print "widget has no name!"
274 # get corresponding gui object
276 guiObject = screen[wname].instance
278 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
280 applyAttributes(guiObject, widget, desktop)
282 # now walk additional objects
283 for widget in elementsWithTag(myscreen.childNodes, lambda x: x != "widget"):
284 if widget.tagName == "eLabel":
285 guiObject = eLabel(screen.instance)
286 elif widget.tagName == "ePixmap":
287 guiObject = ePixmap(screen.instance)
289 raise str("unsupported stuff : %s" % widget.tagName)
291 applyAttributes(guiObject, widget, desktop )
292 guiObject.thisown = 0