Add Notification::close()

This commit is contained in:
Julian Ospald 2017-07-09 19:33:53 +02:00
parent b77584e0a0
commit f351cc15e2
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

View File

@ -358,6 +358,27 @@ impl<'a> Notification<'a> {
sys::notify_notification_clear_hints(self.handle);
}
}
/// Synchronously tells the notification server to hide the
/// notification on the screen.
pub fn close(&self) -> Result<(), NotificationShowError> {
unsafe {
let mut err: *mut glib_sys::GError = std::ptr::null_mut();
sys::notify_notification_close(self.handle,
&mut err);
if !err.is_null() {
let result = Err(NotificationShowError {
message: CStr::from_ptr((*err).message)
.to_string_lossy()
.into_owned(),
});
glib_sys::g_error_free(err);
return result;
}
}
return Ok(());
}
}