Add Notification::set_hint()
This commit is contained in:
parent
cdc4af3be1
commit
95263c33f8
@ -14,3 +14,4 @@ keywords = ["libnotify", "notification"]
|
|||||||
libnotify-sys = "^0.5.0"
|
libnotify-sys = "^0.5.0"
|
||||||
glib-sys = "^0.3.4"
|
glib-sys = "^0.3.4"
|
||||||
gtypes = "^0.2.0"
|
gtypes = "^0.2.0"
|
||||||
|
glib = "^0.1.3"
|
||||||
|
23
src/lib.rs
23
src/lib.rs
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
extern crate libnotify_sys as sys;
|
extern crate libnotify_sys as sys;
|
||||||
extern crate glib_sys;
|
extern crate glib_sys;
|
||||||
|
extern crate glib;
|
||||||
extern crate gtypes;
|
extern crate gtypes;
|
||||||
|
|
||||||
use std::ffi::{self, CStr, CString};
|
use std::ffi::{self, CStr, CString};
|
||||||
@ -28,6 +29,7 @@ use std::os::raw::c_int;
|
|||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use glib::translate::*;
|
||||||
|
|
||||||
use gtypes::{TRUE, FALSE};
|
use gtypes::{TRUE, FALSE};
|
||||||
|
|
||||||
@ -254,6 +256,27 @@ impl<'a> Notification<'a> {
|
|||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets a hint for `key` with value `value`. If value is `None`,
|
||||||
|
/// then key is unset.
|
||||||
|
pub fn set_hint(&self, key: &str, value: Option<glib::variant::Variant>) -> Result<(), NotificationCreationError> {
|
||||||
|
let key = try!(CString::new(key));
|
||||||
|
|
||||||
|
let gvalue: *mut glib_sys::GVariant = {
|
||||||
|
match value {
|
||||||
|
Some(ref value) => value.to_glib_none().0,
|
||||||
|
None => std::ptr::null_mut(),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
sys::notify_notification_set_hint(self.handle,
|
||||||
|
key.as_ptr(),
|
||||||
|
gvalue)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error that can happen when attempting to show a notification.
|
/// An error that can happen when attempting to show a notification.
|
||||||
|
Loading…
Reference in New Issue
Block a user