b7cfb430bf7eff2d8f14321beb23a54b84c66ca4
[vuplus_dvbapp] / lib / python / Components / GUISkin.py
1 from GUIComponent import GUIComponent
2 from skin import applyAllAttributes
3 from Tools.CList import CList
4 from Sources.Source import Source
5
6 class GUISkin:
7         __module__ = __name__
8
9         def __init__(self):
10                 self.onLayoutFinish = [ ]
11                 self.summaries = CList()
12
13         def createGUIScreen(self, parent, desktop):
14                 for val in self.renderer:
15                         if isinstance(val, GUIComponent):
16                                 val.GUIcreate(parent)
17                                 if not val.applySkin(desktop):
18                                         print "warning, skin is missing renderer", val, "in", self
19
20                 for key in self:
21                         val = self[key]
22                         if isinstance(val, GUIComponent):
23                                 val.GUIcreate(parent)
24                                 if not val.applySkin(desktop):
25                                         print "warning, skin is missing element", key, "in", self
26
27                 for w in self.additionalWidgets:
28                         w.instance = w.widget(parent)
29                         # w.instance.thisown = 0
30                         applyAllAttributes(w.instance, desktop, w.skinAttributes)
31
32                 for f in self.onLayoutFinish:
33                         if type(f) is not type(self.close): # is this the best way to do this?
34                                 exec(f) in globals(), locals()
35                         else:
36                                 f()
37
38         def deleteGUIScreen(self):
39                 seenFakeSource = False
40                 for (name, val) in self.items():
41                         if name == "fake" and isinstance(val, Source):
42                                 seenFakeSource = True
43                         if isinstance(val, GUIComponent):
44                                 val.GUIdelete()
45                 if seenFakeSource:
46                         del self["fake"]
47
48         def close(self):
49                 self.deleteGUIScreen()
50
51         def createSummary(self):
52                 return None
53
54         def addSummary(self, summary):
55                 self.summaries.append(summary)
56
57         def removeSummary(self, summary):
58                 self.summaries.remove(summary)
59
60         def setTitle(self, title):
61                 self.instance.setTitle(title)
62                 self.title = title
63                 self.summaries.setTitle(title)