comparison cagou/core/cagou_main.py @ 350:1ac40d3121f6

core (Cagou): "new" arg can be None in switchWidget, in which case default widget is used.
author Goffi <goffi@goffi.org>
date Fri, 17 Jan 2020 18:44:35 +0100
parents 33244f944bd8
children e9d3c3793f94
comparison
equal deleted inserted replaced
349:33244f944bd8 350:1ac40d3121f6
725 def newWidget(self, widget): 725 def newWidget(self, widget):
726 log.debug("new widget created: {}".format(widget)) 726 log.debug("new widget created: {}".format(widget))
727 if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP: 727 if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP:
728 self.addNote("", _("room {} has been joined").format(widget.target)) 728 self.addNote("", _("room {} has been joined").format(widget.target))
729 729
730 def switchWidget(self, old, new): 730 def switchWidget(self, old, new=None):
731 """Replace old widget by new one 731 """Replace old widget by new one
732 732
733 old(CagouWidgetn None): CagouWidget instance or a child 733 old(CagouWidget, None): CagouWidget instance or a child
734 None to select automatically widget to switch 734 None to select automatically widget to switch
735 new(CagouWidget): new widget instance 735 new(CagouWidget): new widget instance
736 None to use default widget
736 """ 737 """
737 if old is None: 738 if old is None:
738 old = self.getWidgetToSwitch() 739 old = self.getWidgetToSwitch()
740 if new is None:
741 factory = self.default_wid['factory']
742 new = factory(self.default_wid, None, profiles=old.profiles)
739 to_change = None 743 to_change = None
740 if isinstance(old, CagouWidget): 744 if isinstance(old, CagouWidget):
741 to_change = old 745 to_change = old
742 else: 746 else:
743 for w in old.walk_reverse(): 747 for w in old.walk_reverse():