gio/auto/
app_info_monitor.rs1use gio_sys;
6use glib::object::ObjectType as ObjectType_;
7use glib::signal::connect_raw;
8use glib::signal::SignalHandlerId;
9use glib::translate::*;
10use glib_sys;
11use std::boxed::Box as Box_;
12use std::fmt;
13use std::mem::transmute;
14
15glib_wrapper! {
16 pub struct AppInfoMonitor(Object<gio_sys::GAppInfoMonitor, AppInfoMonitorClass>);
17
18 match fn {
19 get_type => || gio_sys::g_app_info_monitor_get_type(),
20 }
21}
22
23impl AppInfoMonitor {
24 pub fn get() -> AppInfoMonitor {
25 unsafe { from_glib_full(gio_sys::g_app_info_monitor_get()) }
26 }
27
28 pub fn connect_changed<F: Fn(&AppInfoMonitor) + 'static>(&self, f: F) -> SignalHandlerId {
29 unsafe extern "C" fn changed_trampoline<F: Fn(&AppInfoMonitor) + 'static>(
30 this: *mut gio_sys::GAppInfoMonitor,
31 f: glib_sys::gpointer,
32 ) {
33 let f: &F = &*(f as *const F);
34 f(&from_glib_borrow(this))
35 }
36 unsafe {
37 let f: Box_<F> = Box_::new(f);
38 connect_raw(
39 self.as_ptr() as *mut _,
40 b"changed\0".as_ptr() as *const _,
41 Some(transmute(changed_trampoline::<F> as usize)),
42 Box_::into_raw(f),
43 )
44 }
45 }
46}
47
48impl fmt::Display for AppInfoMonitor {
49 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
50 write!(f, "AppInfoMonitor")
51 }
52}