changeset 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
files cagou/core/cagou_main.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Fri Jan 17 18:44:35 2020 +0100
+++ b/cagou/core/cagou_main.py	Fri Jan 17 18:44:35 2020 +0100
@@ -727,15 +727,19 @@
         if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP:
             self.addNote("", _("room {} has been joined").format(widget.target))
 
-    def switchWidget(self, old, new):
+    def switchWidget(self, old, new=None):
         """Replace old widget by new one
 
-        old(CagouWidgetn None): CagouWidget instance or a child
+        old(CagouWidget, None): CagouWidget instance or a child
             None to select automatically widget to switch
         new(CagouWidget): new widget instance
+            None to use default widget
         """
         if old is None:
             old = self.getWidgetToSwitch()
+        if new is None:
+            factory = self.default_wid['factory']
+            new = factory(self.default_wid, None, profiles=old.profiles)
         to_change = None
         if isinstance(old, CagouWidget):
             to_change = old