Rename new_notification() to new()
This commit is contained in:
parent
fe4d803efe
commit
437f2cc756
@ -4,9 +4,9 @@ fn main() {
|
|||||||
// Init libnotify
|
// Init libnotify
|
||||||
libnotify::init("myapp").unwrap();
|
libnotify::init("myapp").unwrap();
|
||||||
// Create a new notification and show it
|
// Create a new notification and show it
|
||||||
let n = libnotify::Notification::new_notification("Summary",
|
let n =
|
||||||
Some("Optional Body"),
|
libnotify::Notification::new("Summary", Some("Optional Body"), None)
|
||||||
None).unwrap();
|
.unwrap();
|
||||||
// Show the notification
|
// Show the notification
|
||||||
n.show().unwrap();
|
n.show().unwrap();
|
||||||
// You can also use the .show() convenience method on the context
|
// You can also use the .show() convenience method on the context
|
||||||
|
25
src/lib.rs
25
src/lib.rs
@ -4,15 +4,20 @@
|
|||||||
//! extern crate libnotify;
|
//! extern crate libnotify;
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! // Create a libnotify context
|
//! // Init libnotify
|
||||||
//! let notify = libnotify::Context::new("myapp").unwrap();
|
//! libnotify::init("myapp").unwrap();
|
||||||
//! // Create a new notification and show it
|
//! // Create a new notification and show it
|
||||||
//! let n = notify.new_notification("Summary",
|
//! let n = libnotify::Notification::new("Summary",
|
||||||
//! Some("Optional Body"),
|
//! Some("Optional Body"),
|
||||||
//! None).unwrap();
|
//! None).unwrap();
|
||||||
|
//! // Show the notification
|
||||||
//! n.show().unwrap();
|
//! n.show().unwrap();
|
||||||
//! // You can also use the .show() convenience method on the context
|
//! // 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();
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
@ -94,10 +99,10 @@ impl Notification {
|
|||||||
/// - summary: Required summary text
|
/// - summary: Required summary text
|
||||||
/// - body: Optional body text
|
/// - body: Optional body text
|
||||||
/// - icon: Optional icon theme icon name or filename
|
/// - icon: Optional icon theme icon name or filename
|
||||||
pub fn new_notification(summary: &str,
|
pub fn new(summary: &str,
|
||||||
body: Option<&str>,
|
body: Option<&str>,
|
||||||
icon: Option<&str>)
|
icon: Option<&str>)
|
||||||
-> Result<Notification> {
|
-> Result<Notification> {
|
||||||
init_panic!();
|
init_panic!();
|
||||||
let summary = CString::new(summary)?;
|
let summary = CString::new(summary)?;
|
||||||
let body = match body {
|
let body = match body {
|
||||||
|
Loading…
Reference in New Issue
Block a user