Skip to content

Commit 81515d7

Browse files
committed
Update DesktopNotifierSync to match DesktopNotifier
1 parent c88a537 commit 81515d7

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/desktop_notifier/sync.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Attachment,
1313
Button,
1414
Capability,
15+
DispatchedNotification,
1516
Icon,
1617
Notification,
1718
ReplyField,
@@ -41,7 +42,7 @@ def __init__(
4142
app_icon: Icon | None = DEFAULT_ICON,
4243
notification_limit: int | None = None,
4344
) -> None:
44-
self._async_api = DesktopNotifier(app_name, app_icon)
45+
self._async_api = DesktopNotifier(app_name, app_icon, notification_limit)
4546
self._loop = asyncio.new_event_loop()
4647

4748
def _run_coro_sync(self, coro: Coroutine[None, None, T]) -> T:
@@ -62,9 +63,17 @@ def app_name(self) -> str:
6263

6364
@app_name.setter
6465
def app_name(self, value: str) -> None:
65-
"""Setter: app_name"""
6666
self._async_api.app_name = value
6767

68+
@property
69+
def app_icon(self) -> Icon | None:
70+
"""The application icon"""
71+
return self._async_api.app_icon
72+
73+
@app_icon.setter
74+
def app_icon(self, value: Icon | None) -> None:
75+
self._async_api.app_icon = value
76+
6877
def request_authorisation(self) -> bool:
6978
"""See :meth:`desktop_notifier.main.DesktopNotifier.request_authorisation`"""
7079
coro = self._async_api.request_authorisation()
@@ -75,7 +84,9 @@ def has_authorisation(self) -> bool:
7584
coro = self._async_api.has_authorisation()
7685
return self._run_coro_sync(coro)
7786

78-
def send_notification(self, notification: Notification) -> str:
87+
def send_notification(
88+
self, notification: Notification | DispatchedNotification
89+
) -> DispatchedNotification | None:
7990
"""See :meth:`desktop_notifier.main.DesktopNotifier.send_notification`"""
8091
coro = self._async_api.send_notification(notification)
8192
return self._run_coro_sync(coro)
@@ -88,13 +99,14 @@ def send(
8899
icon: Icon | None = None,
89100
buttons: Sequence[Button] = (),
90101
reply_field: ReplyField | None = None,
102+
on_cleared: Callable[[], Any] | None = None,
91103
on_clicked: Callable[[], Any] | None = None,
92104
on_dismissed: Callable[[], Any] | None = None,
93105
attachment: Attachment | None = None,
94106
sound: Sound | None = None,
95107
thread: str | None = None,
96108
timeout: int = -1, # in seconds
97-
) -> str:
109+
) -> DispatchedNotification | None:
98110
"""See :meth:`desktop_notifier.main.DesktopNotifier.send`"""
99111
notification = Notification(
100112
title,
@@ -103,6 +115,7 @@ def send(
103115
icon=icon,
104116
buttons=tuple(buttons),
105117
reply_field=reply_field,
118+
on_cleared=on_cleared,
106119
on_clicked=on_clicked,
107120
on_dismissed=on_dismissed,
108121
attachment=attachment,
@@ -113,7 +126,7 @@ def send(
113126
coro = self._async_api.send_notification(notification)
114127
return self._run_coro_sync(coro)
115128

116-
def get_current_notifications(self) -> list[str]:
129+
def get_current_notifications(self) -> dict[str, DispatchedNotification]:
117130
"""See :meth:`desktop_notifier.main.DesktopNotifier.get_current_notifications`"""
118131
coro = self._async_api.get_current_notifications()
119132
return self._run_coro_sync(coro)

0 commit comments

Comments
 (0)