Mercurial > libervia-desktop-kivy
diff cagou/core/cagou_main.py @ 385:6dacaf81339a
core: return newly switched widget in switchWidget and doAction
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2020 20:47:17 +0100 |
parents | eb3f622d8791 |
children | de066b72f5a8 |
line wrap: on
line diff
--- a/cagou/core/cagou_main.py Tue Feb 04 20:47:17 2020 +0100 +++ b/cagou/core/cagou_main.py Tue Feb 04 20:47:17 2020 +0100 @@ -737,10 +737,11 @@ def switchWidget(self, old, new=None): """Replace old widget by new one - old(CagouWidget, None): CagouWidget instance or a child + @param old(CagouWidget, None): CagouWidget instance or a child None to select automatically widget to switch - new(CagouWidget): new widget instance + @param new(CagouWidget): new widget instance None to use default widget + @return (CagouWidget): new widget """ if old is None: old = self.getWidgetToSwitch() @@ -767,6 +768,7 @@ # selected_widget can be modified in changeWidget, so we need to set it before self.selected_widget = new to_change.whwrapper.changeWidget(new) + return new def _addVisibleWidget(self, widget): """declare a widget visible @@ -863,10 +865,13 @@ @return (CagouWidget): widget to switch """ - if self._selected_widget_main is not None: + if (self._selected_widget_main is not None + and self._selected_widget_main.whwrapper is not None): # we are not on the main screen, we want to switch a widget from main screen return self._selected_widget_main - elif self.selected_widget is not None: + elif (self.selected_widget is not None + and isinstance(self.selected_widget, CagouWidget) + and self.selected_widget.whwrapper is not None): return self.selected_widget # no widget is selected we check if we have any default widget default_cls = self.default_class @@ -884,6 +889,7 @@ - chat: open a chat widget @param target(unicode): target of the action @param profiles(list[unicode]): profiles to use + @return (CagouWidget, None): new widget """ try: # FIXME: Q&D way to get chat plugin, should be replaced by a clean method @@ -894,7 +900,8 @@ log.warning("No plugin widget found to do {action}".format(action=action)) else: factory = plg_infos['factory'] - self.switchWidget(None, + return self.switchWidget( + None, factory(plg_infos, target=target, profiles=profiles)) ## bridge handlers ##