desktop-notifier 6.0.0.dev0__tar.gz → 6.1.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.
- {desktop_notifier-6.0.0.dev0/src/desktop_notifier.egg-info → desktop_notifier-6.1.0.dev0}/PKG-INFO +19 -21
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/README.md +2 -4
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/pyproject.toml +17 -18
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/__init__.py +1 -1
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/base.py +16 -4
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/dbus.py +28 -20
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/dummy.py +0 -3
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/macos.py +34 -23
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/winrt.py +101 -63
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/common.py +22 -13
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/main.py +31 -33
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/sync.py +13 -3
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0/src/desktop_notifier.egg-info}/PKG-INFO +19 -21
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier.egg-info/SOURCES.txt +1 -0
- desktop_notifier-6.1.0.dev0/src/desktop_notifier.egg-info/requires.txt +34 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/tests/test_api.py +47 -16
- desktop_notifier-6.1.0.dev0/tests/test_callbacks.py +231 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/tests/test_sync_api.py +29 -5
- desktop_notifier-6.0.0.dev0/src/desktop_notifier.egg-info/requires.txt +0 -33
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/LICENSE +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/setup.cfg +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/__init__.py +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/macos_support.py +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/py.typed +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/resources/__init__.py +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/resources/python.png +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier.egg-info/dependency_links.txt +0 -0
- {desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier.egg-info/top_level.txt +0 -0
{desktop_notifier-6.0.0.dev0/src/desktop_notifier.egg-info → desktop_notifier-6.1.0.dev0}/PKG-INFO
RENAMED
|
@@ -1,44 +1,43 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: desktop-notifier
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.1.0.dev0
|
|
4
4
|
Summary: Python library for cross-platform desktop notifications
|
|
5
5
|
Author-email: Sam Schott <sam.schott@outlook.com>
|
|
6
|
-
License: MIT
|
|
6
|
+
License-Expression: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/samschott/desktop-notifier
|
|
8
8
|
Keywords: desktop-notifier,notifications,Notification Center,push notifications,Toast notifications
|
|
9
9
|
Classifier: Development Status :: 5 - Production/Stable
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
12
11
|
Classifier: Natural Language :: English
|
|
13
12
|
Classifier: Operating System :: MacOS :: MacOS X
|
|
14
13
|
Classifier: Operating System :: Microsoft :: Windows
|
|
15
14
|
Classifier: Operating System :: OS Independent
|
|
16
15
|
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
20
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
21
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
24
22
|
Classifier: Topic :: Communications
|
|
25
23
|
Classifier: Topic :: Desktop Environment
|
|
26
24
|
Classifier: Topic :: Desktop Environment :: Gnome
|
|
27
25
|
Classifier: Topic :: Desktop Environment :: K Desktop Environment (KDE)
|
|
28
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
29
|
-
Requires-Python: >=3.
|
|
27
|
+
Requires-Python: >=3.9
|
|
30
28
|
Description-Content-Type: text/markdown
|
|
31
29
|
License-File: LICENSE
|
|
32
30
|
Requires-Dist: bidict
|
|
33
31
|
Requires-Dist: packaging
|
|
34
|
-
Requires-Dist:
|
|
35
|
-
Requires-Dist:
|
|
36
|
-
Requires-Dist:
|
|
37
|
-
Requires-Dist: winrt-
|
|
38
|
-
Requires-Dist: winrt-windows.
|
|
39
|
-
Requires-Dist: winrt-windows.
|
|
40
|
-
Requires-Dist: winrt-windows.foundation
|
|
41
|
-
Requires-Dist: winrt-windows.
|
|
32
|
+
Requires-Dist: typing-extensions
|
|
33
|
+
Requires-Dist: dbus-fast; sys_platform == "linux"
|
|
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"
|
|
42
41
|
Provides-Extra: dev
|
|
43
42
|
Requires-Dist: black; extra == "dev"
|
|
44
43
|
Requires-Dist: bump2version; extra == "dev"
|
|
@@ -51,9 +50,10 @@ Requires-Dist: pytest-asyncio; extra == "dev"
|
|
|
51
50
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
52
51
|
Provides-Extra: docs
|
|
53
52
|
Requires-Dist: furo==2024.8.6; extra == "docs"
|
|
54
|
-
Requires-Dist: sphinx==8.
|
|
55
|
-
Requires-Dist: sphinx-autoapi==3.
|
|
53
|
+
Requires-Dist: sphinx==8.1.3; extra == "docs"
|
|
54
|
+
Requires-Dist: sphinx-autoapi==3.6.0; extra == "docs"
|
|
56
55
|
Requires-Dist: sphinx-mdinclude==0.6.2; extra == "docs"
|
|
56
|
+
Dynamic: license-file
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
# Desktop Notifier
|
|
@@ -130,10 +130,7 @@ from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField, DEFAU
|
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
async def main() -> None:
|
|
133
|
-
notifier = DesktopNotifier(
|
|
134
|
-
app_name="Sample App",
|
|
135
|
-
notification_limit=10,
|
|
136
|
-
)
|
|
133
|
+
notifier = DesktopNotifier(app_name="Sample App")
|
|
137
134
|
|
|
138
135
|
await notifier.send(
|
|
139
136
|
title="Julius Caesar",
|
|
@@ -148,6 +145,7 @@ async def main() -> None:
|
|
|
148
145
|
reply_field=ReplyField(
|
|
149
146
|
on_replied=lambda text: print("Brutus replied:", text),
|
|
150
147
|
),
|
|
148
|
+
on_dispatched=lambda: print("Notification showing"),
|
|
151
149
|
on_clicked=lambda: print("Notification clicked"),
|
|
152
150
|
on_dismissed=lambda: print("Notification dismissed"),
|
|
153
151
|
sound=DEFAULT_SOUND,
|
|
@@ -73,10 +73,7 @@ from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField, DEFAU
|
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
async def main() -> None:
|
|
76
|
-
notifier = DesktopNotifier(
|
|
77
|
-
app_name="Sample App",
|
|
78
|
-
notification_limit=10,
|
|
79
|
-
)
|
|
76
|
+
notifier = DesktopNotifier(app_name="Sample App")
|
|
80
77
|
|
|
81
78
|
await notifier.send(
|
|
82
79
|
title="Julius Caesar",
|
|
@@ -91,6 +88,7 @@ async def main() -> None:
|
|
|
91
88
|
reply_field=ReplyField(
|
|
92
89
|
on_replied=lambda text: print("Brutus replied:", text),
|
|
93
90
|
),
|
|
91
|
+
on_dispatched=lambda: print("Notification showing"),
|
|
94
92
|
on_clicked=lambda: print("Notification clicked"),
|
|
95
93
|
on_dismissed=lambda: print("Notification dismissed"),
|
|
96
94
|
sound=DEFAULT_SOUND,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[build-system]
|
|
2
|
-
requires = ["setuptools
|
|
2
|
+
requires = ["setuptools"]
|
|
3
3
|
build-backend = "setuptools.build_meta"
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "desktop-notifier"
|
|
7
|
-
version = "6.
|
|
7
|
+
version = "6.1.0.dev0"
|
|
8
8
|
authors = [{name = "Sam Schott", email = "sam.schott@outlook.com"}]
|
|
9
|
-
license =
|
|
9
|
+
license = "MIT"
|
|
10
10
|
description = "Python library for cross-platform desktop notifications"
|
|
11
11
|
keywords = [
|
|
12
12
|
"desktop-notifier",
|
|
@@ -18,18 +18,16 @@ keywords = [
|
|
|
18
18
|
classifiers = [
|
|
19
19
|
"Development Status :: 5 - Production/Stable",
|
|
20
20
|
"Intended Audience :: Developers",
|
|
21
|
-
"License :: OSI Approved :: MIT License",
|
|
22
21
|
"Natural Language :: English",
|
|
23
22
|
"Operating System :: MacOS :: MacOS X",
|
|
24
23
|
"Operating System :: Microsoft :: Windows",
|
|
25
24
|
"Operating System :: OS Independent",
|
|
26
25
|
"Programming Language :: Python :: 3",
|
|
27
|
-
"Programming Language :: Python :: 3.7",
|
|
28
|
-
"Programming Language :: Python :: 3.8",
|
|
29
26
|
"Programming Language :: Python :: 3.9",
|
|
30
27
|
"Programming Language :: Python :: 3.10",
|
|
31
28
|
"Programming Language :: Python :: 3.11",
|
|
32
29
|
"Programming Language :: Python :: 3.12",
|
|
30
|
+
"Programming Language :: Python :: 3.13",
|
|
33
31
|
"Programming Language :: Python :: 3 :: Only",
|
|
34
32
|
"Topic :: Communications",
|
|
35
33
|
"Topic :: Desktop Environment",
|
|
@@ -37,18 +35,19 @@ classifiers = [
|
|
|
37
35
|
"Topic :: Desktop Environment :: K Desktop Environment (KDE)",
|
|
38
36
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
39
37
|
]
|
|
40
|
-
requires-python = ">=3.
|
|
38
|
+
requires-python = ">=3.9"
|
|
41
39
|
dependencies = [
|
|
42
40
|
"bidict",
|
|
43
41
|
"packaging",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"winrt-
|
|
48
|
-
"winrt-windows.
|
|
49
|
-
"winrt-windows.
|
|
50
|
-
"winrt-windows.foundation
|
|
51
|
-
"winrt-windows.
|
|
42
|
+
"typing-extensions",
|
|
43
|
+
"dbus-fast;sys_platform=='linux'",
|
|
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'",
|
|
52
51
|
]
|
|
53
52
|
|
|
54
53
|
[project.readme]
|
|
@@ -72,8 +71,8 @@ dev = [
|
|
|
72
71
|
]
|
|
73
72
|
docs = [
|
|
74
73
|
"furo==2024.8.6",
|
|
75
|
-
"sphinx==8.
|
|
76
|
-
"sphinx-autoapi==3.
|
|
74
|
+
"sphinx==8.1.3",
|
|
75
|
+
"sphinx-autoapi==3.6.0",
|
|
77
76
|
"sphinx-mdinclude==0.6.2",
|
|
78
77
|
]
|
|
79
78
|
|
|
@@ -96,7 +95,7 @@ files = ["src"]
|
|
|
96
95
|
|
|
97
96
|
[tool.black]
|
|
98
97
|
line-length = 88
|
|
99
|
-
target-version = ["
|
|
98
|
+
target-version = ["py38", "py39", "py310", "py311", "py312", "py313"]
|
|
100
99
|
|
|
101
100
|
[tool.isort]
|
|
102
101
|
profile = "black"
|
{desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/base.py
RENAMED
|
@@ -8,7 +8,7 @@ import logging
|
|
|
8
8
|
from abc import ABC, abstractmethod
|
|
9
9
|
from typing import Any, Callable
|
|
10
10
|
|
|
11
|
-
from ..common import Capability, Notification
|
|
11
|
+
from ..common import Capability, Icon, Notification
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
14
14
|
"DesktopNotifierBackend",
|
|
@@ -24,10 +24,12 @@ class DesktopNotifierBackend(ABC):
|
|
|
24
24
|
:param app_name: Name to identify the application in the notification center.
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
|
-
def __init__(self, app_name: str) -> None:
|
|
27
|
+
def __init__(self, app_name: str, app_icon: Icon | None = None) -> None:
|
|
28
28
|
self.app_name = app_name
|
|
29
|
+
self.app_icon = app_icon
|
|
29
30
|
self._notification_cache: dict[str, Notification] = dict()
|
|
30
31
|
|
|
32
|
+
self.on_dispatched: Callable[[str], Any] | None = None
|
|
31
33
|
self.on_clicked: Callable[[str], Any] | None = None
|
|
32
34
|
self.on_dismissed: Callable[[str], Any] | None = None
|
|
33
35
|
self.on_button_pressed: Callable[[str, str], Any] | None = None
|
|
@@ -67,12 +69,14 @@ class DesktopNotifierBackend(ABC):
|
|
|
67
69
|
logger.debug("Notification sent: %s", notification)
|
|
68
70
|
self._notification_cache[notification.identifier] = notification
|
|
69
71
|
|
|
70
|
-
|
|
72
|
+
self.handle_dispatched(notification.identifier, notification)
|
|
73
|
+
|
|
74
|
+
def _clear_notification_from_cache(self, identifier: str) -> Notification | None:
|
|
71
75
|
"""
|
|
72
76
|
Removes the notification from our cache. Should be called by backends when the
|
|
73
77
|
notification is closed.
|
|
74
78
|
"""
|
|
75
|
-
self._notification_cache.pop(identifier, None)
|
|
79
|
+
return self._notification_cache.pop(identifier, None)
|
|
76
80
|
|
|
77
81
|
@abstractmethod
|
|
78
82
|
async def _send(self, notification: Notification) -> None:
|
|
@@ -142,6 +146,14 @@ class DesktopNotifierBackend(ABC):
|
|
|
142
146
|
"""
|
|
143
147
|
...
|
|
144
148
|
|
|
149
|
+
def handle_dispatched(
|
|
150
|
+
self, identifier: str, notification: Notification | None = None
|
|
151
|
+
) -> None:
|
|
152
|
+
if notification and notification.on_dispatched:
|
|
153
|
+
notification.on_dispatched()
|
|
154
|
+
elif self.on_dispatched:
|
|
155
|
+
self.on_dispatched(identifier)
|
|
156
|
+
|
|
145
157
|
def handle_clicked(
|
|
146
158
|
self, identifier: str, notification: Notification | None = None
|
|
147
159
|
) -> None:
|
{desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/dbus.py
RENAMED
|
@@ -11,12 +11,12 @@ import logging
|
|
|
11
11
|
from typing import TypeVar
|
|
12
12
|
|
|
13
13
|
from bidict import bidict
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
14
|
+
from dbus_fast.aio.message_bus import MessageBus
|
|
15
|
+
from dbus_fast.aio.proxy_object import ProxyInterface
|
|
16
|
+
from dbus_fast.errors import DBusError
|
|
17
|
+
from dbus_fast.signature import Variant
|
|
18
18
|
|
|
19
|
-
from ..common import Capability, Notification, Urgency
|
|
19
|
+
from ..common import Capability, Icon, Notification, Urgency
|
|
20
20
|
from .base import DesktopNotifierBackend
|
|
21
21
|
|
|
22
22
|
__all__ = ["DBusDesktopNotifier"]
|
|
@@ -48,8 +48,8 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
48
48
|
|
|
49
49
|
supported_hint_signatures = {"a{sv}", "a{ss}"}
|
|
50
50
|
|
|
51
|
-
def __init__(self, app_name: str) -> None:
|
|
52
|
-
super().__init__(app_name)
|
|
51
|
+
def __init__(self, app_name: str, app_icon: Icon | None = None) -> None:
|
|
52
|
+
super().__init__(app_name, app_icon)
|
|
53
53
|
self.interface: ProxyInterface | None = None
|
|
54
54
|
self._platform_to_interface_notification_identifier: bidict[int, str] = bidict()
|
|
55
55
|
|
|
@@ -115,7 +115,7 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
115
115
|
|
|
116
116
|
if notification.sound:
|
|
117
117
|
if notification.sound.is_named():
|
|
118
|
-
hints_v["sound-name"] = Variant("s",
|
|
118
|
+
hints_v["sound-name"] = Variant("s", notification.sound.name)
|
|
119
119
|
else:
|
|
120
120
|
hints_v["sound-file"] = Variant("s", notification.sound.as_uri())
|
|
121
121
|
|
|
@@ -143,13 +143,20 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
143
143
|
hints = {}
|
|
144
144
|
|
|
145
145
|
timeout = notification.timeout * 1000 if notification.timeout != -1 else -1
|
|
146
|
+
|
|
147
|
+
icon: str = ""
|
|
146
148
|
if notification.icon:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
icon = (
|
|
150
|
+
notification.icon.as_name()
|
|
151
|
+
if notification.icon.is_named()
|
|
152
|
+
else notification.icon.as_uri()
|
|
153
|
+
)
|
|
154
|
+
elif self.app_icon:
|
|
155
|
+
icon = (
|
|
156
|
+
self.app_icon.as_name()
|
|
157
|
+
if self.app_icon.is_named()
|
|
158
|
+
else self.app_icon.as_uri()
|
|
159
|
+
)
|
|
153
160
|
|
|
154
161
|
# dbus_next proxy APIs are generated at runtime. Silence the type checker but
|
|
155
162
|
# raise an AttributeError if required.
|
|
@@ -172,7 +179,7 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
172
179
|
Asynchronously removes a notification from the notification center
|
|
173
180
|
"""
|
|
174
181
|
if not self.interface:
|
|
175
|
-
|
|
182
|
+
self.interface = await self._init_dbus()
|
|
176
183
|
|
|
177
184
|
platform_id = self._platform_to_interface_notification_identifier.inverse[
|
|
178
185
|
identifier
|
|
@@ -199,9 +206,6 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
199
206
|
"""
|
|
200
207
|
Asynchronously clears all notifications from notification center
|
|
201
208
|
"""
|
|
202
|
-
if not self.interface:
|
|
203
|
-
return
|
|
204
|
-
|
|
205
209
|
for identifier in list(
|
|
206
210
|
self._platform_to_interface_notification_identifier.values()
|
|
207
211
|
):
|
|
@@ -222,7 +226,7 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
222
226
|
ourselves when scheduling the notification.
|
|
223
227
|
"""
|
|
224
228
|
identifier = self._platform_to_interface_notification_identifier.pop(nid, "")
|
|
225
|
-
notification = self.
|
|
229
|
+
notification = self._clear_notification_from_cache(identifier)
|
|
226
230
|
|
|
227
231
|
if not notification:
|
|
228
232
|
return
|
|
@@ -242,7 +246,10 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
242
246
|
:param reason: An integer describing the reason why the notification was closed.
|
|
243
247
|
"""
|
|
244
248
|
identifier = self._platform_to_interface_notification_identifier.pop(nid, "")
|
|
245
|
-
notification = self.
|
|
249
|
+
notification = self._clear_notification_from_cache(identifier)
|
|
250
|
+
|
|
251
|
+
if not notification:
|
|
252
|
+
return
|
|
246
253
|
|
|
247
254
|
if reason == NOTIFICATION_CLOSED_DISMISSED:
|
|
248
255
|
self.handle_dismissed(identifier, notification)
|
|
@@ -257,6 +264,7 @@ class DBusDesktopNotifier(DesktopNotifierBackend):
|
|
|
257
264
|
Capability.TITLE,
|
|
258
265
|
Capability.TIMEOUT,
|
|
259
266
|
Capability.URGENCY,
|
|
267
|
+
Capability.ON_DISPATCHED,
|
|
260
268
|
}
|
|
261
269
|
|
|
262
270
|
# Capabilities supported by some notification servers.
|
{desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/dummy.py
RENAMED
|
@@ -11,9 +11,6 @@ from .base import DesktopNotifierBackend
|
|
|
11
11
|
class DummyNotificationCenter(DesktopNotifierBackend):
|
|
12
12
|
"""A dummy backend for unsupported platforms"""
|
|
13
13
|
|
|
14
|
-
def __init__(self, app_name: str) -> None:
|
|
15
|
-
super().__init__(app_name)
|
|
16
|
-
|
|
17
14
|
async def request_authorisation(self) -> bool:
|
|
18
15
|
"""
|
|
19
16
|
Request authorisation to send notifications.
|
{desktop_notifier-6.0.0.dev0 → desktop_notifier-6.1.0.dev0}/src/desktop_notifier/backends/macos.py
RENAMED
|
@@ -22,7 +22,7 @@ from packaging.version import Version
|
|
|
22
22
|
from rubicon.objc import NSObject, ObjCClass, objc_method, py_from_ns
|
|
23
23
|
from rubicon.objc.runtime import load_library, objc_block, objc_id
|
|
24
24
|
|
|
25
|
-
from ..common import DEFAULT_SOUND, Capability, Notification, Urgency
|
|
25
|
+
from ..common import DEFAULT_SOUND, Capability, Icon, Notification, Urgency
|
|
26
26
|
from .base import DesktopNotifierBackend
|
|
27
27
|
from .macos_support import macos_version
|
|
28
28
|
|
|
@@ -33,6 +33,7 @@ logger = logging.getLogger(__name__)
|
|
|
33
33
|
foundation = load_library("Foundation")
|
|
34
34
|
uns = load_library("UserNotifications")
|
|
35
35
|
|
|
36
|
+
UNNotification = ObjCClass("UNNotification")
|
|
36
37
|
UNUserNotificationCenter = ObjCClass("UNUserNotificationCenter")
|
|
37
38
|
UNMutableNotificationContent = ObjCClass("UNMutableNotificationContent")
|
|
38
39
|
UNNotificationRequest = ObjCClass("UNNotificationRequest")
|
|
@@ -83,17 +84,17 @@ class UNNotificationInterruptionLevel(enum.Enum):
|
|
|
83
84
|
ReplyActionIdentifier = "com.desktop-notifier.ReplyActionIdentifier"
|
|
84
85
|
|
|
85
86
|
|
|
86
|
-
class NotificationCenterDelegate(NSObject): # type:ignore
|
|
87
|
+
class NotificationCenterDelegate(NSObject): # type:ignore[misc]
|
|
87
88
|
"""Delegate to handle user interactions with notifications"""
|
|
88
89
|
|
|
89
90
|
implementation: CocoaNotificationCenter
|
|
90
91
|
|
|
91
|
-
@objc_method # type:ignore
|
|
92
|
+
@objc_method # type:ignore[misc]
|
|
92
93
|
def userNotificationCenter_didReceiveNotificationResponse_withCompletionHandler_(
|
|
93
|
-
self, center, response, completion_handler: objc_block
|
|
94
|
+
self, center: objc_id, response: objc_id, completion_handler: objc_block
|
|
94
95
|
) -> None:
|
|
95
96
|
identifier = py_from_ns(response.notification.request.identifier)
|
|
96
|
-
notification = self.implementation.
|
|
97
|
+
notification = self.implementation._clear_notification_from_cache(identifier)
|
|
97
98
|
|
|
98
99
|
if response.actionIdentifier == UNNotificationDefaultActionIdentifier:
|
|
99
100
|
self.implementation.handle_clicked(identifier, notification)
|
|
@@ -107,7 +108,7 @@ class NotificationCenterDelegate(NSObject): # type:ignore
|
|
|
107
108
|
|
|
108
109
|
else:
|
|
109
110
|
action_id = py_from_ns(response.actionIdentifier)
|
|
110
|
-
self.implementation.
|
|
111
|
+
self.implementation.handle_button(identifier, action_id, notification)
|
|
111
112
|
|
|
112
113
|
completion_handler()
|
|
113
114
|
|
|
@@ -128,8 +129,8 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
128
129
|
Urgency.Critical: UNNotificationInterruptionLevel.TimeSensitive,
|
|
129
130
|
}
|
|
130
131
|
|
|
131
|
-
def __init__(self, app_name: str) -> None:
|
|
132
|
-
super().__init__(app_name)
|
|
132
|
+
def __init__(self, app_name: str, app_icon: Icon | None = None) -> None:
|
|
133
|
+
super().__init__(app_name, app_icon)
|
|
133
134
|
self.nc = UNUserNotificationCenter.currentNotificationCenter()
|
|
134
135
|
self.nc_delegate = NotificationCenterDelegate.alloc().init()
|
|
135
136
|
self.nc_delegate.implementation = self
|
|
@@ -151,8 +152,6 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
151
152
|
|
|
152
153
|
def on_auth_completed(granted: bool, error: objc_id) -> None:
|
|
153
154
|
ns_error = py_from_ns(error)
|
|
154
|
-
if ns_error:
|
|
155
|
-
ns_error.retain()
|
|
156
155
|
future.set_result((granted, ns_error))
|
|
157
156
|
|
|
158
157
|
self.nc.requestAuthorizationWithOptions(
|
|
@@ -166,7 +165,6 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
166
165
|
|
|
167
166
|
if error:
|
|
168
167
|
log_nserror(error, "Error requesting notification authorization")
|
|
169
|
-
error.autorelease() # type:ignore[attr-defined]
|
|
170
168
|
elif not has_authorization:
|
|
171
169
|
logger.info("Not authorized to send notifications.")
|
|
172
170
|
else:
|
|
@@ -180,20 +178,39 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
180
178
|
|
|
181
179
|
def handler(settings: objc_id) -> None:
|
|
182
180
|
settings = py_from_ns(settings)
|
|
183
|
-
|
|
181
|
+
future.set_result(settings)
|
|
184
182
|
future.set_result(settings)
|
|
185
183
|
|
|
186
184
|
self.nc.getNotificationSettingsWithCompletionHandler(handler)
|
|
187
185
|
|
|
188
186
|
settings = await asyncio.wrap_future(future)
|
|
189
|
-
|
|
187
|
+
return settings.authorizationStatus in ( # type:ignore[attr-defined]
|
|
190
188
|
UNAuthorizationStatusAuthorized,
|
|
191
189
|
UNAuthorizationStatusProvisional,
|
|
192
190
|
UNAuthorizationStatusEphemeral,
|
|
193
191
|
)
|
|
194
|
-
settings.autorelease() # type:ignore[attr-defined]
|
|
195
192
|
|
|
196
|
-
|
|
193
|
+
async def get_current_notifications(self) -> list[str]:
|
|
194
|
+
future: Future[list[UNNotification]] = Future() # type:ignore[valid-type]
|
|
195
|
+
|
|
196
|
+
def handler(notifications: objc_id) -> None:
|
|
197
|
+
notifications = py_from_ns(notifications)
|
|
198
|
+
for notification in notifications:
|
|
199
|
+
notification.retain()
|
|
200
|
+
future.set_result(notifications)
|
|
201
|
+
|
|
202
|
+
self.nc.getDeliveredNotificationsWithCompletionHandler(handler)
|
|
203
|
+
|
|
204
|
+
notifications = await asyncio.wrap_future(future)
|
|
205
|
+
identifiers = [
|
|
206
|
+
str(n.request.identifier) # type:ignore[attr-defined]
|
|
207
|
+
for n in notifications
|
|
208
|
+
]
|
|
209
|
+
|
|
210
|
+
for notification in notifications:
|
|
211
|
+
notification.autorelease() # type:ignore[attr-defined]
|
|
212
|
+
|
|
213
|
+
return identifiers
|
|
197
214
|
|
|
198
215
|
async def _send(self, notification: Notification) -> None:
|
|
199
216
|
"""
|
|
@@ -248,8 +265,6 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
248
265
|
|
|
249
266
|
def handler(error: objc_id) -> None:
|
|
250
267
|
ns_error = py_from_ns(error)
|
|
251
|
-
if ns_error:
|
|
252
|
-
ns_error.retain()
|
|
253
268
|
future.set_result(ns_error)
|
|
254
269
|
|
|
255
270
|
# Post the notification.
|
|
@@ -262,7 +277,6 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
262
277
|
|
|
263
278
|
if error:
|
|
264
279
|
log_nserror(error, "Error when scheduling notification")
|
|
265
|
-
error.autorelease() # type:ignore[attr-defined]
|
|
266
280
|
|
|
267
281
|
async def _find_or_create_notification_category(
|
|
268
282
|
self, notification: Notification
|
|
@@ -339,15 +353,11 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
339
353
|
|
|
340
354
|
def handler(categories: objc_id) -> None:
|
|
341
355
|
categories = py_from_ns(categories)
|
|
342
|
-
categories.retain()
|
|
343
356
|
future.set_result(categories)
|
|
344
357
|
|
|
345
358
|
self.nc.getNotificationCategoriesWithCompletionHandler(handler)
|
|
346
359
|
|
|
347
|
-
|
|
348
|
-
categories.autorelease() # type:ignore[attr-defined]
|
|
349
|
-
|
|
350
|
-
return categories
|
|
360
|
+
return await asyncio.wrap_future(future)
|
|
351
361
|
|
|
352
362
|
def _clear_notification_categories(self) -> None:
|
|
353
363
|
"""Clears all registered notification categories for this application."""
|
|
@@ -375,6 +385,7 @@ class CocoaNotificationCenter(DesktopNotifierBackend):
|
|
|
375
385
|
Capability.MESSAGE,
|
|
376
386
|
Capability.BUTTONS,
|
|
377
387
|
Capability.REPLY_FIELD,
|
|
388
|
+
Capability.ON_DISPATCHED,
|
|
378
389
|
Capability.ON_CLICKED,
|
|
379
390
|
Capability.ON_DISMISSED,
|
|
380
391
|
Capability.SOUND,
|