Struct notify_rust::NotificationHandle
[−]
[src]
pub struct NotificationHandle { // some fields omitted }
A handle to a shown notification.
This keeps a connection alive to ensure actions work on certain desktops.
Methods
impl NotificationHandle
[src]
fn wait_for_action<F>(self, invokation_closure: F) where F: FnOnce(&str)
Waits for the user to act on a notification and then calls
invokation_closure
with the name of the corresponding action.
fn close(self)
Manually close the notification
fn on_close<F>(self, closure: F) where F: FnOnce()
Executes a closure after the notification has closed.
Example
Notification::new() .summary("Time is running out") .body("This will go away.") .icon("clock") .show().unwrap() .on_close(||{println!("closed")});
fn update(&mut self)
Replace the original notification with an updated version
Example
let mut notification = Notification::new() .summary("Latest News") .body("Bayern Dortmund 3:2") .show().unwrap(); std::thread::sleep_ms(1_500); notification .summary("Latest News (Correction)") .body("Bayern Dortmund 3:3"); notification.update();
Watch out for different implementations of the notification server! On plasma5 or instance, you should also change the appname, so the old message is really replaced and not just amended. Xfce behaves well, all others have not been tested by the developer.
fn id(&self) -> u32
Returns the Handle's id.
Methods from Deref<Target=Notification>
fn appname(&mut self, appname: &str) -> &mut Notification
Overwrite the appname field used for Notification.
fn summary(&mut self, summary: &str) -> &mut Notification
Set the summary
.
Often acts as title of the notification. For more elaborate content use the body
field.
fn body(&mut self, body: &str) -> &mut Notification
Set the content of the body
field.
Multiline textual content of the notification. Each line should be treated as a paragraph. Simple html markup should be supported, depending on the server implementation.
fn icon(&mut self, icon: &str) -> &mut Notification
Set the icon
field.
You can use common icon names here, usually those in /usr/share/icons
can all be used.
You can also use an absolute path to file.
fn auto_icon(&mut self) -> &mut Notification
Set the icon
field automatically.
This looks at your binaries name and uses it to set the icon.t
fn hint(&mut self, hint: NotificationHint) -> &mut Notification
Adds a hint.
This method will add a hint to the internal hint hashset. Hints must be of type NotificationHint.
Notification::new() .summary("Category:email") .body("This should not go away until you acknoledge it.") .icon("thunderbird") .appname("thunderbird") .hint(NotificationHint::Category("email".to_owned())) .hint(NotificationHint::Resident(true)) .show();
fn timeout(&mut self, timeout: i32) -> &mut Notification
Set the timeout
.
This sets the time (in miliseconds) from the time the notification is displayed until it is closed again by the Notification Server. According to specification -1 will leave the timeout to be set by the server and 0 will cause the notification never to expire.
fn urgency(&mut self, urgency: NotificationUrgency) -> &mut Notification
Set the urgency
.
Pick between Medium, Low and High.
fn actions(&mut self, actions: Vec<String>) -> &mut Notification
Set actions
.
To quote http://www.galago-project.org/specs/notification/0.9/x408.html#command-notify
Actions are sent over as a list of pairs. Each even element in the list (starting at index 0) represents the identifier for the action. Each odd element in the list is the localized string that will be displayed to the user.
There is nothing fancy going on here yet. Carefull! This replaces the internal list of actions!
fn action(&mut self, identifier: &str, label: &str) -> &mut Notification
Add an action.
This adds a single action to the internal list of actions.
fn id(&mut self, id: u32) -> &mut Notification
Set an Id ahead of time
Setting the id ahead of time allows overriding a known other notification.
Though if you want to update a notification, it is easier to use the update()
method of
the NotificationHandle
object that show()
returns.
fn finalize(&self) -> Notification
Finalizes a Notification.
Part of the builder pattern, returns a complete copy of the built notification.
fn show(&self) -> Result<NotificationHandle, Error>
Sends Notification to D-Bus.
Returns a handle to a notification
fn show_debug(&mut self) -> Result<NotificationHandle, Error>
Wraps show() but prints notification to stdout.
Trait Implementations
impl Debug for NotificationHandle
[src]
impl Deref for NotificationHandle
[src]
Required for DerefMut
type Target = Notification
The resulting type after dereferencing
fn deref(&self) -> &Notification
The method called to dereference a value
impl DerefMut for NotificationHandle
[src]
Allow to easily modify notification properties
fn deref_mut(&mut self) -> &mut Notification
The method called to mutably dereference a value