small fixes for PIG
[enigma2.git] / 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                         print "DEL FAKE SOURCE"
47                         del self["fake"]
48
49         def close(self):
50                 self.deleteGUIScreen()
51
52         def createSummary(self):
53                 return None
54
55         def addSummary(self, summary):
56                 self.summaries.append(summary)
57
58         def removeSummary(self, summary):
59                 self.summaries.remove(summary)
60
61         def setTitle(self, title):
62                 self.instance.setTitle(title)
63                 self.title = title
64                 self.summaries.setTitle(title)