1 from Tools.Profile import profile
3 profile("LOAD:GUISkin")
4 from Components.GUISkin import GUISkin
6 from Components.Sources.Source import Source
7 profile("LOAD:GUIComponent")
8 from Components.GUIComponent import GUIComponent
10 class Screen(dict, GUISkin):
12 False, SUSPEND_STOPS, SUSPEND_PAUSES = range(3)
17 def __init__(self, session, parent = None):
19 self.skinName = self.__class__.__name__
20 self.session = session
22 GUISkin.__init__(self)
25 self.onFirstExecBegin = [ ]
26 self.onExecBegin = [ ]
35 # already shown is false until the screen is really shown (after creation)
36 self.already_shown = False
40 # in order to support screens *without* a help,
41 # we need the list in every screen. how ironic.
44 self.close_on_next_exec = None
46 # stand alone screens (for example web screens)
47 # don't care about having or not having focus.
48 self.stand_alone = False
51 self.active_components = [ ]
52 if self.close_on_next_exec is not None:
53 tmp = self.close_on_next_exec
54 self.close_on_next_exec = None
58 single = self.onFirstExecBegin
59 self.onFirstExecBegin = []
60 for x in self.onExecBegin + single:
62 if not self.stand_alone and self.session.current_dialog != self:
65 # assert self.session == None, "a screen can only exec once per time"
66 # self.session = session
68 for val in self.values() + self.renderer:
70 if not self.stand_alone and self.session.current_dialog != self:
72 self.active_components.append(val)
76 for x in self.onShown:
80 active_components = self.active_components
81 # for (name, val) in self.items():
82 self.active_components = None
83 for val in active_components:
85 # assert self.session != None, "execEnd on non-execing screen!"
89 # never call this directly - it will be called from the session!
92 for x in self.onClose:
95 # fixup circular references
99 # first disconnect all render from their sources.
100 # we might split this out into a "unskin"-call,
101 # but currently we destroy the screen afterwards
103 for val in self.renderer:
104 val.disconnectAll() # disconnected converter/sources and probably destroy them. Sources will not be destroyed.
107 for (name, val) in self.items():
113 # really delete all elements now
114 self.__dict__.clear()
116 def close(self, *retval):
118 self.close_on_next_exec = retval
120 self.session.close(self, *retval)
122 def setFocus(self, o):
123 self.instance.setFocus(o.instance)
126 if (self.shown and self.already_shown) or not self.instance:
129 self.already_shown = True
131 for x in self.onShow:
133 for val in self.values() + self.renderer:
134 if isinstance(val, GUIComponent) or isinstance(val, Source):
138 if not self.shown or not self.instance:
142 for x in self.onHide:
144 for val in self.values() + self.renderer:
145 if isinstance(val, GUIComponent) or isinstance(val, Source):
149 return str(type(self))
151 def getRelatedScreen(self, name):
152 if name == "session":
153 return self.session.screen
154 elif name == "parent":
156 elif name == "global":
157 return self.global_screen