comparison libervia.py @ 192:cf5c83e7d515

browser side: per tab selected widget management fix bug 6
author Goffi <goffi@goffi.org>
date Sun, 03 Mar 2013 23:30:25 +0100
parents 8475a29d7214
children f2ae8e170c49
comparison
equal deleted inserted replaced
191:8213e22c1120 192:cf5c83e7d515
121 def onModuleLoad(self): 121 def onModuleLoad(self):
122 print "============ onModuleLoad ==============" 122 print "============ onModuleLoad =============="
123 self.whoami = None 123 self.whoami = None
124 self.bridge = BridgeCall() 124 self.bridge = BridgeCall()
125 self.bridge_signals = BridgeSignals(self) 125 self.bridge_signals = BridgeSignals(self)
126 self.selected = None
127 self.uni_box = None 126 self.uni_box = None
128 self.status_panel = panels.StatusPanel(self) 127 self.status_panel = panels.StatusPanel(self)
129 self.contact_panel = ContactPanel(self) 128 self.contact_panel = ContactPanel(self)
130 self.panel = panels.MainPanel(self) 129 self.panel = panels.MainPanel(self)
131 self.discuss_panel = self.panel.discuss_panel 130 self.discuss_panel = self.panel.discuss_panel
142 RootPanel().add(self.panel) 141 RootPanel().add(self.panel)
143 DOM.addEventPreview(self) 142 DOM.addEventPreview(self)
144 self.resize() 143 self.resize()
145 self._register = RegisterCall() 144 self._register = RegisterCall()
146 self._register.call('isRegistered',self._isRegisteredCB) 145 self._register.call('isRegistered',self._isRegisteredCB)
146 self.selected = property(self.getSelected, self.setSelected)
147
148 def getSelected(self):
149 wid = self.tab_panel.getCurrentPanel()
150 if not isinstance(wid, WidgetsPanel):
151 print "ERROR: Tab widget is not a WidgetsPanel, can't get selected widget"
152 return None
153 return wid.selected
154
155 def setSelected(self, widget):
156 """Define the selected widget"""
157 widgets_panel = self.tab_panel.getCurrentPanel()
158 if not isinstance(widgets_panel, WidgetsPanel):
159 return
160
161 selected = widgets_panel.selected
162
163 if selected:
164 if selected == widget:
165 return
166 selected.removeStyleName('selected_widget')
167
168 widgets_panel.selected = widget
169 if widget:
170 widgets_panel.selected.addStyleName('selected_widget')
171
172
147 173
148 def resize(self): 174 def resize(self):
149 """Resize elements""" 175 """Resize elements"""
150 Window.onResize() 176 Window.onResize()
151 177
178 204
179 def setUniBox(self, unibox): 205 def setUniBox(self, unibox):
180 """register the unibox widget""" 206 """register the unibox widget"""
181 self.uni_box = unibox 207 self.uni_box = unibox
182 self.uni_box.addKey("@@: ") 208 self.uni_box.addKey("@@: ")
183
184 def select(self, widget):
185 """Define the selected widget"""
186 if self.selected:
187 if self.selected == widget:
188 return
189 self.selected.removeStyleName('selected_widget')
190 self.selected = widget
191 if widget:
192 self.selected.addStyleName('selected_widget')
193 209
194 def addTab(self, wid, label): 210 def addTab(self, wid, label):
195 """Create a new tab and add a widget in 211 """Create a new tab and add a widget in
196 @param wid: LiberviaWidget to add 212 @param wid: LiberviaWidget to add
197 @param label: label of the tab""" 213 @param label: label of the tab"""