Add Notification::set_image_from_pixbuf()

This commit is contained in:
Julian Ospald 2017-07-09 19:33:13 +02:00
parent 6166c861e4
commit c3897b7c0e
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 15 additions and 0 deletions

View File

@ -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"

View File

@ -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);
}
}
}