Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
191:8213e22c1120 | 192:cf5c83e7d515 |
---|---|
120 if not isinstance(_new_panel, LiberviaWidget): | 120 if not isinstance(_new_panel, LiberviaWidget): |
121 print ('WARNING: droping an object which is not a class of LiberviaWidget') | 121 print ('WARNING: droping an object which is not a class of LiberviaWidget') |
122 _flextable = self.getParent() | 122 _flextable = self.getParent() |
123 _widgetspanel = _flextable.getParent().getParent() | 123 _widgetspanel = _flextable.getParent().getParent() |
124 row_idx, cell_idx = self._getCellAndRow(_flextable, event) | 124 row_idx, cell_idx = self._getCellAndRow(_flextable, event) |
125 if self.host.selected == self: | 125 if self.host.getSelected == self: |
126 self.host.select(None) | 126 self.host.setSelected(None) |
127 _widgetspanel.changeWidget(row_idx, cell_idx, _new_panel) | 127 _widgetspanel.changeWidget(row_idx, cell_idx, _new_panel) |
128 """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable)) | 128 """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable)) |
129 _width = 90/float(len(_unempty_panels) or 1) | 129 _width = 90/float(len(_unempty_panels) or 1) |
130 #now we resize all the cell of the column | 130 #now we resize all the cell of the column |
131 for panel in _unempty_panels: | 131 for panel in _unempty_panels: |
181 if current is None: | 181 if current is None: |
182 print "Error: can't find WidgetsPanel" | 182 print "Error: can't find WidgetsPanel" |
183 return current | 183 return current |
184 | 184 |
185 def onClick(self, sender): | 185 def onClick(self, sender): |
186 self.host.select(self) | 186 self.host.setSelected(self) |
187 | 187 |
188 def onClose(self, sender): | 188 def onClose(self, sender): |
189 """ Called when the close button is pushed """ | 189 """ Called when the close button is pushed """ |
190 _widgetspanel = self._getWidgetsPanel() | 190 _widgetspanel = self._getWidgetsPanel() |
191 _widgetspanel.removeWidget(self) | 191 _widgetspanel.removeWidget(self) |
437 def _getTarget(self, txt): | 437 def _getTarget(self, txt): |
438 """Say who will receive the messsage | 438 """Say who will receive the messsage |
439 Return a tuple (target_type, target info)""" | 439 Return a tuple (target_type, target info)""" |
440 type = None | 440 type = None |
441 target = None | 441 target = None |
442 selected = self.host.getSelected() | |
442 if txt.startswith('@@: '): | 443 if txt.startswith('@@: '): |
443 type = "PUBLIC" | 444 type = "PUBLIC" |
444 elif txt.startswith('@'): | 445 elif txt.startswith('@'): |
445 type = "GROUP" | 446 type = "GROUP" |
446 _end = txt.find(': ') | 447 _end = txt.find(': ') |
448 type = "STATUS" | 449 type = "STATUS" |
449 else: | 450 else: |
450 target = txt[1:_end] #only one target group is managed for the moment | 451 target = txt[1:_end] #only one target group is managed for the moment |
451 if not target in self.host.contact_panel.getGroups(): | 452 if not target in self.host.contact_panel.getGroups(): |
452 target = None | 453 target = None |
453 elif self.host.selected == None: | 454 elif selected == None: |
454 type = "STATUS" | 455 type = "STATUS" |
455 elif isinstance(self.host.selected, ChatPanel): | 456 elif isinstance(selected, ChatPanel): |
456 type = "ONE2ONE" | 457 type = "ONE2ONE" |
457 target = str(self.host.selected.target) | 458 target = str(selected.target) |
458 else: | 459 else: |
459 print "Unknown selected host:",self.host.selected | 460 print "Unknown selected host:",selected |
460 type = "UNKNOWN" | 461 type = "UNKNOWN" |
461 return (type, target) | 462 return (type, target) |
462 | 463 |
463 def onBrowserEvent(self, event): | 464 def onBrowserEvent(self, event): |
464 #XXX: woraroung a pyjamas bug: self.currentEvent is not set | 465 #XXX: woraroung a pyjamas bug: self.currentEvent is not set |
477 self._timeCb(None) #we remove the popup | 478 self._timeCb(None) #we remove the popup |
478 self.showWarning(_target) | 479 self.showWarning(_target) |
479 | 480 |
480 self._timer.schedule(2000) | 481 self._timer.schedule(2000) |
481 | 482 |
483 selected = self.host.getSelected() | |
482 #if keycode == KEY_ENTER and not self.visible: | 484 #if keycode == KEY_ENTER and not self.visible: |
483 if keycode == KEY_ENTER: | 485 if keycode == KEY_ENTER: |
484 if _txt: | 486 if _txt: |
485 if _txt.startswith('@'): | 487 if _txt.startswith('@'): |
486 self.host.bridge.call('sendMblog', None, self.getText()) | 488 self.host.bridge.call('sendMblog', None, self.getText()) |
487 elif self.host.selected == None: | 489 elif selected == None: |
488 self.host.bridge.call('setStatus', None, _txt) | 490 self.host.bridge.call('setStatus', None, _txt) |
489 elif isinstance(self.host.selected, ChatPanel): | 491 elif isinstance(selected, ChatPanel): |
490 _chat = self.host.selected | 492 _chat = selected |
491 mess_type = "groupchat" if _chat.type=='group' else "chat" | 493 mess_type = "groupchat" if _chat.type=='group' else "chat" |
492 self.host.bridge.call('sendMessage', None, str(_chat.target), _txt, '', mess_type) | 494 self.host.bridge.call('sendMessage', None, str(_chat.target), _txt, '', mess_type) |
493 self.setText('') | 495 self.setText('') |
494 self._timeCb(None) #we remove the popup | 496 self._timeCb(None) #we remove the popup |
495 sender.cancelKey() | 497 sender.cancelKey() |
648 self.status = new_status or ' ' | 650 self.status = new_status or ' ' |
649 self.setHTML(self.__getContent()) | 651 self.setHTML(self.__getContent()) |
650 | 652 |
651 def onClick(self, sender): | 653 def onClick(self, sender): |
652 #As status is the default target of uniBar, we don't want to select anything if click on it | 654 #As status is the default target of uniBar, we don't want to select anything if click on it |
653 self.host.select(None) | 655 self.host.setSelected(None) |
654 | 656 |
655 class ChatText(HTMLPanel): | 657 class ChatText(HTMLPanel): |
656 | 658 |
657 def __init__(self, timestamp, nick, mymess, msg): | 659 def __init__(self, timestamp, nick, mymess, msg): |
658 _date = datetime.fromtimestamp(float(timestamp or time())) | 660 _date = datetime.fromtimestamp(float(timestamp or time())) |
865 def __init__(self, host, locked = False): | 867 def __init__(self, host, locked = False): |
866 ScrollPanelWrapper.__init__(self) | 868 ScrollPanelWrapper.__init__(self) |
867 self.setSize('100%', '100%') | 869 self.setSize('100%', '100%') |
868 self.host = host | 870 self.host = host |
869 self.locked = locked #if True: tab will not be removed when there are no more widgets inside | 871 self.locked = locked #if True: tab will not be removed when there are no more widgets inside |
872 self.selected = None | |
870 self.flextable = FlexTable() | 873 self.flextable = FlexTable() |
871 self.flextable.setSize('100%','100%') | 874 self.flextable.setSize('100%','100%') |
872 self.setWidget(self.flextable) | 875 self.setWidget(self.flextable) |
873 self.setStyleName('widgetsPanel') | 876 self.setStyleName('widgetsPanel') |
874 _bottom = BottomBorderWidget(self.host) | 877 _bottom = BottomBorderWidget(self.host) |
1027 self.tabBar.setVisible(False) | 1030 self.tabBar.setVisible(False) |
1028 self.setStyleName('liberviaTabPanel') | 1031 self.setStyleName('liberviaTabPanel') |
1029 self.addStyleName('mainTabPanel') | 1032 self.addStyleName('mainTabPanel') |
1030 Window.addWindowResizeListener(self) | 1033 Window.addWindowResizeListener(self) |
1031 | 1034 |
1035 def getCurrentPanel(self): | |
1036 """ Get the panel of the currently selected tab """ | |
1037 return self.deck.visibleWidget | |
1038 | |
1032 def onWindowResized(self, width, height): | 1039 def onWindowResized(self, width, height): |
1033 tab_panel_elt = self.getElement() | 1040 tab_panel_elt = self.getElement() |
1034 _elts = doc().getElementsByClassName('gwt-TabBar') | 1041 _elts = doc().getElementsByClassName('gwt-TabBar') |
1035 if not _elts.length: | 1042 if not _elts.length: |
1036 print ("ERROR: no TabBar found, it should exist !") | 1043 print ("ERROR: no TabBar found, it should exist !") |