Skip to content

Commit 90e7460

Browse files
committed
DesktopNotifierSync: Add on_* properties for class-level events
1 parent ff32314 commit 90e7460

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

src/desktop_notifier/sync.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,68 @@ def get_capabilities(self) -> frozenset[Capability]:
132132
"""See :meth:`desktop_notifier.main.DesktopNotifier.get_capabilities`"""
133133
coro = self._async_api.get_capabilities()
134134
return self._run_coro_sync(coro)
135+
136+
@property
137+
def on_clicked(self) -> Callable[[str], Any] | None:
138+
"""
139+
A method to call when a notification is clicked
140+
141+
The method must take the notification identifier as a single argument.
142+
143+
If the notification itself already specifies an on_clicked handler, it will be
144+
used instead of the class-level handler.
145+
"""
146+
return self._async_api.on_clicked
147+
148+
@on_clicked.setter
149+
def on_clicked(self, handler: Callable[[str], Any] | None) -> None:
150+
self._async_api.on_clicked = handler
151+
152+
@property
153+
def on_dismissed(self) -> Callable[[str], Any] | None:
154+
"""
155+
A method to call when a notification is dismissed
156+
157+
The method must take the notification identifier as a single argument.
158+
159+
If the notification itself already specifies an on_dismissed handler, it will be
160+
used instead of the class-level handler.
161+
"""
162+
return self._async_api.on_dismissed
163+
164+
@on_dismissed.setter
165+
def on_dismissed(self, handler: Callable[[str], Any] | None) -> None:
166+
self._async_api.on_dismissed = handler
167+
168+
@property
169+
def on_button_pressed(self) -> Callable[[str, str], Any] | None:
170+
"""
171+
A method to call when a notification is dismissed
172+
173+
The method must take the notification identifier and the button identifier as
174+
arguments.
175+
176+
If the notification button itself already specifies an on_pressed handler, it
177+
will be used instead of the class-level handler.
178+
"""
179+
return self._async_api.on_button_pressed
180+
181+
@on_button_pressed.setter
182+
def on_button_pressed(self, handler: Callable[[str, str], Any] | None) -> None:
183+
self._async_api.on_button_pressed = handler
184+
185+
@property
186+
def on_replied(self) -> Callable[[str, str], Any] | None:
187+
"""
188+
A method to call when a user responds through the reply field of a notification
189+
190+
The method must take the notification identifier and input text as arguments.
191+
192+
If the notification's reply field itself already specifies an on_replied
193+
handler, it will be used instead of the class-level handler.
194+
"""
195+
return self._async_api.on_replied
196+
197+
@on_replied.setter
198+
def on_replied(self, handler: Callable[[str, str], Any] | None) -> None:
199+
self._async_api.on_replied = handler

0 commit comments

Comments
 (0)