Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions examples/actions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(unused_imports)]
use notify_rust::{Hint, Notification};
use notify_rust::{Hint, Notification, Timeout};

#[cfg(any(target_os = "windows", target_os = "macos"))]
fn main() {
Expand All @@ -10,10 +10,26 @@ fn main() {
fn main() {
Notification::new()
.summary("click me")
.body("This will disappear by itself")
.action("clicked_a", "button a") // IDENTIFIER, LABEL
.hint(Hint::Transient(true)) // needed to work on kde
.show()
.unwrap()
.wait_for_action(|action| match action {
"clicked_a" => println!("clicked a"),
// FIXME: here "__closed" is a hardcoded keyword, it will be deprecated!!
"__closed" => println!("the notification was closed"),
_ => (),
});

Notification::new()
.summary("click me")
.body("This action needs to be clicked")
.action("default", "default") // IDENTIFIER, LABEL
.action("clicked_a", "button a") // IDENTIFIER, LABEL
.action("clicked_b", "button b") // IDENTIFIER, LABEL
.hint(Hint::Resident(true))
.hint(Hint::Resident(true)) // does not work on kde
.timeout(Timeout::Never) // works on kde and gnome
.show()
.unwrap()
.wait_for_action(|action| match action {
Expand Down
Loading