gio/auto/unix_mount_monitor.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use 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 /// Watches for changes to the set of mount entries and mount points in the
16 /// system.
17 ///
18 /// Connect to the [`mounts-changed`][struct@crate::GioUnix::MountMonitor#mounts-changed] signal to be
19 /// notified of changes to the `GioUnix::MountEntry` list.
20 ///
21 /// Connect to the [`mountpoints-changed`][struct@crate::GioUnix::MountMonitor#mountpoints-changed] signal to
22 /// be notified of changes to the `GioUnix::MountPoint` list.
23 ///
24 /// ## Signals
25 ///
26 ///
27 /// #### `mountpoints-changed`
28 /// Emitted when the Unix mount points have changed.
29 ///
30 ///
31 ///
32 ///
33 /// #### `mounts-changed`
34 /// Emitted when the Unix mount entries have changed.
35 ///
36 ///
37 ///
38 /// # Implements
39 ///
40 /// [`trait@glib::ObjectExt`]
41 #[doc(alias = "GUnixMountMonitor")]
42 pub struct UnixMountMonitor(Object<ffi::GUnixMountMonitor, ffi::GUnixMountMonitorClass>);
43
44 match fn {
45 type_ => || ffi::g_unix_mount_monitor_get_type(),
46 }
47}
48
49impl UnixMountMonitor {
50 /// Gets the `GioUnix::MountMonitor` for the current thread-default main
51 /// context.
52 ///
53 /// The mount monitor can be used to monitor for changes to the list of
54 /// mounted filesystems as well as the list of mount points (ie: fstab
55 /// entries).
56 ///
57 /// You must only call `GObject::Object::unref()` on the return value from
58 /// under the same main context as you called this function.
59 ///
60 /// # Returns
61 ///
62 /// the `GioUnix::MountMonitor`
63 #[doc(alias = "g_unix_mount_monitor_get")]
64 pub fn get() -> UnixMountMonitor {
65 unsafe { from_glib_full(ffi::g_unix_mount_monitor_get()) }
66 }
67
68 /// Emitted when the Unix mount points have changed.
69 #[doc(alias = "mountpoints-changed")]
70 pub fn connect_mountpoints_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
71 unsafe extern "C" fn mountpoints_changed_trampoline<F: Fn(&UnixMountMonitor) + 'static>(
72 this: *mut ffi::GUnixMountMonitor,
73 f: glib::ffi::gpointer,
74 ) {
75 let f: &F = &*(f as *const F);
76 f(&from_glib_borrow(this))
77 }
78 unsafe {
79 let f: Box_<F> = Box_::new(f);
80 connect_raw(
81 self.as_ptr() as *mut _,
82 b"mountpoints-changed\0".as_ptr() as *const _,
83 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
84 mountpoints_changed_trampoline::<F> as *const (),
85 )),
86 Box_::into_raw(f),
87 )
88 }
89 }
90
91 /// Emitted when the Unix mount entries have changed.
92 #[doc(alias = "mounts-changed")]
93 pub fn connect_mounts_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
94 unsafe extern "C" fn mounts_changed_trampoline<F: Fn(&UnixMountMonitor) + 'static>(
95 this: *mut ffi::GUnixMountMonitor,
96 f: glib::ffi::gpointer,
97 ) {
98 let f: &F = &*(f as *const F);
99 f(&from_glib_borrow(this))
100 }
101 unsafe {
102 let f: Box_<F> = Box_::new(f);
103 connect_raw(
104 self.as_ptr() as *mut _,
105 b"mounts-changed\0".as_ptr() as *const _,
106 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
107 mounts_changed_trampoline::<F> as *const (),
108 )),
109 Box_::into_raw(f),
110 )
111 }
112 }
113}