From d26dbdee8fb2a5ca6fa87878d9daffaf7d3575a8 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 3 Mar 2006 19:45:25 +0000 Subject: [PATCH] split out dialogs into skin_default.xml --- data/skin.xml | 427 +++++--------------------------------------------- data/skin_default.xml | 354 +++++++++++++++++++++++++++++++++++++++++ skin.py | 24 ++- 3 files changed, 408 insertions(+), 397 deletions(-) create mode 100644 data/skin_default.xml diff --git a/data/skin.xml b/data/skin.xml index 099a662..38d6fa3 100644 --- a/data/skin.xml +++ b/data/skin.xml @@ -1,192 +1,42 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -248,205 +98,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -# this should be factored out into some helper code, but currently demonstrates 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] + 50, textsize[1] + 50) -count = len(self.list) -if count > 6: - count = 6 -offset = 30 * count -wsizex = textsize[0] + 60 -wsizey = textsize[1] + offset -if (400 > wsizex): - wsizex = 400 -wsize = (wsizex, wsizey) - - -# resize -self.instance.resize(eSize(*wsize)) - -# resize label -self["text"].instance.resize(eSize(*textsize)) - -# move list -listsize = (wsizex, 30 * len(self.list)) -self["list"].instance.move(ePoint(0, textsize[1])) -self["list"].instance.resize(eSize(*listsize)) - -# center window -newwidth = wsize[0] -self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) - - - - - - - - - - - - - - - - - - - - - - - - - - -# this should be factored out into some helper code, but currently demonstrates 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] + 50, textsize[1] + 50) -offset = 0 -if self.type == self.TYPE_YESNO: - offset = 60 -wsizex = textsize[0] + 60 -wsizey = textsize[1] + offset -if (280 > wsizex): - wsizex = 280 -wsize = (wsizex, wsizey) - - -# resize -self.instance.resize(eSize(*wsize)) - -# resize label -self["text"].instance.resize(eSize(*textsize)) - -# move list -listsize = (wsizex, 50) -self["list"].instance.move(ePoint(0, textsize[1])) -self["list"].instance.resize(eSize(*listsize)) - -# center window -newwidth = wsize[0] -self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) - - - + diff --git a/data/skin_default.xml b/data/skin_default.xml new file mode 100644 index 0000000..7bdcdd9 --- /dev/null +++ b/data/skin_default.xml @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# this should be factored out into some helper code, but currently demonstrates 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] + 50, textsize[1] + 50) +count = len(self.list) +if count > 6: + count = 6 +offset = 30 * count +wsizex = textsize[0] + 60 +wsizey = textsize[1] + offset +if (400 > wsizex): + wsizex = 400 +wsize = (wsizex, wsizey) + + +# resize +self.instance.resize(eSize(*wsize)) + +# resize label +self["text"].instance.resize(eSize(*textsize)) + +# move list +listsize = (wsizex, 30 * len(self.list)) +self["list"].instance.move(ePoint(0, textsize[1])) +self["list"].instance.resize(eSize(*listsize)) + +# center window +newwidth = wsize[0] +self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) + + + + + + + + + + + + + + + + + + + + + + + + + + +# this should be factored out into some helper code, but currently demonstrates 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] + 50, textsize[1] + 50) +offset = 0 +if self.type == self.TYPE_YESNO: + offset = 60 +wsizex = textsize[0] + 60 +wsizey = textsize[1] + offset +if (280 > wsizex): + wsizex = 280 +wsize = (wsizex, wsizey) + + +# resize +self.instance.resize(eSize(*wsize)) + +# resize label +self["text"].instance.resize(eSize(*textsize)) + +# move list +listsize = (wsizex, 50) +self["list"].instance.move(ePoint(0, textsize[1])) +self["list"].instance.resize(eSize(*listsize)) + +# center window +newwidth = wsize[0] +self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y())) + + + \ No newline at end of file diff --git a/skin.py b/skin.py index 3016016..a4d43f2 100644 --- a/skin.py +++ b/skin.py @@ -17,10 +17,8 @@ def dump(x, i=0): from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE # read the skin -skinfile = file(resolveFilename(SCOPE_SKIN, 'skin.xml'), 'r') -dom = xml.dom.minidom.parseString(skinfile.read()) -skinfile.close() - +dom_skin = xml.dom.minidom.parse(resolveFilename(SCOPE_SKIN, 'skin.xml')) +dom_skin_default = xml.dom.minidom.parse(resolveFilename(SCOPE_SKIN, 'skin_default.xml')) def parsePosition(str): x, y = str.split(',') @@ -155,7 +153,7 @@ def applyAllAttributes(guiObject, desktop, attributes): def loadSkin(desktop): print "loading skin..." - skin = dom.childNodes[0] + skin = dom_skin.childNodes[0] assert skin.tagName == "skin", "root element in skin must be 'skin'!" for c in elementsWithTag(skin.childNodes, "colors"): @@ -203,14 +201,24 @@ def readSkin(screen, skin, name, desktop): myscreen = None # first, find the corresponding screen element - skin = dom.childNodes[0] + skin = dom_skin.childNodes[0] + skin_default = dom_skin_default.childNodes[0] for x in elementsWithTag(skin.childNodes, "screen"): if x.getAttribute('name') == name: myscreen = x - del skin + break + + # if not found, check default skin + if myscreen is None: + for x in elementsWithTag(skin_default.childNodes, "screen"): + if x.getAttribute('name') == name: + myscreen = x + break + + del skin, skin_default - # try embedded skin + # otherwise try embedded skin myscreen = myscreen or getattr(screen, "parsedSkin", None) # try uncompiled embedded skin -- 2.7.4