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):
18 self.skinName = self.__class__.__name__
19 self.session = session
21 GUISkin.__init__(self)
24 self.onFirstExecBegin = [ ]
25 self.onExecBegin = [ ]
34 # already shown is false until the screen is really shown (after creation)
35 self.already_shown = False
39 # in order to support screens *without* a help,
40 # we need the list in every screen. how ironic.
43 self.close_on_next_exec = None
45 # stand alone screens (for example web screens)
46 # don't care about having or not having focus.
47 self.stand_alone = False
50 self.active_components = [ ]
51 if self.close_on_next_exec is not None:
52 tmp = self.close_on_next_exec
53 self.close_on_next_exec = None
57 single = self.onFirstExecBegin
58 self.onFirstExecBegin = []
59 for x in self.onExecBegin + single:
61 if not self.stand_alone and self.session.current_dialog != self:
64 # assert self.session == None, "a screen can only exec once per time"
65 # self.session = session
67 for val in self.values() + self.renderer:
69 if not self.stand_alone and self.session.current_dialog != self:
71 self.active_components.append(val)
75 for x in self.onShown:
79 active_components = self.active_components
80 # for (name, val) in self.items():
81 self.active_components = None
82 for val in active_components:
84 # assert self.session != None, "execEnd on non-execing screen!"
88 # never call this directly - it will be called from the session!
91 for x in self.onClose:
94 # fixup circular references
98 # first disconnect all render from their sources.
99 # we might split this out into a "unskin"-call,
100 # but currently we destroy the screen afterwards
102 for val in self.renderer:
103 val.disconnectAll() # disconnected converter/sources and probably destroy them. Sources will not be destroyed.
106 for (name, val) in self.items():
112 # really delete all elements now
113 self.__dict__.clear()
115 def close(self, *retval):
117 self.close_on_next_exec = retval
119 self.session.close(self, *retval)
121 def setFocus(self, o):
122 self.instance.setFocus(o.instance)
125 if (self.shown and self.already_shown) or not self.instance:
128 self.already_shown = True
130 for x in self.onShow:
132 for val in self.values() + self.renderer:
133 if isinstance(val, GUIComponent) or isinstance(val, Source):
137 if not self.shown or not self.instance:
141 for x in self.onHide:
143 for val in self.values() + self.renderer:
144 if isinstance(val, GUIComponent) or isinstance(val, Source):
148 return str(type(self))
150 def getRelatedScreen(self, name):
151 if name == "session":
152 return self.session.screen
153 elif name == "parent":
155 elif name == "global":
156 return self.global_screen