add building of NFIFlash plugin, but display only for DM8000
[enigma2.git] / lib / python / Components / GUISkin.py
1 from GUIComponent import GUIComponent
2 from skin import applyAllAttributes
3 from Tools.CList import CList
4
5 class GUISkin:
6         __module__ = __name__
7
8         def __init__(self):
9                 self.onLayoutFinish = [ ]
10                 self.summaries = CList()
11                 self.instance = None
12                 self.desktop = None
13
14         def createGUIScreen(self, parent, desktop, updateonly = False):
15                 for val in self.renderer:
16                         if isinstance(val, GUIComponent):
17                                 if not updateonly:
18                                         val.GUIcreate(parent)
19                                 if not val.applySkin(desktop, self):
20                                         print "warning, skin is missing renderer", val, "in", self
21
22                 for key in self:
23                         val = self[key]
24                         if isinstance(val, GUIComponent):
25                                 if not updateonly:
26                                         val.GUIcreate(parent)
27                                 depr = val.deprecationInfo
28                                 if val.applySkin(desktop, self):
29                                         if depr:
30                                                 print "WARNING: OBSOLETE COMPONENT '%s' USED IN SKIN. USE '%s' INSTEAD!" % (key, depr[0])
31                                                 print "OBSOLETE COMPONENT WILL BE REMOVED %s, PLEASE UPDATE!" % (depr[1])
32                                 elif not depr:
33                                         print "warning, skin is missing element", key, "in", self
34
35                 for w in self.additionalWidgets:
36                         if not updateonly:
37                                 w.instance = w.widget(parent)
38                                 # w.instance.thisown = 0
39                         applyAllAttributes(w.instance, desktop, w.skinAttributes, self.scale)
40
41                 for f in self.onLayoutFinish:
42                         if type(f) is not type(self.close): # is this the best way to do this?
43                                 exec(f) in globals(), locals()
44                         else:
45                                 f()
46
47         def deleteGUIScreen(self):
48                 for (name, val) in self.items():
49                         if isinstance(val, GUIComponent):
50                                 val.GUIdelete()
51
52         def close(self):
53                 self.deleteGUIScreen()
54
55         def createSummary(self):
56                 return None
57
58         def addSummary(self, summary):
59                 self.summaries.append(summary)
60
61         def removeSummary(self, summary):
62                 self.summaries.remove(summary)
63
64         def setTitle(self, title):
65                 self.instance.setTitle(title)
66                 self.title = title
67                 self.summaries.setTitle(title)
68
69         def setDesktop(self, desktop):
70                 self.desktop = desktop
71
72         def applySkin(self):
73                 z = 0
74                 title = ""
75                 baseres = (720, 576) # FIXME: a skin might have set another resolution, which should be the base res
76                 for (key, value) in self.skinAttributes:
77                         if key == "zPosition":
78                                 z = int(value)
79                         elif key == "title":
80                                 title = value
81                         elif key == "baseResolution":
82                                 baseres = tuple([int(x) for x in value.split(',')])
83                 self.scale = ((baseres[0], baseres[0]), (baseres[1], baseres[1]))
84
85                 if not self.instance:
86                         from enigma import eWindow
87                         self.instance = eWindow(self.desktop, z)
88                 self.title = title
89                 applyAllAttributes(self.instance, self.desktop, self.skinAttributes, self.scale)
90                 self.createGUIScreen(self.instance, self.desktop)