// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
    pub struct AppInfoMonitor(Object<ffi::GAppInfoMonitor>);

    match fn {
        get_type => || ffi::g_app_info_monitor_get_type(),
    }
}

impl AppInfoMonitor {
    #[cfg(any(feature = "v2_40", feature = "dox"))]
    pub fn get() -> AppInfoMonitor {
        unsafe {
            from_glib_full(ffi::g_app_info_monitor_get())
        }
    }
}

pub trait AppInfoMonitorExt {
    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<AppInfoMonitor> + IsA<glib::object::Object>> AppInfoMonitorExt for O {
    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "changed",
                transmute(changed_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn changed_trampoline<P>(this: *mut ffi::GAppInfoMonitor, f: glib_ffi::gpointer)
where P: IsA<AppInfoMonitor> {
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&AppInfoMonitor::from_glib_borrow(this).downcast_unchecked())
}
