Skip to content

Commit 01cd7a6

Browse files
committed
Update on_cleared event docs
Improve docs of the `ON_CLEARED` capability and update other docs to allow distinguishing between expired and programatically closed notifications in the future. Actually adding support for expiring notifications is out-of-scope here.
1 parent f210474 commit 01cd7a6

File tree

5 files changed

+10
-9
lines changed

5 files changed

+10
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ async def main() -> None:
8989
on_replied=lambda text: print("Brutus replied:", text),
9090
),
9191
on_dispatched=lambda: print("Notification showing"),
92-
on_cleared=lambda: print("Notification timed out"),
92+
on_cleared=lambda: print("Notification closed w/o user interaction"),
9393
on_clicked=lambda: print("Notification clicked"),
94-
on_dismissed=lambda: print("Notification dismissed"),
94+
on_dismissed=lambda: print("Notification dismissed by the user"),
9595
sound=DEFAULT_SOUND,
9696
timeout=10,
9797
)

examples/eventloop.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ async def main() -> None:
3434
on_replied=lambda text: print(f"Received reply '{text}'"),
3535
),
3636
on_dispatched=lambda: print("Notification is showing now"),
37-
on_cleared=lambda: print("Notification timed out"),
37+
on_cleared=lambda: print("Notification closed w/o user interaction"),
3838
on_clicked=lambda: print("Notification was clicked"),
39-
on_dismissed=lambda: print("Notification was dismissed"),
39+
on_dismissed=lambda: print("Notification was dismissed by the user"),
4040
sound=DEFAULT_SOUND,
4141
timeout=10,
4242
)

examples/synchronous.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
on_replied=lambda text: print("Brutus replied:", text),
2525
),
2626
on_dispatched=lambda: print("Notification showing"),
27-
on_cleared=lambda: print("Notification timed out"),
27+
on_cleared=lambda: print("Notification closed w/o user interaction"),
2828
on_clicked=lambda: print("Notification clicked"),
29-
on_dismissed=lambda: print("Notification dismissed"),
29+
on_dismissed=lambda: print("Notification dismissed by user"),
3030
sound=DEFAULT_SOUND,
3131
timeout=10,
3232
)

src/desktop_notifier/common.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ class Capability(Enum):
304304
"""Supports on-dispatched callbacks"""
305305

306306
ON_CLEARED = auto()
307-
"""Supports distinguishing between an user closing a notification, and clearing a
308-
notification programmatically, and consequently supports on-cleared callbacks"""
307+
"""Supports on-cleared callbacks, which are called if a notification wasn't
308+
cleared by user interaction, but programmatically; platforms not supporting
309+
this distinction will call on-dismissed callbacks instead"""
309310

310311
ON_CLICKED = auto()
311312
"""Supports on-clicked callbacks"""

src/desktop_notifier/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def on_dispatched(self, handler: Callable[[str], Any] | None) -> None:
300300
def on_cleared(self) -> Callable[[str], Any] | None:
301301
"""
302302
A method to call when a notification is cleared without user interaction
303-
(e.g. after a timeout, or if cleared by another process)
303+
(e.g. if cleared by another process)
304304
305305
The method must take the notification identifier as a single argument.
306306

0 commit comments

Comments
 (0)