Add Drop impl for Notification
The notification is now unrefed via the GObject system.
This commit is contained in:
parent
437f2cc756
commit
9f6e3f5d31
@ -16,5 +16,6 @@ libnotify-sys = "^0.5.0"
|
|||||||
gdk-pixbuf = "^0.1.3"
|
gdk-pixbuf = "^0.1.3"
|
||||||
gdk-pixbuf-sys = "^0.3.4"
|
gdk-pixbuf-sys = "^0.3.4"
|
||||||
glib-sys = "^0.3.4"
|
glib-sys = "^0.3.4"
|
||||||
|
gobject-sys = "^0.3.4"
|
||||||
gtypes = "^0.2.0"
|
gtypes = "^0.2.0"
|
||||||
glib = "^0.1.3"
|
glib = "^0.1.3"
|
||||||
|
18
src/lib.rs
18
src/lib.rs
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate error_chain;
|
extern crate error_chain;
|
||||||
|
extern crate gobject_sys;
|
||||||
extern crate gdk_pixbuf;
|
extern crate gdk_pixbuf;
|
||||||
extern crate gdk_pixbuf_sys;
|
extern crate gdk_pixbuf_sys;
|
||||||
extern crate glib;
|
extern crate glib;
|
||||||
@ -91,6 +92,23 @@ pub struct Notification {
|
|||||||
handle: *mut sys::NotifyNotification,
|
handle: *mut sys::NotifyNotification,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Drop for Notification {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
unsafe {
|
||||||
|
if gobject_sys::g_type_check_instance_is_a(
|
||||||
|
self.handle as *mut gobject_sys::GTypeInstance,
|
||||||
|
gobject_sys::G_TYPE_OBJECT,
|
||||||
|
) == FALSE
|
||||||
|
{
|
||||||
|
panic!("Not a GObject!");
|
||||||
|
}
|
||||||
|
let gobject = self.handle as
|
||||||
|
*mut gobject_sys::GObject;
|
||||||
|
gobject_sys::g_object_unref(gobject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Notification {
|
impl Notification {
|
||||||
/// Creates a new Notification.
|
/// Creates a new Notification.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user