gio/auto/
app_info_monitor.rs1use crate::ffi;
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{connect_raw, SignalHandlerId},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GAppInfoMonitor")]
16 pub struct AppInfoMonitor(Object<ffi::GAppInfoMonitor>);
17
18 match fn {
19 type_ => || ffi::g_app_info_monitor_get_type(),
20 }
21}
22
23impl AppInfoMonitor {
24 #[doc(alias = "g_app_info_monitor_get")]
25 pub fn get() -> AppInfoMonitor {
26 unsafe { from_glib_full(ffi::g_app_info_monitor_get()) }
27 }
28
29 #[doc(alias = "changed")]
30 pub fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
31 unsafe extern "C" fn changed_trampoline<F: Fn(&AppInfoMonitor) + 'static>(
32 this: *mut ffi::GAppInfoMonitor,
33 f: glib::ffi::gpointer,
34 ) {
35 let f: &F = &*(f as *const F);
36 f(&from_glib_borrow(this))
37 }
38 unsafe {
39 let f: Box_<F> = Box_::new(f);
40 connect_raw(
41 self.as_ptr() as *mut _,
42 c"changed".as_ptr() as *const _,
43 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
44 changed_trampoline::<F> as *const (),
45 )),
46 Box_::into_raw(f),
47 )
48 }
49 }
50}