rust-libnotify/examples/show.rs
Julian Ospald fe4d803efe
Small rewrite:
* Use error-chain for errors and expose them
* Don't use Context object, since the lifetimes get us in trouble
  when used with gtk-rs, which has callback closures with static
  lifetime. Instead we just expose notify_init()/notify_uninit() and
  panic when functions are called before notify_init().
2017-07-10 01:01:36 +02:00

19 lines
654 B
Rust

extern crate libnotify;
fn main() {
// Init libnotify
libnotify::init("myapp").unwrap();
// Create a new notification and show it
let n = libnotify::Notification::new_notification("Summary",
Some("Optional Body"),
None).unwrap();
// Show the notification
n.show().unwrap();
// You can also use the .show() convenience method on the context
n.update("I am another notification", None, None).unwrap();
// Show the update notification
n.show().unwrap();
// We are done, deinit
libnotify::uninit();
}