diff --git a/Cargo.toml b/Cargo.toml index fc21ee83..34b7f83d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,8 @@ keywords = ["libnotify", "notification"] [dependencies] libnotify-sys = "^0.5.0" +gdk-pixbuf = "^0.1.3" +gdk-pixbuf-sys = "^0.3.4" glib-sys = "^0.3.4" gtypes = "^0.2.0" glib = "^0.1.3" diff --git a/src/lib.rs b/src/lib.rs index d13e471d..cfd79d3e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,11 +19,14 @@ #![warn(missing_docs)] +extern crate gdk_pixbuf; +extern crate gdk_pixbuf_sys; extern crate glib; extern crate glib_sys; extern crate gtypes; extern crate libnotify_sys as sys; +use gdk_pixbuf_sys::GdkPixbuf; use glib::translate::*; use gtypes::{TRUE, FALSE}; use std::error::Error; @@ -338,6 +341,16 @@ impl<'a> Notification<'a> { urgency); } } + + /// Sets the image in the notification from a Pixbuf. + pub fn set_image_from_pixbuf(&self, pixbuf: &gdk_pixbuf::Pixbuf) { + let pixbuf: *mut GdkPixbuf = pixbuf.to_glib_none().0; + + unsafe { + sys::notify_notification_set_image_from_pixbuf(self.handle, + pixbuf); + } + } }