From 393bc07d7f6680ad1cd3b5118ab7e54011f58c92 Mon Sep 17 00:00:00 2001 From: szymon Date: Wed, 30 Sep 2026 14:17:29 +0200 Subject: [PATCH] feat: implement show --- src/notification.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/notification.rs b/src/notification.rs index a8ae8d3..2f57781 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -249,7 +249,29 @@ impl<'a> Notification { /// Tells the notification server to display the notification on the screen pub fn show(&self) -> Result<(), Box> { - todo!(); + let mut gerror = std::ptr::null_mut() as *mut GError; + + if unsafe { notify_notification_show(self.inner, &mut gerror) } == 0 { + if gerror.is_null() { + return Err("Unknown error".into()); + } + + let err_msg = unsafe { *gerror }.message; + + if err_msg.is_null() { + unsafe { g_error_free(gerror) }; + return Err("Unknown error".into()); + } + + let err_msg_str = unsafe { std::ffi::CStr::from_ptr(err_msg) } + .to_string_lossy() + .to_string(); + + unsafe { g_error_free(gerror) }; + return Err(err_msg_str.into()); + } + + Ok(()) } /// Updates the notification text and icon.