From 8c66220a4ee840905e57bddf4e5a448ca22eaf18 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 9 Jul 2017 14:21:31 +0200 Subject: [PATCH] Add Notification::set_notification_timeout() --- Cargo.toml | 2 +- src/lib.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 33d608fe..75b6dafc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,6 @@ documentation = "http://crumblingstatue.github.io/doc/libnotify/libnotify/" keywords = ["libnotify", "notification"] [dependencies] -libnotify-sys = "0.3" +libnotify-sys = "^0.5.0" glib-sys = "^0.3.4" gtypes = "^0.2.0" diff --git a/src/lib.rs b/src/lib.rs index 311fbd9d..99fbed01 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,6 +24,7 @@ extern crate glib_sys; extern crate gtypes; use std::ffi::{self, CStr, CString}; +use std::os::raw::c_int; use std::marker::PhantomData; use std::fmt; use std::error::Error; @@ -200,6 +201,18 @@ impl<'a> Notification<'a> { Ok(()) } } + + /// Set the notification timeout. Note that the server might ignore + /// the timeout. + pub fn set_notification_timeout(&self, timeout: i32) { + let _timeout: c_int = From::from(timeout); + + unsafe { + sys::notify_notification_set_timeout(self.handle, + _timeout) + + } + } } /// An error that can happen when attempting to show a notification.