small cleanup
[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
12         def createGUIScreen(self, parent, desktop):
13                 for val in self.renderer:
14                         if isinstance(val, GUIComponent):
15                                 val.GUIcreate(parent)
16                                 if not val.applySkin(desktop):
17                                         print "warning, skin is missing renderer", val, "in", self
18
19                 for key in self:
20                         val = self[key]
21                         if isinstance(val, GUIComponent):
22                                 val.GUIcreate(parent)
23                                 if not val.applySkin(desktop):
24                                         print "warning, skin is missing element", key, "in", self
25
26                 for w in self.additionalWidgets:
27                         w.instance = w.widget(parent)
28                         # w.instance.thisown = 0
29                         applyAllAttributes(w.instance, desktop, w.skinAttributes)
30
31                 for f in self.onLayoutFinish:
32                         if type(f) is not type(self.close): # is this the best way to do this?
33                                 exec(f) in globals(), locals()
34                         else:
35                                 f()
36
37         def deleteGUIScreen(self):
38                 for (name, val) in self.items():
39                         if isinstance(val, GUIComponent):
40                                 val.GUIdelete()
41
42         def close(self):
43                 self.deleteGUIScreen()
44
45         def createSummary(self):
46                 return None
47
48         def addSummary(self, summary):
49                 self.summaries.append(summary)
50
51         def removeSummary(self, summary):
52                 self.summaries.remove(summary)
53
54         def setTitle(self, title):
55                 self.instance.setTitle(title)
56                 self.title = title
57                 self.summaries.setTitle(title)