enigma2: add patch to fix global skin variable backport
[opendreambox.git] / meta-opendreambox / recipes-dreambox / enigma2 / files / 0001-skin.py-add-global-skin-variables-define-them-like-t.patch
1 From 464d3cbbd89a5e007fe77ec22f3bb81574be951b Mon Sep 17 00:00:00 2001
2 From: reichi <reichi@opendreambox.org>
3 Date: Wed, 5 Jun 2019 10:21:39 +0200
4 Subject: [PATCH] skin.py: add "global skin variables" define them like this: 
5  <globals>              <value name="infobar_pos" value="0,540" /> 
6  </globals>
7
8 and then use them like this:
9         <screen name="InfoBar" position="{{infobar_pos}}" size="1280,150" backgroundColor="transparent" flags="wfNoBorder">
10
11 Change-Id: I543ed2f2a9392e1aec0177e78c03d567cc2383c9
12 (cherry picked from commit 469a678e29418c14fe1437e217fd661b734da9ef)
13 ---
14  usr/lib/enigma2/python/skin.py | 27 +++++++++++++++++++++++----
15  1 file changed, 23 insertions(+), 4 deletions(-)
16
17 diff --git a/usr/lib/enigma2/python/skin.py b/usr/lib/enigma2/python/skin.py
18 index f2bcc4c..b9798c8 100644
19 --- a/usr/lib/enigma2/python/skin.py
20 +++ b/usr/lib/enigma2/python/skin.py
21 @@ -13,9 +13,12 @@ from Tools.Import import my_import
22  from Tools.LoadPixmap import LoadPixmap
23  from Tools.Log import Log
24  
25 +from re import search as re_search
26 +
27  HAS_SKIN_USER_DISPLAY = True
28  
29  colorNames = dict()
30 +skinGlobals = dict()
31  
32  def dump(x, i=0):
33         print " " * i + str(x)
34 @@ -125,8 +128,18 @@ def getParentSize(desktop, guiObject):
35                 parent_size = desktop.size()
36         return parent_size
37  
38 -def parsePosition(str, scale, desktop = None, guiObject = None):
39 -       p = str.split(',')
40 +def translateVariable(value):
41 +       match = re_search("{{(.*)}}", value)
42 +       if match and len(match.groups()) == 1:
43 +               key = match.group(1)
44 +               val = skinGlobals.get(key, value)
45 +               Log.i("%s => %s" %(key, val))
46 +               return val
47 +       return value
48 +
49 +def parsePosition(value, scale, desktop = None, guiObject = None):
50 +       value = translateVariable(value)
51 +       p = value.split(',')
52         x, y = p[0], p[1]
53         wsize = 1, 1
54         ssize = 1, 1
55 @@ -150,8 +163,9 @@ def parsePosition(str, scale, desktop = None, guiObject = None):
56  
57         return ePoint(x, y)
58  
59 -def parseSize(str, scale, desktop = None, guiObject = None):
60 -       x, y = str.split(',')
61 +def parseSize(value, scale, desktop = None, guiObject = None):
62 +       value = translateVariable(value)
63 +       x, y = value.split(',')
64         if guiObject is not None:
65                 parent_size = getParentSize(desktop, guiObject)
66                 #width aliases
67 @@ -643,6 +657,11 @@ def loadSingleSkinData(desktop, skin, path_prefix):
68                 x = eWindowStyleManager.getInstance()
69                 x.setStyle(id, style)
70  
71 +       for g in skin.findall("globals"):
72 +               for value in g.findall("value"):
73 +                       Log.i("Global skin value : %s" %(value.attrib,))
74 +                       skinGlobals[value.attrib["name"]] = value.attrib["value"]
75 +
76         for components in skin.findall("components"):
77                 for component in components.findall("component"):
78                         componentSizes.apply(component.attrib)
79 -- 
80 2.1.4
81