mirror of
https://github.com/szymon-jozef/libnotify-rs.git
synced 2026-10-27 19:20:43 +01:00
feat: implement set_hint
This commit is contained in:
@@ -195,8 +195,31 @@ impl<'a> Notification {
|
|||||||
/// Sets a hint for key with value value
|
/// Sets a hint for key with value value
|
||||||
///
|
///
|
||||||
/// Available since: 0.6
|
/// Available since: 0.6
|
||||||
pub fn set_hint(&mut self, key: &str, value: HintValue) {
|
pub fn set_hint(
|
||||||
todo!();
|
&mut self,
|
||||||
|
key: &str,
|
||||||
|
value: HintValue,
|
||||||
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let key_c = std::ffi::CString::new(key)?;
|
||||||
|
|
||||||
|
let value_c = match value {
|
||||||
|
HintValue::String(s) => {
|
||||||
|
let s = std::ffi::CString::new(s)?;
|
||||||
|
unsafe { g_variant_new_string(s.as_ptr()) }
|
||||||
|
}
|
||||||
|
|
||||||
|
HintValue::Int32(i) => unsafe { g_variant_new_int32(i) },
|
||||||
|
|
||||||
|
HintValue::Boolean(b) => unsafe { g_variant_new_boolean(b as i32) },
|
||||||
|
};
|
||||||
|
|
||||||
|
if value_c.is_null() {
|
||||||
|
return Err("Couldn't create hint value".into());
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe { notify_notification_set_hint(self.inner, key_c.as_ptr(), value_c) };
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the timeout of the notification.
|
/// Sets the timeout of the notification.
|
||||||
|
|||||||
Reference in New Issue
Block a user