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().
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
extern crate libnotify;
|
||||
|
||||
fn main() {
|
||||
// Create a libnotify context
|
||||
let notify = libnotify::Context::new("myapp").unwrap();
|
||||
// Init libnotify
|
||||
libnotify::init("myapp").unwrap();
|
||||
// Create a new notification and show it
|
||||
let n = notify.new_notification("Summary", Some("Optional Body"), None)
|
||||
.unwrap();
|
||||
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
|
||||
notify.show("I am another notification", None, None).unwrap();
|
||||
n.update("I am another notification", None, None).unwrap();
|
||||
// Show the update notification
|
||||
n.show().unwrap();
|
||||
// We are done, deinit
|
||||
libnotify::uninit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user