# HG changeset patch # User Goffi # Date 1579289757 -3600 # Node ID 307c2501d8b2a583bcc35cc87eb0c5836cb3523f # Parent 8b6621cc142cd84359e094b50c98ca96db91d5d3 chat: keep as many instances of opened chat as there are active WHWrapper, instead of just one: Chat instances can be shown on any WHWrapper, even in all at the same time, so we keep as many instances as active wrapper to avoid unnecessary widget (re)creation diff -r 8b6621cc142c -r 307c2501d8b2 cagou/core/cagou_main.py --- a/cagou/core/cagou_main.py Fri Jan 17 20:33:43 2020 +0100 +++ b/cagou/core/cagou_main.py Fri Jan 17 20:35:57 2020 +0100 @@ -925,8 +925,8 @@ ## misc ## def plugging_profiles(self): - self._widgets_handler = widgets_handler.WidgetsHandler() - self.app.root.changeWidget(self._widgets_handler) + self.widgets_handler = widgets_handler.WidgetsHandler() + self.app.root.changeWidget(self.widgets_handler) self.bridge.menusGet("", C.NO_SECURITY_LIMIT, callback=self._menusGetCb) def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): diff -r 8b6621cc142c -r 307c2501d8b2 cagou/plugins/plugin_wid_chat.py --- a/cagou/plugins/plugin_wid_chat.py Fri Jan 17 20:33:43 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Fri Jan 17 20:35:57 2020 +0100 @@ -767,13 +767,13 @@ if not self.sync: self.resync() - def onDelete(self): + def onDelete(self, **kwargs): # we always keep one widget, so it's available when swiping # TODO: delete all widgets when chat is closed nb_instances = sum(1 for _ in self.host.widgets.getWidgetInstances(self)) - if nb_instances > 1: - return super(Chat, self).onDelete() - else: + # we want to keep at least one instance of Chat by WHWrapper + nb_to_keep = len(G.host.widgets_handler.children) + if nb_instances <= nb_to_keep: return False def _history_unlock(self, __):