comparison cagou/core/cagou_main.py @ 363:816a0c880f52

core: use selected widget from main screen in getWidgetToSwitch: if we are not on "main" screen, selected_widget may not refer to a widget that we want to change. To avoid that, getWidgetToSwitch check and use `_selected_widget_main` if suitable. In other words, a widget from "main" screen will be returned and switched, even if we are on a other screen (e.g. if on "extra", if a widget like ShareWidget is shown).
author Goffi <goffi@goffi.org>
date Mon, 27 Jan 2020 21:17:08 +0100
parents a77386b73e55
children 58e395c0777e
comparison
equal deleted inserted replaced
362:e1f56257cabc 363:816a0c880f52
871 def getWidgetToSwitch(self): 871 def getWidgetToSwitch(self):
872 """Choose best candidate when we need to switch widget and old is not specified 872 """Choose best candidate when we need to switch widget and old is not specified
873 873
874 @return (CagouWidget): widget to switch 874 @return (CagouWidget): widget to switch
875 """ 875 """
876 if self.selected_widget is not None: 876 if self._selected_widget_main is not None:
877 # we are not on the main screen, we want to switch a widget from main screen
878 return self._selected_widget_main
879 elif self.selected_widget is not None:
877 return self.selected_widget 880 return self.selected_widget
878 # no widget is selected we check if we have any default widget 881 # no widget is selected we check if we have any default widget
879 default_cls = self.default_class 882 default_cls = self.default_class
880 for w in self.visible_widgets: 883 for w in self.visible_widgets:
881 if isinstance(w, default_cls): 884 if isinstance(w, default_cls):