gio/auto/
volume_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, Drive, Mount, Volume};
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 = "GVolumeMonitor")]
16    pub struct VolumeMonitor(Object<ffi::GVolumeMonitor, ffi::GVolumeMonitorClass>);
17
18    match fn {
19        type_ => || ffi::g_volume_monitor_get_type(),
20    }
21}
22
23impl VolumeMonitor {
24    pub const NONE: Option<&'static VolumeMonitor> = None;
25
26    #[doc(alias = "g_volume_monitor_get")]
27    pub fn get() -> VolumeMonitor {
28        unsafe { from_glib_full(ffi::g_volume_monitor_get()) }
29    }
30}
31
32pub trait VolumeMonitorExt: IsA<VolumeMonitor> + 'static {
33    #[doc(alias = "g_volume_monitor_get_connected_drives")]
34    #[doc(alias = "get_connected_drives")]
35    fn connected_drives(&self) -> Vec<Drive> {
36        unsafe {
37            FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_connected_drives(
38                self.as_ref().to_glib_none().0,
39            ))
40        }
41    }
42
43    #[doc(alias = "g_volume_monitor_get_mount_for_uuid")]
44    #[doc(alias = "get_mount_for_uuid")]
45    fn mount_for_uuid(&self, uuid: &str) -> Option<Mount> {
46        unsafe {
47            from_glib_full(ffi::g_volume_monitor_get_mount_for_uuid(
48                self.as_ref().to_glib_none().0,
49                uuid.to_glib_none().0,
50            ))
51        }
52    }
53
54    #[doc(alias = "g_volume_monitor_get_mounts")]
55    #[doc(alias = "get_mounts")]
56    fn mounts(&self) -> Vec<Mount> {
57        unsafe {
58            FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_mounts(
59                self.as_ref().to_glib_none().0,
60            ))
61        }
62    }
63
64    #[doc(alias = "g_volume_monitor_get_volume_for_uuid")]
65    #[doc(alias = "get_volume_for_uuid")]
66    fn volume_for_uuid(&self, uuid: &str) -> Option<Volume> {
67        unsafe {
68            from_glib_full(ffi::g_volume_monitor_get_volume_for_uuid(
69                self.as_ref().to_glib_none().0,
70                uuid.to_glib_none().0,
71            ))
72        }
73    }
74
75    #[doc(alias = "g_volume_monitor_get_volumes")]
76    #[doc(alias = "get_volumes")]
77    fn volumes(&self) -> Vec<Volume> {
78        unsafe {
79            FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_volumes(
80                self.as_ref().to_glib_none().0,
81            ))
82        }
83    }
84
85    #[doc(alias = "drive-changed")]
86    fn connect_drive_changed<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
87        unsafe extern "C" fn drive_changed_trampoline<
88            P: IsA<VolumeMonitor>,
89            F: Fn(&P, &Drive) + 'static,
90        >(
91            this: *mut ffi::GVolumeMonitor,
92            drive: *mut ffi::GDrive,
93            f: glib::ffi::gpointer,
94        ) {
95            let f: &F = &*(f as *const F);
96            f(
97                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
98                &from_glib_borrow(drive),
99            )
100        }
101        unsafe {
102            let f: Box_<F> = Box_::new(f);
103            connect_raw(
104                self.as_ptr() as *mut _,
105                c"drive-changed".as_ptr() as *const _,
106                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
107                    drive_changed_trampoline::<Self, F> as *const (),
108                )),
109                Box_::into_raw(f),
110            )
111        }
112    }
113
114    #[doc(alias = "drive-connected")]
115    fn connect_drive_connected<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
116        unsafe extern "C" fn drive_connected_trampoline<
117            P: IsA<VolumeMonitor>,
118            F: Fn(&P, &Drive) + 'static,
119        >(
120            this: *mut ffi::GVolumeMonitor,
121            drive: *mut ffi::GDrive,
122            f: glib::ffi::gpointer,
123        ) {
124            let f: &F = &*(f as *const F);
125            f(
126                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
127                &from_glib_borrow(drive),
128            )
129        }
130        unsafe {
131            let f: Box_<F> = Box_::new(f);
132            connect_raw(
133                self.as_ptr() as *mut _,
134                c"drive-connected".as_ptr() as *const _,
135                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
136                    drive_connected_trampoline::<Self, F> as *const (),
137                )),
138                Box_::into_raw(f),
139            )
140        }
141    }
142
143    #[doc(alias = "drive-disconnected")]
144    fn connect_drive_disconnected<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
145        unsafe extern "C" fn drive_disconnected_trampoline<
146            P: IsA<VolumeMonitor>,
147            F: Fn(&P, &Drive) + 'static,
148        >(
149            this: *mut ffi::GVolumeMonitor,
150            drive: *mut ffi::GDrive,
151            f: glib::ffi::gpointer,
152        ) {
153            let f: &F = &*(f as *const F);
154            f(
155                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
156                &from_glib_borrow(drive),
157            )
158        }
159        unsafe {
160            let f: Box_<F> = Box_::new(f);
161            connect_raw(
162                self.as_ptr() as *mut _,
163                c"drive-disconnected".as_ptr() as *const _,
164                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
165                    drive_disconnected_trampoline::<Self, F> as *const (),
166                )),
167                Box_::into_raw(f),
168            )
169        }
170    }
171
172    #[doc(alias = "drive-eject-button")]
173    fn connect_drive_eject_button<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
174        unsafe extern "C" fn drive_eject_button_trampoline<
175            P: IsA<VolumeMonitor>,
176            F: Fn(&P, &Drive) + 'static,
177        >(
178            this: *mut ffi::GVolumeMonitor,
179            drive: *mut ffi::GDrive,
180            f: glib::ffi::gpointer,
181        ) {
182            let f: &F = &*(f as *const F);
183            f(
184                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
185                &from_glib_borrow(drive),
186            )
187        }
188        unsafe {
189            let f: Box_<F> = Box_::new(f);
190            connect_raw(
191                self.as_ptr() as *mut _,
192                c"drive-eject-button".as_ptr() as *const _,
193                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
194                    drive_eject_button_trampoline::<Self, F> as *const (),
195                )),
196                Box_::into_raw(f),
197            )
198        }
199    }
200
201    #[doc(alias = "drive-stop-button")]
202    fn connect_drive_stop_button<F: Fn(&Self, &Drive) + 'static>(&self, f: F) -> SignalHandlerId {
203        unsafe extern "C" fn drive_stop_button_trampoline<
204            P: IsA<VolumeMonitor>,
205            F: Fn(&P, &Drive) + 'static,
206        >(
207            this: *mut ffi::GVolumeMonitor,
208            drive: *mut ffi::GDrive,
209            f: glib::ffi::gpointer,
210        ) {
211            let f: &F = &*(f as *const F);
212            f(
213                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
214                &from_glib_borrow(drive),
215            )
216        }
217        unsafe {
218            let f: Box_<F> = Box_::new(f);
219            connect_raw(
220                self.as_ptr() as *mut _,
221                c"drive-stop-button".as_ptr() as *const _,
222                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
223                    drive_stop_button_trampoline::<Self, F> as *const (),
224                )),
225                Box_::into_raw(f),
226            )
227        }
228    }
229
230    #[doc(alias = "mount-added")]
231    fn connect_mount_added<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
232        unsafe extern "C" fn mount_added_trampoline<
233            P: IsA<VolumeMonitor>,
234            F: Fn(&P, &Mount) + 'static,
235        >(
236            this: *mut ffi::GVolumeMonitor,
237            mount: *mut ffi::GMount,
238            f: glib::ffi::gpointer,
239        ) {
240            let f: &F = &*(f as *const F);
241            f(
242                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
243                &from_glib_borrow(mount),
244            )
245        }
246        unsafe {
247            let f: Box_<F> = Box_::new(f);
248            connect_raw(
249                self.as_ptr() as *mut _,
250                c"mount-added".as_ptr() as *const _,
251                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
252                    mount_added_trampoline::<Self, F> as *const (),
253                )),
254                Box_::into_raw(f),
255            )
256        }
257    }
258
259    #[doc(alias = "mount-changed")]
260    fn connect_mount_changed<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
261        unsafe extern "C" fn mount_changed_trampoline<
262            P: IsA<VolumeMonitor>,
263            F: Fn(&P, &Mount) + 'static,
264        >(
265            this: *mut ffi::GVolumeMonitor,
266            mount: *mut ffi::GMount,
267            f: glib::ffi::gpointer,
268        ) {
269            let f: &F = &*(f as *const F);
270            f(
271                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
272                &from_glib_borrow(mount),
273            )
274        }
275        unsafe {
276            let f: Box_<F> = Box_::new(f);
277            connect_raw(
278                self.as_ptr() as *mut _,
279                c"mount-changed".as_ptr() as *const _,
280                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
281                    mount_changed_trampoline::<Self, F> as *const (),
282                )),
283                Box_::into_raw(f),
284            )
285        }
286    }
287
288    #[doc(alias = "mount-pre-unmount")]
289    fn connect_mount_pre_unmount<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
290        unsafe extern "C" fn mount_pre_unmount_trampoline<
291            P: IsA<VolumeMonitor>,
292            F: Fn(&P, &Mount) + 'static,
293        >(
294            this: *mut ffi::GVolumeMonitor,
295            mount: *mut ffi::GMount,
296            f: glib::ffi::gpointer,
297        ) {
298            let f: &F = &*(f as *const F);
299            f(
300                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
301                &from_glib_borrow(mount),
302            )
303        }
304        unsafe {
305            let f: Box_<F> = Box_::new(f);
306            connect_raw(
307                self.as_ptr() as *mut _,
308                c"mount-pre-unmount".as_ptr() as *const _,
309                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
310                    mount_pre_unmount_trampoline::<Self, F> as *const (),
311                )),
312                Box_::into_raw(f),
313            )
314        }
315    }
316
317    #[doc(alias = "mount-removed")]
318    fn connect_mount_removed<F: Fn(&Self, &Mount) + 'static>(&self, f: F) -> SignalHandlerId {
319        unsafe extern "C" fn mount_removed_trampoline<
320            P: IsA<VolumeMonitor>,
321            F: Fn(&P, &Mount) + 'static,
322        >(
323            this: *mut ffi::GVolumeMonitor,
324            mount: *mut ffi::GMount,
325            f: glib::ffi::gpointer,
326        ) {
327            let f: &F = &*(f as *const F);
328            f(
329                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
330                &from_glib_borrow(mount),
331            )
332        }
333        unsafe {
334            let f: Box_<F> = Box_::new(f);
335            connect_raw(
336                self.as_ptr() as *mut _,
337                c"mount-removed".as_ptr() as *const _,
338                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
339                    mount_removed_trampoline::<Self, F> as *const (),
340                )),
341                Box_::into_raw(f),
342            )
343        }
344    }
345
346    #[doc(alias = "volume-added")]
347    fn connect_volume_added<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId {
348        unsafe extern "C" fn volume_added_trampoline<
349            P: IsA<VolumeMonitor>,
350            F: Fn(&P, &Volume) + 'static,
351        >(
352            this: *mut ffi::GVolumeMonitor,
353            volume: *mut ffi::GVolume,
354            f: glib::ffi::gpointer,
355        ) {
356            let f: &F = &*(f as *const F);
357            f(
358                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
359                &from_glib_borrow(volume),
360            )
361        }
362        unsafe {
363            let f: Box_<F> = Box_::new(f);
364            connect_raw(
365                self.as_ptr() as *mut _,
366                c"volume-added".as_ptr() as *const _,
367                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
368                    volume_added_trampoline::<Self, F> as *const (),
369                )),
370                Box_::into_raw(f),
371            )
372        }
373    }
374
375    #[doc(alias = "volume-changed")]
376    fn connect_volume_changed<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId {
377        unsafe extern "C" fn volume_changed_trampoline<
378            P: IsA<VolumeMonitor>,
379            F: Fn(&P, &Volume) + 'static,
380        >(
381            this: *mut ffi::GVolumeMonitor,
382            volume: *mut ffi::GVolume,
383            f: glib::ffi::gpointer,
384        ) {
385            let f: &F = &*(f as *const F);
386            f(
387                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
388                &from_glib_borrow(volume),
389            )
390        }
391        unsafe {
392            let f: Box_<F> = Box_::new(f);
393            connect_raw(
394                self.as_ptr() as *mut _,
395                c"volume-changed".as_ptr() as *const _,
396                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
397                    volume_changed_trampoline::<Self, F> as *const (),
398                )),
399                Box_::into_raw(f),
400            )
401        }
402    }
403
404    #[doc(alias = "volume-removed")]
405    fn connect_volume_removed<F: Fn(&Self, &Volume) + 'static>(&self, f: F) -> SignalHandlerId {
406        unsafe extern "C" fn volume_removed_trampoline<
407            P: IsA<VolumeMonitor>,
408            F: Fn(&P, &Volume) + 'static,
409        >(
410            this: *mut ffi::GVolumeMonitor,
411            volume: *mut ffi::GVolume,
412            f: glib::ffi::gpointer,
413        ) {
414            let f: &F = &*(f as *const F);
415            f(
416                VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(),
417                &from_glib_borrow(volume),
418            )
419        }
420        unsafe {
421            let f: Box_<F> = Box_::new(f);
422            connect_raw(
423                self.as_ptr() as *mut _,
424                c"volume-removed".as_ptr() as *const _,
425                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
426                    volume_removed_trampoline::<Self, F> as *const (),
427                )),
428                Box_::into_raw(f),
429            )
430        }
431    }
432}
433
434impl<O: IsA<VolumeMonitor>> VolumeMonitorExt for O {}