From f351cc15e2b459a19361af6484d9944e42eefc65 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 9 Jul 2017 19:33:53 +0200 Subject: [PATCH] Add Notification::close() --- src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 40551038..11fc1458 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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(()); + } }