add language selection
[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.execing = False
19                 
20                 # in order to support screens *without* a help,
21                 # we need the list in every screen. how ironic.
22                 self.helpList = [ ]
23                 
24         def execBegin(self):
25                 self.active_components = [ ]
26                 for x in self.onExecBegin:
27                         x()
28                         if self.session.currentDialog != self:
29                                 return
30
31 #               assert self.session == None, "a screen can only exec one per time"
32 #               self.session = session
33
34                 for (name, val) in self.items():
35                         val.execBegin()
36                         if self.session.currentDialog != self:
37                                 return
38                         self.active_components.append(val)
39
40                 self.execing = True
41         
42                 for x in self.onShown:
43                         x()
44         
45         def execEnd(self):
46 #               for (name, val) in self.items():
47                 for val in self.active_components:
48                         val.execEnd()
49                 del self.active_components
50 #               assert self.session != None, "execEnd on non-execing screen!"
51 #               self.session = None
52                 self.execing = False
53         
54         # never call this directly - it will be called from the session!
55         def doClose(self):
56                 for x in self.onClose:
57                         x()
58                 
59                 # fixup circular references
60                 del self.helpList
61                 GUISkin.close(self)
62                 
63                 del self.session
64                 for (name, val) in self.items():
65                         del self[name]
66         
67         def close(self, *retval):
68                 self.session.close(*retval)
69
70         def setFocus(self, o):
71                 self.instance.setFocus(o.instance)