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):
16 def __init__(self, session, parent = None):
17 self.skinName = self.__class__.__name__
18 self.session = session
20 GUISkin.__init__(self)
23 self.onFirstExecBegin = [ ]
24 self.onExecBegin = [ ]
33 # already shown is false until the screen is really shown (after creation)
34 self.already_shown = False
38 # in order to support screens *without* a help,
39 # we need the list in every screen. how ironic.
42 self.close_on_next_exec = None
44 # stand alone screens (for example web screens)
45 # don't care about having or not having focus.
46 self.stand_alone = False
49 self.active_components = [ ]
50 if self.close_on_next_exec is not None:
51 tmp = self.close_on_next_exec
52 self.close_on_next_exec = None
56 single = self.onFirstExecBegin
57 self.onFirstExecBegin = []
58 for x in self.onExecBegin + single:
60 if not self.stand_alone and self.session.current_dialog != self:
63 # assert self.session == None, "a screen can only exec once per time"
64 # self.session = session
66 for val in self.values() + self.renderer:
68 if not self.stand_alone and self.session.current_dialog != self:
70 self.active_components.append(val)
74 for x in self.onShown:
78 active_components = self.active_components
79 # for (name, val) in self.items():
80 self.active_components = None
81 for val in active_components:
83 # assert self.session != None, "execEnd on non-execing screen!"
87 # never call this directly - it will be called from the session!
90 for x in self.onClose:
93 # fixup circular references
97 # first disconnect all render from their sources.
98 # we might split this out into a "unskin"-call,
99 # but currently we destroy the screen afterwards
101 for val in self.renderer:
102 val.disconnectAll() # disconnected converter/sources and probably destroy them. Sources will not be destroyed.
105 for (name, val) in self.items():
111 # really delete all elements now
112 self.__dict__.clear()
114 def close(self, *retval):
116 self.close_on_next_exec = retval
118 self.session.close(self, *retval)
120 def setFocus(self, o):
121 self.instance.setFocus(o.instance)
124 if (self.shown and self.already_shown) or not self.instance:
127 self.already_shown = True
129 for x in self.onShow:
131 for val in self.values() + self.renderer:
132 if isinstance(val, GUIComponent) or isinstance(val, Source):
136 if not self.shown or not self.instance:
140 for x in self.onHide:
142 for val in self.values() + self.renderer:
143 if isinstance(val, GUIComponent) or isinstance(val, Source):
147 return str(type(self))
149 def getRelatedScreen(self, name):
150 if name == "session":
151 return self.session.screen
152 elif name == "parent":
154 elif name == "global":
155 return self.global_screen