fix selection of subtitle
[enigma2.git] / lib / python / Screens / Screen.py
1 from Components.HTMLSkin import *
2 from Components.GUISkin import *
3
4 import sys
5
6 class Screen(dict, HTMLSkin, GUISkin):
7         """ bla """
8
9         def __init__(self, session):
10                 self.skinName = self.__class__.__name__
11                 self.session = session
12                 GUISkin.__init__(self)
13                 
14                 self.onClose = [ ]
15                 self.onExecBegin = [ ]
16                 self.onShown = [ ]
17                 
18                 self.onShow = [ ]
19                 self.onHide = [ ]
20                 
21                 self.execing = False
22                 self.shown = False
23                 
24                 # in order to support screens *without* a help,
25                 # we need the list in every screen. how ironic.
26                 self.helpList = [ ]
27                 
28         def execBegin(self):
29                 self.active_components = [ ]
30                 for x in self.onExecBegin:
31                         x()
32                         if self.session.current_dialog != self:
33                                 return
34
35 #               assert self.session == None, "a screen can only exec once per time"
36 #               self.session = session
37
38                 for (name, val) in self.items():
39                         val.execBegin()
40                         if self.session.current_dialog != self:
41                                 return
42                         self.active_components.append(val)
43
44                 self.execing = True
45         
46                 for x in self.onShown:
47                         x()
48         
49         def execEnd(self):
50 #               for (name, val) in self.items():
51                 for val in self.active_components:
52                         val.execEnd()
53                 del self.active_components
54 #               assert self.session != None, "execEnd on non-execing screen!"
55 #               self.session = None
56                 self.execing = False
57         
58         # never call this directly - it will be called from the session!
59         def doClose(self):
60                 self.hide()
61                 for x in self.onClose:
62                         x()
63                 
64                 # fixup circular references
65                 del self.helpList
66                 GUISkin.close(self)
67                 
68                 del self.session
69                 for (name, val) in self.items():
70                         val.destroy()
71                         del self[name]
72                 
73                 # really delete all elements now
74                 self.__dict__.clear()
75         
76         def close(self, *retval):
77                 self.session.close(self, *retval)
78
79         def setFocus(self, o):
80                 self.instance.setFocus(o.instance)
81
82         def show(self):
83                 if self.shown:
84                         return
85                 self.shown = True
86                 self.instance.show()
87                 for x in self.onShow:
88                         x()
89                 for (name, val) in self.items():
90                         if isinstance(val, GUIComponent):
91                                 val.onShow()
92
93         def hide(self):
94                 if not self.shown:
95                         return
96                 self.shown = False
97                 self.instance.hide()
98                 for x in self.onHide:
99                         x()
100                 for (name, val) in self.items():
101                         if isinstance(val, GUIComponent):
102                                 val.onHide()