desktop-notifier 5.0.1__tar.gz → 6.0.0.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {desktop_notifier-5.0.1/src/desktop_notifier.egg-info → desktop_notifier-6.0.0.dev0}/PKG-INFO +7 -5
  2. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/pyproject.toml +10 -5
  3. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier/__init__.py +8 -8
  4. desktop_notifier-6.0.0.dev0/src/desktop_notifier/backends/base.py +187 -0
  5. {desktop_notifier-5.0.1/src/desktop_notifier → desktop_notifier-6.0.0.dev0/src/desktop_notifier/backends}/dbus.py +63 -91
  6. {desktop_notifier-5.0.1/src/desktop_notifier → desktop_notifier-6.0.0.dev0/src/desktop_notifier/backends}/dummy.py +8 -18
  7. {desktop_notifier-5.0.1/src/desktop_notifier → desktop_notifier-6.0.0.dev0/src/desktop_notifier/backends}/macos.py +62 -82
  8. {desktop_notifier-5.0.1/src/desktop_notifier → desktop_notifier-6.0.0.dev0/src/desktop_notifier/backends}/macos_support.py +25 -11
  9. {desktop_notifier-5.0.1/src/desktop_notifier → desktop_notifier-6.0.0.dev0/src/desktop_notifier/backends}/winrt.py +48 -81
  10. desktop_notifier-6.0.0.dev0/src/desktop_notifier/common.py +313 -0
  11. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier/main.py +130 -63
  12. desktop_notifier-6.0.0.dev0/src/desktop_notifier/py.typed +0 -0
  13. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier/sync.py +20 -22
  14. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0/src/desktop_notifier.egg-info}/PKG-INFO +7 -5
  15. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier.egg-info/SOURCES.txt +8 -6
  16. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier.egg-info/requires.txt +6 -4
  17. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/tests/test_api.py +16 -23
  18. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/tests/test_sync_api.py +12 -9
  19. desktop_notifier-5.0.1/src/desktop_notifier/base.py +0 -542
  20. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/LICENSE +0 -0
  21. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/README.md +0 -0
  22. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/setup.cfg +0 -0
  23. /desktop_notifier-5.0.1/src/desktop_notifier/py.typed → /desktop_notifier-6.0.0.dev0/src/desktop_notifier/backends/__init__.py +0 -0
  24. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier/resources/__init__.py +0 -0
  25. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier/resources/python.png +0 -0
  26. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier.egg-info/dependency_links.txt +0 -0
  27. {desktop_notifier-5.0.1 → desktop_notifier-6.0.0.dev0}/src/desktop_notifier.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: desktop-notifier
3
- Version: 5.0.1
3
+ Version: 6.0.0.dev0
4
4
  Summary: Python library for cross-platform desktop notifications
5
5
  Author-email: Sam Schott <sam.schott@outlook.com>
6
6
  License: MIT
@@ -29,6 +29,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
29
29
  Requires-Python: >=3.7
30
30
  Description-Content-Type: text/markdown
31
31
  License-File: LICENSE
32
+ Requires-Dist: bidict
32
33
  Requires-Dist: packaging
33
34
  Requires-Dist: dbus-next; sys_platform == "linux"
34
35
  Requires-Dist: rubicon-objc; sys_platform == "darwin"
@@ -43,15 +44,16 @@ Requires-Dist: black; extra == "dev"
43
44
  Requires-Dist: bump2version; extra == "dev"
44
45
  Requires-Dist: flake8; extra == "dev"
45
46
  Requires-Dist: flake8-pyproject; extra == "dev"
47
+ Requires-Dist: isort; extra == "dev"
46
48
  Requires-Dist: mypy; extra == "dev"
47
49
  Requires-Dist: pytest; extra == "dev"
48
50
  Requires-Dist: pytest-asyncio; extra == "dev"
49
51
  Requires-Dist: pytest-cov; extra == "dev"
50
52
  Provides-Extra: docs
51
- Requires-Dist: furo==2024.5.6; extra == "docs"
52
- Requires-Dist: sphinx==7.3.7; extra == "docs"
53
- Requires-Dist: sphinx-autoapi==3.1.2; extra == "docs"
54
- Requires-Dist: sphinx-mdinclude==0.6.1; extra == "docs"
53
+ Requires-Dist: furo==2024.8.6; extra == "docs"
54
+ Requires-Dist: sphinx==8.0.2; extra == "docs"
55
+ Requires-Dist: sphinx-autoapi==3.3.1; extra == "docs"
56
+ Requires-Dist: sphinx-mdinclude==0.6.2; extra == "docs"
55
57
 
56
58
 
57
59
  # Desktop Notifier
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "desktop-notifier"
7
- version = "5.0.1"
7
+ version = "6.0.0.dev0"
8
8
  authors = [{name = "Sam Schott", email = "sam.schott@outlook.com"}]
9
9
  license = {text = "MIT"}
10
10
  description = "Python library for cross-platform desktop notifications"
@@ -39,6 +39,7 @@ classifiers = [
39
39
  ]
40
40
  requires-python = ">=3.7"
41
41
  dependencies = [
42
+ "bidict",
42
43
  "packaging",
43
44
  "dbus-next;sys_platform=='linux'",
44
45
  "rubicon-objc;sys_platform=='darwin'",
@@ -63,16 +64,17 @@ dev = [
63
64
  "bump2version",
64
65
  "flake8",
65
66
  "flake8-pyproject",
67
+ "isort",
66
68
  "mypy",
67
69
  "pytest",
68
70
  "pytest-asyncio",
69
71
  "pytest-cov",
70
72
  ]
71
73
  docs = [
72
- "furo==2024.5.6",
73
- "sphinx==7.3.7",
74
- "sphinx-autoapi==3.1.2",
75
- "sphinx-mdinclude==0.6.1",
74
+ "furo==2024.8.6",
75
+ "sphinx==8.0.2",
76
+ "sphinx-autoapi==3.3.1",
77
+ "sphinx-mdinclude==0.6.2",
76
78
  ]
77
79
 
78
80
  [tool.setuptools.package-data]
@@ -95,3 +97,6 @@ files = ["src"]
95
97
  [tool.black]
96
98
  line-length = 88
97
99
  target-version = ["py37", "py38", "py39", "py310", "py311"]
100
+
101
+ [tool.isort]
102
+ profile = "black"
@@ -3,21 +3,21 @@
3
3
  Desktop notifications for Windows, Linux, macOS, iOS and iPadOS.
4
4
  """
5
5
  from .main import (
6
- DesktopNotifier,
6
+ DEFAULT_ICON,
7
+ DEFAULT_SOUND,
8
+ Attachment,
7
9
  Button,
8
- ReplyField,
9
- Notification,
10
- Urgency,
11
10
  Capability,
11
+ DesktopNotifier,
12
12
  Icon,
13
+ Notification,
14
+ ReplyField,
13
15
  Sound,
14
- Attachment,
15
- DEFAULT_SOUND,
16
- DEFAULT_ICON,
16
+ Urgency,
17
17
  )
18
18
  from .sync import DesktopNotifierSync
19
19
 
20
- __version__ = "5.0.1"
20
+ __version__ = "6.0.0.dev0"
21
21
  __author__ = "Sam Schott"
22
22
  __url__ = "https://github.com/samschott/desktop-notifier"
23
23
 
@@ -0,0 +1,187 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ This module defines the abstract implementation class that backends must inherit from.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import logging
8
+ from abc import ABC, abstractmethod
9
+ from typing import Any, Callable
10
+
11
+ from ..common import Capability, Notification
12
+
13
+ __all__ = [
14
+ "DesktopNotifierBackend",
15
+ ]
16
+
17
+
18
+ logger = logging.getLogger(__name__)
19
+
20
+
21
+ class DesktopNotifierBackend(ABC):
22
+ """Base class for desktop notifier implementations
23
+
24
+ :param app_name: Name to identify the application in the notification center.
25
+ """
26
+
27
+ def __init__(self, app_name: str) -> None:
28
+ self.app_name = app_name
29
+ self._notification_cache: dict[str, Notification] = dict()
30
+
31
+ self.on_clicked: Callable[[str], Any] | None = None
32
+ self.on_dismissed: Callable[[str], Any] | None = None
33
+ self.on_button_pressed: Callable[[str, str], Any] | None = None
34
+ self.on_replied: Callable[[str, str], Any] | None = None
35
+
36
+ @abstractmethod
37
+ async def request_authorisation(self) -> bool:
38
+ """
39
+ Request authorisation to send notifications.
40
+
41
+ :returns: Whether authorisation has been granted.
42
+ """
43
+ ...
44
+
45
+ @abstractmethod
46
+ async def has_authorisation(self) -> bool:
47
+ """
48
+ Returns whether we have authorisation to send notifications.
49
+ """
50
+ ...
51
+
52
+ async def send(self, notification: Notification) -> None:
53
+ """
54
+ Sends a desktop notification.
55
+
56
+ :param notification: Notification to send.
57
+ """
58
+ try:
59
+ await self._send(notification)
60
+ except Exception:
61
+ # Notifications can fail for many reasons:
62
+ # The dbus service may not be available, we might be in a headless session,
63
+ # etc. Since notifications are not critical to an application, we only emit
64
+ # a warning.
65
+ logger.warning("Notification failed", exc_info=True)
66
+ else:
67
+ logger.debug("Notification sent: %s", notification)
68
+ self._notification_cache[notification.identifier] = notification
69
+
70
+ def _clear_notification_from_cache(self, identifier: str) -> None:
71
+ """
72
+ Removes the notification from our cache. Should be called by backends when the
73
+ notification is closed.
74
+ """
75
+ self._notification_cache.pop(identifier, None)
76
+
77
+ @abstractmethod
78
+ async def _send(self, notification: Notification) -> None:
79
+ """
80
+ Method to send a notification via the platform. This should be implemented by
81
+ subclasses.
82
+
83
+ Implementations must raise an exception when the notification could not be
84
+ delivered. If the notification could be delivered but not fully as intended,
85
+ e.g., because associated resources could not be loaded, implementations should
86
+ emit a log message of level warning.
87
+
88
+ :param notification: Notification to send.
89
+ """
90
+ ...
91
+
92
+ async def get_current_notifications(self) -> list[str]:
93
+ """Returns identifiers of all currently displayed notifications for this app."""
94
+ return list(self._notification_cache.keys())
95
+
96
+ async def clear(self, identifier: str) -> None:
97
+ """
98
+ Removes the given notification from the notification center. This is a wrapper
99
+ method which mostly performs housekeeping of notifications ID and calls
100
+ :meth:`_clear` to actually clear the notification. Platform implementations
101
+ must implement :meth:`_clear`.
102
+
103
+ :param identifier: Notification identifier.
104
+ """
105
+ await self._clear(identifier)
106
+ self._clear_notification_from_cache(identifier)
107
+
108
+ @abstractmethod
109
+ async def _clear(self, identifier: str) -> None:
110
+ """
111
+ Removes the given notification from the notification center. Should be
112
+ implemented by subclasses.
113
+
114
+ :param identifier: Notification identifier.
115
+ """
116
+ ...
117
+
118
+ async def clear_all(self) -> None:
119
+ """
120
+ Clears all notifications from the notification center. This is a wrapper method
121
+ which mostly performs housekeeping of notifications ID and calls
122
+ :meth:`_clear_all` to actually clear the notifications. Platform implementations
123
+ must implement :meth:`_clear_all`.
124
+ """
125
+
126
+ await self._clear_all()
127
+ self._notification_cache.clear()
128
+
129
+ @abstractmethod
130
+ async def _clear_all(self) -> None:
131
+ """
132
+ Clears all notifications from the notification center. Should be implemented by
133
+ subclasses.
134
+ """
135
+ ...
136
+
137
+ @abstractmethod
138
+ async def get_capabilities(self) -> frozenset[Capability]:
139
+ """
140
+ Returns the functionality supported by the implementation and, for Linux / dbus,
141
+ the notification server.
142
+ """
143
+ ...
144
+
145
+ def handle_clicked(
146
+ self, identifier: str, notification: Notification | None = None
147
+ ) -> None:
148
+ if notification and notification.on_clicked:
149
+ notification.on_clicked()
150
+ elif self.on_clicked:
151
+ self.on_clicked(identifier)
152
+
153
+ def handle_dismissed(
154
+ self, identifier: str, notification: Notification | None = None
155
+ ) -> None:
156
+ if notification and notification.on_dismissed:
157
+ notification.on_dismissed()
158
+ elif self.on_dismissed:
159
+ self.on_dismissed(identifier)
160
+
161
+ def handle_replied(
162
+ self, identifier: str, reply_text: str, notification: Notification | None = None
163
+ ) -> None:
164
+ if (
165
+ notification
166
+ and notification.reply_field
167
+ and notification.reply_field.on_replied
168
+ ):
169
+ notification.reply_field.on_replied(reply_text)
170
+ elif self.on_replied:
171
+ self.on_replied(identifier, reply_text)
172
+
173
+ def handle_button(
174
+ self,
175
+ identifier: str,
176
+ button_identifier: str,
177
+ notification: Notification | None = None,
178
+ ) -> None:
179
+ if notification and button_identifier in notification._buttons_dict:
180
+ button = notification._buttons_dict[button_identifier]
181
+ else:
182
+ button = None
183
+
184
+ if button and button.on_pressed:
185
+ button.on_pressed()
186
+ elif self.on_button_pressed:
187
+ self.on_button_pressed(identifier, button_identifier)
@@ -7,18 +7,17 @@ interaction with a notification requires a running asyncio event loop.
7
7
  """
8
8
  from __future__ import annotations
9
9
 
10
- # system imports
11
10
  import logging
12
11
  from typing import TypeVar
13
12
 
14
- # external imports
15
- from dbus_next.signature import Variant
13
+ from bidict import bidict
16
14
  from dbus_next.aio.message_bus import MessageBus
17
15
  from dbus_next.aio.proxy_object import ProxyInterface
16
+ from dbus_next.errors import DBusError
17
+ from dbus_next.signature import Variant
18
18
 
19
- # local imports
20
- from .base import Notification, DesktopNotifierBase, Urgency, Capability
21
-
19
+ from ..common import Capability, Notification, Urgency
20
+ from .base import DesktopNotifierBackend
22
21
 
23
22
  __all__ = ["DBusDesktopNotifier"]
24
23
 
@@ -32,28 +31,13 @@ NOTIFICATION_CLOSED_PROGRAMMATICALLY = 3
32
31
  NOTIFICATION_CLOSED_UNDEFINED = 4
33
32
 
34
33
 
35
- def identifier_from_dbus(nid: int) -> str:
36
- if nid == 0:
37
- return ""
38
- return str(nid)
39
-
40
-
41
- def identifier_to_dbus(nid: str) -> int:
42
- if nid == "":
43
- return 0
44
- return int(nid)
45
-
46
-
47
- class DBusDesktopNotifier(DesktopNotifierBase):
34
+ class DBusDesktopNotifier(DesktopNotifierBackend):
48
35
  """DBus notification backend for Linux
49
36
 
50
37
  This implements the org.freedesktop.Notifications standard. The DBUS connection is
51
38
  created in a thread with a running asyncio loop to handle clicked notifications.
52
39
 
53
- :param app_name: The name of the app. If it matches the application name in an
54
- existing desktop entry, the icon from that entry will be used by default.
55
- :param notification_limit: Maximum number of notifications to keep in the system's
56
- notification center.
40
+ :param app_name: The name of the app.
57
41
  """
58
42
 
59
43
  to_native_urgency = {
@@ -64,13 +48,10 @@ class DBusDesktopNotifier(DesktopNotifierBase):
64
48
 
65
49
  supported_hint_signatures = {"a{sv}", "a{ss}"}
66
50
 
67
- def __init__(
68
- self,
69
- app_name: str = "Python",
70
- notification_limit: int | None = None,
71
- ) -> None:
72
- super().__init__(app_name, notification_limit)
51
+ def __init__(self, app_name: str) -> None:
52
+ super().__init__(app_name)
73
53
  self.interface: ProxyInterface | None = None
54
+ self._platform_to_interface_notification_identifier: bidict[int, str] = bidict()
74
55
 
75
56
  async def request_authorisation(self) -> bool:
76
57
  """
@@ -109,38 +90,25 @@ class DBusDesktopNotifier(DesktopNotifierBase):
109
90
 
110
91
  return self.interface
111
92
 
112
- async def _send(
113
- self,
114
- notification: Notification,
115
- notification_to_replace: Notification | None,
116
- ) -> None:
93
+ async def _send(self, notification: Notification) -> None:
117
94
  """
118
95
  Asynchronously sends a notification via the Dbus interface.
119
96
 
120
97
  :param notification: Notification to send.
121
- :param notification_to_replace: Notification to replace, if any.
122
98
  """
123
99
  if not self.interface:
124
100
  self.interface = await self._init_dbus()
125
101
 
126
- if notification_to_replace:
127
- replaces_nid = identifier_to_dbus(notification_to_replace.identifier)
128
- else:
129
- replaces_nid = 0
102
+ # The "default" action is typically invoked when clicking on the
103
+ # notification body itself, see
104
+ # https://specifications.freedesktop.org/notification-spec. There are some
105
+ # exceptions though, such as XFCE, where this will result in a separate
106
+ # button. If no label name is provided in XFCE, it will result in a default
107
+ # symbol being used. We therefore don't specify a label name.
108
+ actions = ["default", ""]
130
109
 
131
- actions: list[str] = []
132
-
133
- if notification.on_clicked:
134
- # The "default" action is typically invoked when clicking on the
135
- # notification body itself, see
136
- # https://specifications.freedesktop.org/notification-spec. There are some
137
- # exceptions though, such as XFCE, where this will result in a separate
138
- # button. If no label name is provided in XFCE, it will result in a default
139
- # symbol being used. We therefore don't specify a label name.
140
- actions = ["default", ""]
141
-
142
- for n, button in enumerate(notification.buttons):
143
- actions += [str(n), button.title]
110
+ for button in notification.buttons:
111
+ actions += [button.identifier, button.title]
144
112
 
145
113
  hints_v: dict[str, Variant] = dict()
146
114
  hints_v["urgency"] = self.to_native_urgency[notification.urgency]
@@ -185,9 +153,9 @@ class DBusDesktopNotifier(DesktopNotifierBase):
185
153
 
186
154
  # dbus_next proxy APIs are generated at runtime. Silence the type checker but
187
155
  # raise an AttributeError if required.
188
- platform_nid = await self.interface.call_notify( # type:ignore[attr-defined]
156
+ platform_id = await self.interface.call_notify( # type:ignore[attr-defined]
189
157
  self.app_name,
190
- replaces_nid,
158
+ 0,
191
159
  icon,
192
160
  notification.title,
193
161
  notification.message,
@@ -195,21 +163,37 @@ class DBusDesktopNotifier(DesktopNotifierBase):
195
163
  hints,
196
164
  timeout,
197
165
  )
166
+ self._platform_to_interface_notification_identifier[platform_id] = (
167
+ notification.identifier
168
+ )
198
169
 
199
- notification.identifier = identifier_from_dbus(platform_nid)
200
-
201
- async def _clear(self, notification: Notification) -> None:
170
+ async def _clear(self, identifier: str) -> None:
202
171
  """
203
172
  Asynchronously removes a notification from the notification center
204
173
  """
205
174
  if not self.interface:
206
175
  return
207
176
 
208
- # dbus_next proxy APIs are generated at runtime. Silence the type checker but
209
- # raise an AttributeError if required.
210
- await self.interface.call_close_notification( # type:ignore[attr-defined]
211
- identifier_to_dbus(notification.identifier)
212
- )
177
+ platform_id = self._platform_to_interface_notification_identifier.inverse[
178
+ identifier
179
+ ]
180
+
181
+ try:
182
+ # dbus_next proxy APIs are generated at runtime. Silence the type checker
183
+ # but raise an AttributeError if required.
184
+ await self.interface.call_close_notification( # type:ignore[attr-defined]
185
+ platform_id
186
+ )
187
+ except DBusError:
188
+ # Notification was already closed.
189
+ # See https://specifications.freedesktop.org/notification-spec/latest/protocol.html#command-close-notification
190
+ pass
191
+
192
+ try:
193
+ del self._platform_to_interface_notification_identifier.inverse[identifier]
194
+ except KeyError:
195
+ # Popping may have been handled already by _on_close callback.
196
+ pass
213
197
 
214
198
  async def _clear_all(self) -> None:
215
199
  """
@@ -218,12 +202,10 @@ class DBusDesktopNotifier(DesktopNotifierBase):
218
202
  if not self.interface:
219
203
  return
220
204
 
221
- for notification in self.current_notifications:
222
- # dbus_next proxy APIs are generated at runtime. Silence the type checker
223
- # but raise an AttributeError if required.
224
- await self.interface.call_close_notification( # type:ignore[attr-defined]
225
- identifier_to_dbus(notification.identifier)
226
- )
205
+ for identifier in list(
206
+ self._platform_to_interface_notification_identifier.values()
207
+ ):
208
+ await self._clear(identifier)
227
209
 
228
210
  # Note that _on_action and _on_closed might be called for the same notification
229
211
  # with some notification servers. This is not a problem because the _on_action
@@ -239,26 +221,17 @@ class DBusDesktopNotifier(DesktopNotifierBase):
239
221
  :param action_key: A string identifying the action to take. We choose those keys
240
222
  ourselves when scheduling the notification.
241
223
  """
242
- notification = self._notification_for_nid.get(identifier_from_dbus(nid))
243
-
244
- if notification:
245
- self._clear_notification_from_cache(notification)
246
-
247
- button_number: int | None
248
-
249
- try:
250
- button_number = int(action_key)
251
- except ValueError:
252
- button_number = None
224
+ identifier = self._platform_to_interface_notification_identifier.pop(nid, "")
225
+ notification = self._notification_cache.pop(identifier, None)
253
226
 
254
- if action_key == "default" and notification.on_clicked:
255
- notification.on_clicked()
227
+ if not notification:
228
+ return
256
229
 
257
- elif button_number is not None:
258
- button = notification.buttons[button_number]
230
+ if action_key == "default":
231
+ self.handle_clicked(identifier, notification)
232
+ return
259
233
 
260
- if button.on_pressed:
261
- button.on_pressed()
234
+ self.handle_button(identifier, action_key, notification)
262
235
 
263
236
  def _on_closed(self, nid: int, reason: int) -> None:
264
237
  """
@@ -268,13 +241,11 @@ class DBusDesktopNotifier(DesktopNotifierBase):
268
241
  :param nid: The platform's notification ID as an integer.
269
242
  :param reason: An integer describing the reason why the notification was closed.
270
243
  """
271
- notification = self._notification_for_nid.get(identifier_from_dbus(nid))
244
+ identifier = self._platform_to_interface_notification_identifier.pop(nid, "")
245
+ notification = self._notification_cache.pop(identifier, None)
272
246
 
273
- if notification:
274
- self._clear_notification_from_cache(notification)
275
-
276
- if reason == NOTIFICATION_CLOSED_DISMISSED and notification.on_dismissed:
277
- notification.on_dismissed()
247
+ if reason == NOTIFICATION_CLOSED_DISMISSED:
248
+ self.handle_dismissed(identifier, notification)
278
249
 
279
250
  async def get_capabilities(self) -> frozenset[Capability]:
280
251
  if not self.interface:
@@ -295,6 +266,7 @@ class DBusDesktopNotifier(DesktopNotifierBase):
295
266
  capabilities.add(Capability.ON_DISMISSED)
296
267
 
297
268
  cps = await self.interface.call_get_capabilities() # type:ignore[attr-defined]
269
+
298
270
  if "actions" in cps:
299
271
  capabilities.add(Capability.BUTTONS)
300
272
  if "body" in cps:
@@ -4,21 +4,15 @@ Dummy backend for unsupported platforms
4
4
  """
5
5
  from __future__ import annotations
6
6
 
7
- import uuid
7
+ from ..common import Capability, Notification
8
+ from .base import DesktopNotifierBackend
8
9
 
9
- from . import Capability
10
- from .base import Notification, DesktopNotifierBase
11
10
 
12
-
13
- class DummyNotificationCenter(DesktopNotifierBase):
11
+ class DummyNotificationCenter(DesktopNotifierBackend):
14
12
  """A dummy backend for unsupported platforms"""
15
13
 
16
- def __init__(
17
- self,
18
- app_name: str = "Python",
19
- notification_limit: int | None = None,
20
- ) -> None:
21
- super().__init__(app_name, notification_limit)
14
+ def __init__(self, app_name: str) -> None:
15
+ super().__init__(app_name)
22
16
 
23
17
  async def request_authorisation(self) -> bool:
24
18
  """
@@ -34,14 +28,10 @@ class DummyNotificationCenter(DesktopNotifierBase):
34
28
  """
35
29
  return True
36
30
 
37
- async def _send(
38
- self,
39
- notification: Notification,
40
- notification_to_replace: Notification | None,
41
- ) -> None:
42
- notification.identifier = str(uuid.uuid4())
31
+ async def _send(self, notification: Notification) -> None:
32
+ pass
43
33
 
44
- async def _clear(self, notification: Notification) -> None:
34
+ async def _clear(self, identifier: str) -> None:
45
35
  pass
46
36
 
47
37
  async def _clear_all(self) -> None: