desktop-notifier 6.1.0.dev0__tar.gz → 6.1.1.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-6.1.0.dev0/src/desktop_notifier.egg-info → desktop_notifier-6.1.1.dev0}/PKG-INFO +7 -7
  2. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/pyproject.toml +7 -7
  3. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/__init__.py +1 -1
  4. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/backends/base.py +16 -9
  5. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/backends/dbus.py +18 -10
  6. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/backends/dummy.py +1 -1
  7. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/backends/macos.py +1 -1
  8. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/backends/winrt.py +2 -4
  9. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/main.py +1 -5
  10. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0/src/desktop_notifier.egg-info}/PKG-INFO +7 -7
  11. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier.egg-info/requires.txt +6 -6
  12. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/tests/test_api.py +0 -5
  13. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/tests/test_sync_api.py +0 -7
  14. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/LICENSE +0 -0
  15. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/README.md +0 -0
  16. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/setup.cfg +0 -0
  17. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/backends/__init__.py +0 -0
  18. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/backends/macos_support.py +0 -0
  19. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/common.py +0 -0
  20. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/py.typed +0 -0
  21. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/resources/__init__.py +0 -0
  22. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/resources/python.png +0 -0
  23. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier/sync.py +0 -0
  24. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier.egg-info/SOURCES.txt +0 -0
  25. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier.egg-info/dependency_links.txt +0 -0
  26. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/src/desktop_notifier.egg-info/top_level.txt +0 -0
  27. {desktop_notifier-6.1.0.dev0 → desktop_notifier-6.1.1.dev0}/tests/test_callbacks.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: desktop-notifier
3
- Version: 6.1.0.dev0
3
+ Version: 6.1.1.dev0
4
4
  Summary: Python library for cross-platform desktop notifications
5
5
  Author-email: Sam Schott <sam.schott@outlook.com>
6
6
  License-Expression: MIT
@@ -32,12 +32,12 @@ Requires-Dist: packaging
32
32
  Requires-Dist: typing-extensions
33
33
  Requires-Dist: dbus-fast; sys_platform == "linux"
34
34
  Requires-Dist: rubicon-objc>=0.5; sys_platform == "darwin"
35
- Requires-Dist: winrt-runtime<4,>=3; sys_platform == "win32"
36
- Requires-Dist: winrt-windows.applicationmodel.core<4,>=3; sys_platform == "win32"
37
- Requires-Dist: winrt-windows.data.xml.dom<4,>=3; sys_platform == "win32"
38
- Requires-Dist: winrt-windows.foundation<4,>=3; sys_platform == "win32"
39
- Requires-Dist: winrt-windows.foundation.collections<4,>=3; sys_platform == "win32"
40
- Requires-Dist: winrt-windows.ui.notifications<4,>=3; sys_platform == "win32"
35
+ Requires-Dist: winrt-runtime>=3.1; sys_platform == "win32"
36
+ Requires-Dist: winrt-windows.applicationmodel.core>=3.1; sys_platform == "win32"
37
+ Requires-Dist: winrt-windows.data.xml.dom>=3.1; sys_platform == "win32"
38
+ Requires-Dist: winrt-windows.foundation>=3.1; sys_platform == "win32"
39
+ Requires-Dist: winrt-windows.foundation.collections>=3.1; sys_platform == "win32"
40
+ Requires-Dist: winrt-windows.ui.notifications>=3.1; sys_platform == "win32"
41
41
  Provides-Extra: dev
42
42
  Requires-Dist: black; extra == "dev"
43
43
  Requires-Dist: bump2version; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "desktop-notifier"
7
- version = "6.1.0.dev0"
7
+ version = "6.1.1.dev0"
8
8
  authors = [{name = "Sam Schott", email = "sam.schott@outlook.com"}]
9
9
  license = "MIT"
10
10
  description = "Python library for cross-platform desktop notifications"
@@ -42,12 +42,12 @@ dependencies = [
42
42
  "typing-extensions",
43
43
  "dbus-fast;sys_platform=='linux'",
44
44
  "rubicon-objc>=0.5;sys_platform=='darwin'",
45
- "winrt-runtime>=3,<4;sys_platform=='win32'",
46
- "winrt-windows.applicationmodel.core>=3,<4;sys_platform=='win32'",
47
- "winrt-windows.data.xml.dom>=3,<4;sys_platform=='win32'",
48
- "winrt-windows.foundation>=3,<4;sys_platform=='win32'",
49
- "winrt-windows.foundation.collections>=3,<4;sys_platform=='win32'",
50
- "winrt-windows.ui.notifications>=3,<4;sys_platform=='win32'",
45
+ "winrt-runtime>=3.1;sys_platform=='win32'",
46
+ "winrt-windows.applicationmodel.core>=3.1;sys_platform=='win32'",
47
+ "winrt-windows.data.xml.dom>=3.1;sys_platform=='win32'",
48
+ "winrt-windows.foundation>=3.1;sys_platform=='win32'",
49
+ "winrt-windows.foundation.collections>=3.1;sys_platform=='win32'",
50
+ "winrt-windows.ui.notifications>=3.1;sys_platform=='win32'",
51
51
  ]
52
52
 
53
53
  [project.readme]
@@ -17,7 +17,7 @@ from .main import (
17
17
  )
18
18
  from .sync import DesktopNotifierSync
19
19
 
20
- __version__ = "6.1.0.dev0"
20
+ __version__ = "6.1.1.dev0"
21
21
  __author__ = "Sam Schott"
22
22
  __url__ = "https://github.com/samschott/desktop-notifier"
23
23
 
@@ -35,6 +35,8 @@ class DesktopNotifierBackend(ABC):
35
35
  self.on_button_pressed: Callable[[str, str], Any] | None = None
36
36
  self.on_replied: Callable[[str, str], Any] | None = None
37
37
 
38
+ self._capabilities: frozenset[Capability] | None = None
39
+
38
40
  @abstractmethod
39
41
  async def request_authorisation(self) -> bool:
40
42
  """
@@ -81,8 +83,7 @@ class DesktopNotifierBackend(ABC):
81
83
  @abstractmethod
82
84
  async def _send(self, notification: Notification) -> None:
83
85
  """
84
- Method to send a notification via the platform. This should be implemented by
85
- subclasses.
86
+ Method to send a notification via the platform.
86
87
 
87
88
  Implementations must raise an exception when the notification could not be
88
89
  delivered. If the notification could be delivered but not fully as intended,
@@ -112,8 +113,7 @@ class DesktopNotifierBackend(ABC):
112
113
  @abstractmethod
113
114
  async def _clear(self, identifier: str) -> None:
114
115
  """
115
- Removes the given notification from the notification center. Should be
116
- implemented by subclasses.
116
+ Removes the given notification from the notification center.
117
117
 
118
118
  :param identifier: Notification identifier.
119
119
  """
@@ -133,19 +133,26 @@ class DesktopNotifierBackend(ABC):
133
133
  @abstractmethod
134
134
  async def _clear_all(self) -> None:
135
135
  """
136
- Clears all notifications from the notification center. Should be implemented by
137
- subclasses.
136
+ Clears all notifications from the notification center.
138
137
  """
139
138
  ...
140
139
 
141
140
  @abstractmethod
142
- async def get_capabilities(self) -> frozenset[Capability]:
141
+ async def _get_capabilities(self) -> frozenset[Capability]:
143
142
  """
144
- Returns the functionality supported by the implementation and, for Linux / dbus,
145
- the notification server.
143
+ Returns the functionality supported by the notification server.
146
144
  """
147
145
  ...
148
146
 
147
+ async def get_capabilities(self) -> frozenset[Capability]:
148
+ """
149
+ Returns the functionality supported by the notification server. Caches the
150
+ result.
151
+ """
152
+ if not self._capabilities:
153
+ self._capabilities = await self._get_capabilities()
154
+ return self._capabilities
155
+
149
156
  def handle_dispatched(
150
157
  self, identifier: str, notification: Notification | None = None
151
158
  ) -> None:
@@ -30,6 +30,8 @@ NOTIFICATION_CLOSED_DISMISSED = 2
30
30
  NOTIFICATION_CLOSED_PROGRAMMATICALLY = 3
31
31
  NOTIFICATION_CLOSED_UNDEFINED = 4
32
32
 
33
+ DEFAULT_ACTION_KEY = "default"
34
+
33
35
 
34
36
  class DBusDesktopNotifier(DesktopNotifierBackend):
35
37
  """DBus notification backend for Linux
@@ -99,13 +101,11 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
99
101
  if not self.interface:
100
102
  self.interface = await self._init_dbus()
101
103
 
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", ""]
104
+ actions = []
105
+
106
+ # The "default" action is invoked when clicking on the notification body.
107
+ if Capability.ON_CLICKED in await self.get_capabilities():
108
+ actions += [DEFAULT_ACTION_KEY, ""]
109
109
 
110
110
  for button in notification.buttons:
111
111
  actions += [button.identifier, button.title]
@@ -231,7 +231,7 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
231
231
  if not notification:
232
232
  return
233
233
 
234
- if action_key == "default":
234
+ if action_key == DEFAULT_ACTION_KEY:
235
235
  self.handle_clicked(identifier, notification)
236
236
  return
237
237
 
@@ -254,7 +254,7 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
254
254
  if reason == NOTIFICATION_CLOSED_DISMISSED:
255
255
  self.handle_dismissed(identifier, notification)
256
256
 
257
- async def get_capabilities(self) -> frozenset[Capability]:
257
+ async def _get_capabilities(self) -> frozenset[Capability]:
258
258
  if not self.interface:
259
259
  self.interface = await self._init_dbus()
260
260
 
@@ -270,9 +270,17 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
270
270
  # Capabilities supported by some notification servers.
271
271
  # See https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html#protocol.
272
272
  if hasattr(self.interface, "on_notification_closed"):
273
- capabilities.add(Capability.ON_CLICKED)
274
273
  capabilities.add(Capability.ON_DISMISSED)
275
274
 
275
+ server_info = (
276
+ await self.interface.call_get_server_information() # type:ignore[attr-defined]
277
+ )
278
+
279
+ # xfce4-notifyd does not support a "default" action when the notification is
280
+ # clicked. See https://docs.xfce.org/apps/xfce4-notifyd/spec.
281
+ if server_info[0] != "Xfce Notify Daemon":
282
+ capabilities.add(Capability.ON_CLICKED)
283
+
276
284
  cps = await self.interface.call_get_capabilities() # type:ignore[attr-defined]
277
285
 
278
286
  if "actions" in cps:
@@ -34,5 +34,5 @@ class DummyNotificationCenter(DesktopNotifierBackend):
34
34
  async def _clear_all(self) -> None:
35
35
  pass
36
36
 
37
- async def get_capabilities(self) -> frozenset[Capability]:
37
+ async def _get_capabilities(self) -> frozenset[Capability]:
38
38
  return frozenset()
@@ -379,7 +379,7 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
379
379
  """
380
380
  self.nc.removeAllDeliveredNotifications()
381
381
 
382
- async def get_capabilities(self) -> frozenset[Capability]:
382
+ async def _get_capabilities(self) -> frozenset[Capability]:
383
383
  capabilities = {
384
384
  Capability.TITLE,
385
385
  Capability.MESSAGE,
@@ -304,12 +304,10 @@ class WinRTDesktopNotifier(DesktopNotifierBackend):
304
304
  async def get_current_notifications(self) -> list[str]:
305
305
  if self.manager.history:
306
306
  notifications = self.manager.history.get_history_with_id(self.app_id)
307
- # Convert winrt IVectorView to list because the former does crashes on list
308
- # comprehension on some Python versions.
309
- return [n.tag for n in list(notifications)]
307
+ return [n.tag for n in notifications]
310
308
  return await super().get_current_notifications()
311
309
 
312
- async def get_capabilities(self) -> frozenset[Capability]:
310
+ async def _get_capabilities(self) -> frozenset[Capability]:
313
311
  capabilities = {
314
312
  Capability.TITLE,
315
313
  Capability.MESSAGE,
@@ -143,8 +143,6 @@ class DesktopNotifier:
143
143
  self._backend = backend(app_name, app_icon)
144
144
  self._did_request_authorisation = False
145
145
 
146
- self._capabilities: frozenset[Capability] | None = None
147
-
148
146
  @property
149
147
  def app_name(self) -> str:
150
148
  """The application name"""
@@ -274,9 +272,7 @@ class DesktopNotifier:
274
272
  """
275
273
  Returns which functionality is supported by the implementation.
276
274
  """
277
- if not self._capabilities:
278
- self._capabilities = await self._backend.get_capabilities()
279
- return self._capabilities
275
+ return await self._backend.get_capabilities()
280
276
 
281
277
  @property
282
278
  def on_dispatched(self) -> Callable[[str], Any] | None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: desktop-notifier
3
- Version: 6.1.0.dev0
3
+ Version: 6.1.1.dev0
4
4
  Summary: Python library for cross-platform desktop notifications
5
5
  Author-email: Sam Schott <sam.schott@outlook.com>
6
6
  License-Expression: MIT
@@ -32,12 +32,12 @@ Requires-Dist: packaging
32
32
  Requires-Dist: typing-extensions
33
33
  Requires-Dist: dbus-fast; sys_platform == "linux"
34
34
  Requires-Dist: rubicon-objc>=0.5; sys_platform == "darwin"
35
- Requires-Dist: winrt-runtime<4,>=3; sys_platform == "win32"
36
- Requires-Dist: winrt-windows.applicationmodel.core<4,>=3; sys_platform == "win32"
37
- Requires-Dist: winrt-windows.data.xml.dom<4,>=3; sys_platform == "win32"
38
- Requires-Dist: winrt-windows.foundation<4,>=3; sys_platform == "win32"
39
- Requires-Dist: winrt-windows.foundation.collections<4,>=3; sys_platform == "win32"
40
- Requires-Dist: winrt-windows.ui.notifications<4,>=3; sys_platform == "win32"
35
+ Requires-Dist: winrt-runtime>=3.1; sys_platform == "win32"
36
+ Requires-Dist: winrt-windows.applicationmodel.core>=3.1; sys_platform == "win32"
37
+ Requires-Dist: winrt-windows.data.xml.dom>=3.1; sys_platform == "win32"
38
+ Requires-Dist: winrt-windows.foundation>=3.1; sys_platform == "win32"
39
+ Requires-Dist: winrt-windows.foundation.collections>=3.1; sys_platform == "win32"
40
+ Requires-Dist: winrt-windows.ui.notifications>=3.1; sys_platform == "win32"
41
41
  Provides-Extra: dev
42
42
  Requires-Dist: black; extra == "dev"
43
43
  Requires-Dist: bump2version; extra == "dev"
@@ -9,12 +9,12 @@ rubicon-objc>=0.5
9
9
  dbus-fast
10
10
 
11
11
  [:sys_platform == "win32"]
12
- winrt-runtime<4,>=3
13
- winrt-windows.applicationmodel.core<4,>=3
14
- winrt-windows.data.xml.dom<4,>=3
15
- winrt-windows.foundation<4,>=3
16
- winrt-windows.foundation.collections<4,>=3
17
- winrt-windows.ui.notifications<4,>=3
12
+ winrt-runtime>=3.1
13
+ winrt-windows.applicationmodel.core>=3.1
14
+ winrt-windows.data.xml.dom>=3.1
15
+ winrt-windows.foundation>=3.1
16
+ winrt-windows.foundation.collections>=3.1
17
+ winrt-windows.ui.notifications>=3.1
18
18
 
19
19
  [dev]
20
20
  black
@@ -1,5 +1,4 @@
1
1
  import asyncio
2
- import sys
3
2
  import time
4
3
  from pathlib import Path
5
4
 
@@ -129,10 +128,6 @@ async def test_attachment_uri(notifier: DesktopNotifier) -> None:
129
128
 
130
129
 
131
130
  @pytest.mark.asyncio
132
- @pytest.mark.skipif(
133
- sys.platform.startswith("win"),
134
- reason="Clearing individual notifications is broken on Windows",
135
- )
136
131
  async def test_clear(notifier: DesktopNotifier) -> None:
137
132
  n0 = await notifier.send(
138
133
  title="Julius Caesar",
@@ -1,8 +1,5 @@
1
- import sys
2
1
  import time
3
2
 
4
- import pytest
5
-
6
3
  from desktop_notifier import (
7
4
  DEFAULT_SOUND,
8
5
  Button,
@@ -51,10 +48,6 @@ def test_send(notifier_sync: DesktopNotifierSync) -> None:
51
48
  assert notification in notifier_sync.get_current_notifications()
52
49
 
53
50
 
54
- @pytest.mark.skipif(
55
- sys.platform.startswith("win"),
56
- reason="Clearing individual notifications is broken on Windows",
57
- )
58
51
  def test_clear(notifier_sync: DesktopNotifierSync) -> None:
59
52
  n0 = notifier_sync.send(
60
53
  title="Julius Caesar",