diff browser_side/panels.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 8213e22c1120
children f2ae8e170c49
line wrap: on
line diff
--- a/browser_side/panels.py	Sun Mar 03 23:26:09 2013 +0100
+++ b/browser_side/panels.py	Sun Mar 03 23:30:25 2013 +0100
@@ -122,8 +122,8 @@
         _flextable = self.getParent()
         _widgetspanel = _flextable.getParent().getParent()
         row_idx, cell_idx = self._getCellAndRow(_flextable, event)
-        if self.host.selected == self:
-            self.host.select(None)
+        if self.host.getSelected == self:
+            self.host.setSelected(None)
         _widgetspanel.changeWidget(row_idx, cell_idx, _new_panel)
         """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable))
         _width = 90/float(len(_unempty_panels) or 1)
@@ -183,7 +183,7 @@
         return current
     
     def onClick(self, sender):
-        self.host.select(self)
+        self.host.setSelected(self)
 
     def onClose(self, sender):
         """ Called when the close button is pushed """
@@ -439,6 +439,7 @@
         Return a tuple (target_type, target info)"""
         type = None
         target = None
+        selected = self.host.getSelected()
         if txt.startswith('@@: '):
             type = "PUBLIC"
         elif txt.startswith('@'):
@@ -450,13 +451,13 @@
                 target = txt[1:_end] #only one target group is managed for the moment
                 if not target in self.host.contact_panel.getGroups():
                     target = None
-        elif self.host.selected == None:
+        elif selected == None:
             type = "STATUS"
-        elif isinstance(self.host.selected, ChatPanel):
+        elif isinstance(selected, ChatPanel):
             type = "ONE2ONE"
-            target = str(self.host.selected.target)
+            target = str(selected.target)
         else:
-            print "Unknown selected host:",self.host.selected
+            print "Unknown selected host:",selected
             type = "UNKNOWN"
         return (type, target)
 
@@ -479,15 +480,16 @@
 
         self._timer.schedule(2000)
 
+        selected = self.host.getSelected()
         #if keycode == KEY_ENTER and not self.visible:
         if keycode == KEY_ENTER:
             if _txt:
                 if _txt.startswith('@'):
                     self.host.bridge.call('sendMblog', None, self.getText())
-                elif self.host.selected == None:
+                elif selected == None:
                     self.host.bridge.call('setStatus', None, _txt)
-                elif isinstance(self.host.selected, ChatPanel):
-                    _chat = self.host.selected
+                elif isinstance(selected, ChatPanel):
+                    _chat = selected
                     mess_type = "groupchat" if _chat.type=='group' else "chat"
                     self.host.bridge.call('sendMessage', None, str(_chat.target), _txt, '', mess_type)
             self.setText('')
@@ -650,7 +652,7 @@
 
     def onClick(self, sender):
         #As status is the default target of uniBar, we don't want to select anything if click on it
-        self.host.select(None)
+        self.host.setSelected(None)
 
 class ChatText(HTMLPanel):
 
@@ -867,6 +869,7 @@
         self.setSize('100%', '100%')
         self.host = host
         self.locked = locked #if True: tab will not be removed when there are no more widgets inside
+        self.selected = None
         self.flextable = FlexTable()
         self.flextable.setSize('100%','100%')
         self.setWidget(self.flextable)
@@ -1029,6 +1032,10 @@
         self.addStyleName('mainTabPanel')
         Window.addWindowResizeListener(self)
 
+    def getCurrentPanel(self):
+        """ Get the panel of the currently selected tab """
+        return self.deck.visibleWidget
+
     def onWindowResized(self, width, height):
         tab_panel_elt = self.getElement()
         _elts = doc().getElementsByClassName('gwt-TabBar')