# HG changeset patch # User Goffi # Date 1698240282 -7200 # Node ID bbef1a4135155b4c0b08f7af66cbe63ae68d4ea6 # Parent fe0bdc4765762d0705b84fbfa7ac7def1bf89745 core (main): add methods to deleted notifications: This will be used notably in Calls feature to remove a notification if an incoming call is cancelled before being handler by user. rel 425 diff -r fe0bdc476576 -r bbef1a413515 libervia/desktop_kivy/core/cagou_main.py --- a/libervia/desktop_kivy/core/cagou_main.py Wed Oct 25 15:22:19 2023 +0200 +++ b/libervia/desktop_kivy/core/cagou_main.py Wed Oct 25 15:24:42 2023 +0200 @@ -111,6 +111,12 @@ def add_notif(self, callback, *args, **kwargs): self.notifs.append((callback, args, kwargs)) + def del_notif(self, callback, *args, **kwargs): + try: + self.notifs.remove((callback, args, kwargs)) + except ValueError: + log.debug("The notification to delete doesn't exist anymore.") + class Note(Label): title = properties.StringProperty() @@ -207,6 +213,10 @@ app = App.get_running_app() self.notifs_icon.add_notif(app.host.show_extra_ui, widget=widget) + def del_notif_widget(self, widget): + app = App.get_running_app() + self.notifs_icon.del_notif(app.host.show_extra_ui, widget=widget) + def _display_next_note(self, __=None): screen = Screen() try: @@ -285,6 +295,9 @@ def add_notif_widget(self, widget): self.head_widget.add_notif_widget(widget) + def del_notif_widget(self, widget): + self.head_widget.del_notif_widget(widget) + class LiberviaDesktopKivyApp(App): """Kivy App for LiberviaDesktopKivy""" @@ -458,7 +471,8 @@ self._plg_wids = [] # transfer widgets plugins self._plg_wids_transfer = [] - self._import_plugins() + + Clock.schedule_once(lambda __: self._import_plugins(), 0) # visible widgets by classes self._visible_widgets = {} # used to keep track of last selected widget in "main" screen when changing @@ -1042,6 +1056,16 @@ """ self.app.root.add_notif_widget(widget) + def del_notif_widget(self, widget): + """del a notification with a Kivy widget attached + + @param widget(kivy.uix.Widget): widget to attach to notification + """ + if self.selected_widget == widget: + self.close_ui() + else: + self.app.root.del_notif_widget(widget) + def show_ui(self, ui): """show a XMLUI""" self.app.root.change_widget(ui, "xmlui") @@ -1057,6 +1081,7 @@ self.selected_widget = widget def close_ui(self): + """Close current UI in extra screen""" self.app.root.show() self.selected_widget = self._selected_widget_main self._selected_widget_main = None @@ -1089,6 +1114,7 @@ answer_data) ) self.add_notif_widget(wid) + return wid else: log.warning(_("unknown dialog type: {dialog_type}").format(dialog_type=type))