gio/auto/
mount_operation.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, AskPasswordFlags, MountOperationResult, PasswordSave};
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 = "GMountOperation")]
16    pub struct MountOperation(Object<ffi::GMountOperation, ffi::GMountOperationClass>);
17
18    match fn {
19        type_ => || ffi::g_mount_operation_get_type(),
20    }
21}
22
23impl MountOperation {
24    pub const NONE: Option<&'static MountOperation> = None;
25
26    #[doc(alias = "g_mount_operation_new")]
27    pub fn new() -> MountOperation {
28        unsafe { from_glib_full(ffi::g_mount_operation_new()) }
29    }
30}
31
32impl Default for MountOperation {
33    fn default() -> Self {
34        Self::new()
35    }
36}
37
38mod sealed {
39    pub trait Sealed {}
40    impl<T: super::IsA<super::MountOperation>> Sealed for T {}
41}
42
43pub trait MountOperationExt: IsA<MountOperation> + sealed::Sealed + 'static {
44    #[doc(alias = "g_mount_operation_get_anonymous")]
45    #[doc(alias = "get_anonymous")]
46    #[doc(alias = "anonymous")]
47    fn is_anonymous(&self) -> bool {
48        unsafe {
49            from_glib(ffi::g_mount_operation_get_anonymous(
50                self.as_ref().to_glib_none().0,
51            ))
52        }
53    }
54
55    #[doc(alias = "g_mount_operation_get_choice")]
56    #[doc(alias = "get_choice")]
57    fn choice(&self) -> i32 {
58        unsafe { ffi::g_mount_operation_get_choice(self.as_ref().to_glib_none().0) }
59    }
60
61    #[doc(alias = "g_mount_operation_get_domain")]
62    #[doc(alias = "get_domain")]
63    fn domain(&self) -> Option<glib::GString> {
64        unsafe {
65            from_glib_none(ffi::g_mount_operation_get_domain(
66                self.as_ref().to_glib_none().0,
67            ))
68        }
69    }
70
71    #[cfg(feature = "v2_58")]
72    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
73    #[doc(alias = "g_mount_operation_get_is_tcrypt_hidden_volume")]
74    #[doc(alias = "get_is_tcrypt_hidden_volume")]
75    #[doc(alias = "is-tcrypt-hidden-volume")]
76    fn is_tcrypt_hidden_volume(&self) -> bool {
77        unsafe {
78            from_glib(ffi::g_mount_operation_get_is_tcrypt_hidden_volume(
79                self.as_ref().to_glib_none().0,
80            ))
81        }
82    }
83
84    #[cfg(feature = "v2_58")]
85    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
86    #[doc(alias = "g_mount_operation_get_is_tcrypt_system_volume")]
87    #[doc(alias = "get_is_tcrypt_system_volume")]
88    #[doc(alias = "is-tcrypt-system-volume")]
89    fn is_tcrypt_system_volume(&self) -> bool {
90        unsafe {
91            from_glib(ffi::g_mount_operation_get_is_tcrypt_system_volume(
92                self.as_ref().to_glib_none().0,
93            ))
94        }
95    }
96
97    #[doc(alias = "g_mount_operation_get_password")]
98    #[doc(alias = "get_password")]
99    fn password(&self) -> Option<glib::GString> {
100        unsafe {
101            from_glib_none(ffi::g_mount_operation_get_password(
102                self.as_ref().to_glib_none().0,
103            ))
104        }
105    }
106
107    #[doc(alias = "g_mount_operation_get_password_save")]
108    #[doc(alias = "get_password_save")]
109    #[doc(alias = "password-save")]
110    fn password_save(&self) -> PasswordSave {
111        unsafe {
112            from_glib(ffi::g_mount_operation_get_password_save(
113                self.as_ref().to_glib_none().0,
114            ))
115        }
116    }
117
118    #[cfg(feature = "v2_58")]
119    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
120    #[doc(alias = "g_mount_operation_get_pim")]
121    #[doc(alias = "get_pim")]
122    fn pim(&self) -> u32 {
123        unsafe { ffi::g_mount_operation_get_pim(self.as_ref().to_glib_none().0) }
124    }
125
126    #[doc(alias = "g_mount_operation_get_username")]
127    #[doc(alias = "get_username")]
128    fn username(&self) -> Option<glib::GString> {
129        unsafe {
130            from_glib_none(ffi::g_mount_operation_get_username(
131                self.as_ref().to_glib_none().0,
132            ))
133        }
134    }
135
136    #[doc(alias = "g_mount_operation_reply")]
137    fn reply(&self, result: MountOperationResult) {
138        unsafe {
139            ffi::g_mount_operation_reply(self.as_ref().to_glib_none().0, result.into_glib());
140        }
141    }
142
143    #[doc(alias = "g_mount_operation_set_anonymous")]
144    #[doc(alias = "anonymous")]
145    fn set_anonymous(&self, anonymous: bool) {
146        unsafe {
147            ffi::g_mount_operation_set_anonymous(
148                self.as_ref().to_glib_none().0,
149                anonymous.into_glib(),
150            );
151        }
152    }
153
154    #[doc(alias = "g_mount_operation_set_choice")]
155    #[doc(alias = "choice")]
156    fn set_choice(&self, choice: i32) {
157        unsafe {
158            ffi::g_mount_operation_set_choice(self.as_ref().to_glib_none().0, choice);
159        }
160    }
161
162    #[doc(alias = "g_mount_operation_set_domain")]
163    #[doc(alias = "domain")]
164    fn set_domain(&self, domain: Option<&str>) {
165        unsafe {
166            ffi::g_mount_operation_set_domain(
167                self.as_ref().to_glib_none().0,
168                domain.to_glib_none().0,
169            );
170        }
171    }
172
173    #[cfg(feature = "v2_58")]
174    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
175    #[doc(alias = "g_mount_operation_set_is_tcrypt_hidden_volume")]
176    #[doc(alias = "is-tcrypt-hidden-volume")]
177    fn set_is_tcrypt_hidden_volume(&self, hidden_volume: bool) {
178        unsafe {
179            ffi::g_mount_operation_set_is_tcrypt_hidden_volume(
180                self.as_ref().to_glib_none().0,
181                hidden_volume.into_glib(),
182            );
183        }
184    }
185
186    #[cfg(feature = "v2_58")]
187    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
188    #[doc(alias = "g_mount_operation_set_is_tcrypt_system_volume")]
189    #[doc(alias = "is-tcrypt-system-volume")]
190    fn set_is_tcrypt_system_volume(&self, system_volume: bool) {
191        unsafe {
192            ffi::g_mount_operation_set_is_tcrypt_system_volume(
193                self.as_ref().to_glib_none().0,
194                system_volume.into_glib(),
195            );
196        }
197    }
198
199    #[doc(alias = "g_mount_operation_set_password")]
200    #[doc(alias = "password")]
201    fn set_password(&self, password: Option<&str>) {
202        unsafe {
203            ffi::g_mount_operation_set_password(
204                self.as_ref().to_glib_none().0,
205                password.to_glib_none().0,
206            );
207        }
208    }
209
210    #[doc(alias = "g_mount_operation_set_password_save")]
211    #[doc(alias = "password-save")]
212    fn set_password_save(&self, save: PasswordSave) {
213        unsafe {
214            ffi::g_mount_operation_set_password_save(
215                self.as_ref().to_glib_none().0,
216                save.into_glib(),
217            );
218        }
219    }
220
221    #[cfg(feature = "v2_58")]
222    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
223    #[doc(alias = "g_mount_operation_set_pim")]
224    #[doc(alias = "pim")]
225    fn set_pim(&self, pim: u32) {
226        unsafe {
227            ffi::g_mount_operation_set_pim(self.as_ref().to_glib_none().0, pim);
228        }
229    }
230
231    #[doc(alias = "g_mount_operation_set_username")]
232    #[doc(alias = "username")]
233    fn set_username(&self, username: Option<&str>) {
234        unsafe {
235            ffi::g_mount_operation_set_username(
236                self.as_ref().to_glib_none().0,
237                username.to_glib_none().0,
238            );
239        }
240    }
241
242    #[doc(alias = "aborted")]
243    fn connect_aborted<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
244        unsafe extern "C" fn aborted_trampoline<P: IsA<MountOperation>, F: Fn(&P) + 'static>(
245            this: *mut ffi::GMountOperation,
246            f: glib::ffi::gpointer,
247        ) {
248            let f: &F = &*(f as *const F);
249            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
250        }
251        unsafe {
252            let f: Box_<F> = Box_::new(f);
253            connect_raw(
254                self.as_ptr() as *mut _,
255                b"aborted\0".as_ptr() as *const _,
256                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
257                    aborted_trampoline::<Self, F> as *const (),
258                )),
259                Box_::into_raw(f),
260            )
261        }
262    }
263
264    #[doc(alias = "ask-password")]
265    fn connect_ask_password<F: Fn(&Self, &str, &str, &str, AskPasswordFlags) + 'static>(
266        &self,
267        f: F,
268    ) -> SignalHandlerId {
269        unsafe extern "C" fn ask_password_trampoline<
270            P: IsA<MountOperation>,
271            F: Fn(&P, &str, &str, &str, AskPasswordFlags) + 'static,
272        >(
273            this: *mut ffi::GMountOperation,
274            message: *mut std::ffi::c_char,
275            default_user: *mut std::ffi::c_char,
276            default_domain: *mut std::ffi::c_char,
277            flags: ffi::GAskPasswordFlags,
278            f: glib::ffi::gpointer,
279        ) {
280            let f: &F = &*(f as *const F);
281            f(
282                MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
283                &glib::GString::from_glib_borrow(message),
284                &glib::GString::from_glib_borrow(default_user),
285                &glib::GString::from_glib_borrow(default_domain),
286                from_glib(flags),
287            )
288        }
289        unsafe {
290            let f: Box_<F> = Box_::new(f);
291            connect_raw(
292                self.as_ptr() as *mut _,
293                b"ask-password\0".as_ptr() as *const _,
294                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
295                    ask_password_trampoline::<Self, F> as *const (),
296                )),
297                Box_::into_raw(f),
298            )
299        }
300    }
301
302    //#[doc(alias = "ask-question")]
303    //fn connect_ask_question<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
304    //    Empty ctype choices: *.CArray TypeId { ns_id: 0, id: 28 }
305    //}
306
307    #[doc(alias = "reply")]
308    fn connect_reply<F: Fn(&Self, MountOperationResult) + 'static>(&self, f: F) -> SignalHandlerId {
309        unsafe extern "C" fn reply_trampoline<
310            P: IsA<MountOperation>,
311            F: Fn(&P, MountOperationResult) + 'static,
312        >(
313            this: *mut ffi::GMountOperation,
314            result: ffi::GMountOperationResult,
315            f: glib::ffi::gpointer,
316        ) {
317            let f: &F = &*(f as *const F);
318            f(
319                MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
320                from_glib(result),
321            )
322        }
323        unsafe {
324            let f: Box_<F> = Box_::new(f);
325            connect_raw(
326                self.as_ptr() as *mut _,
327                b"reply\0".as_ptr() as *const _,
328                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
329                    reply_trampoline::<Self, F> as *const (),
330                )),
331                Box_::into_raw(f),
332            )
333        }
334    }
335
336    //#[doc(alias = "show-processes")]
337    //fn connect_show_processes<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId {
338    //    Empty ctype processes: *.Array TypeId { ns_id: 2, id: 4 }
339    //    Empty ctype choices: *.CArray TypeId { ns_id: 0, id: 28 }
340    //}
341
342    #[doc(alias = "show-unmount-progress")]
343    fn connect_show_unmount_progress<F: Fn(&Self, &str, i64, i64) + 'static>(
344        &self,
345        f: F,
346    ) -> SignalHandlerId {
347        unsafe extern "C" fn show_unmount_progress_trampoline<
348            P: IsA<MountOperation>,
349            F: Fn(&P, &str, i64, i64) + 'static,
350        >(
351            this: *mut ffi::GMountOperation,
352            message: *mut std::ffi::c_char,
353            time_left: i64,
354            bytes_left: i64,
355            f: glib::ffi::gpointer,
356        ) {
357            let f: &F = &*(f as *const F);
358            f(
359                MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
360                &glib::GString::from_glib_borrow(message),
361                time_left,
362                bytes_left,
363            )
364        }
365        unsafe {
366            let f: Box_<F> = Box_::new(f);
367            connect_raw(
368                self.as_ptr() as *mut _,
369                b"show-unmount-progress\0".as_ptr() as *const _,
370                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
371                    show_unmount_progress_trampoline::<Self, F> as *const (),
372                )),
373                Box_::into_raw(f),
374            )
375        }
376    }
377
378    #[doc(alias = "anonymous")]
379    fn connect_anonymous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
380        unsafe extern "C" fn notify_anonymous_trampoline<
381            P: IsA<MountOperation>,
382            F: Fn(&P) + 'static,
383        >(
384            this: *mut ffi::GMountOperation,
385            _param_spec: glib::ffi::gpointer,
386            f: glib::ffi::gpointer,
387        ) {
388            let f: &F = &*(f as *const F);
389            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
390        }
391        unsafe {
392            let f: Box_<F> = Box_::new(f);
393            connect_raw(
394                self.as_ptr() as *mut _,
395                b"notify::anonymous\0".as_ptr() as *const _,
396                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
397                    notify_anonymous_trampoline::<Self, F> as *const (),
398                )),
399                Box_::into_raw(f),
400            )
401        }
402    }
403
404    #[doc(alias = "choice")]
405    fn connect_choice_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
406        unsafe extern "C" fn notify_choice_trampoline<
407            P: IsA<MountOperation>,
408            F: Fn(&P) + 'static,
409        >(
410            this: *mut ffi::GMountOperation,
411            _param_spec: glib::ffi::gpointer,
412            f: glib::ffi::gpointer,
413        ) {
414            let f: &F = &*(f as *const F);
415            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
416        }
417        unsafe {
418            let f: Box_<F> = Box_::new(f);
419            connect_raw(
420                self.as_ptr() as *mut _,
421                b"notify::choice\0".as_ptr() as *const _,
422                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
423                    notify_choice_trampoline::<Self, F> as *const (),
424                )),
425                Box_::into_raw(f),
426            )
427        }
428    }
429
430    #[doc(alias = "domain")]
431    fn connect_domain_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
432        unsafe extern "C" fn notify_domain_trampoline<
433            P: IsA<MountOperation>,
434            F: Fn(&P) + 'static,
435        >(
436            this: *mut ffi::GMountOperation,
437            _param_spec: glib::ffi::gpointer,
438            f: glib::ffi::gpointer,
439        ) {
440            let f: &F = &*(f as *const F);
441            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
442        }
443        unsafe {
444            let f: Box_<F> = Box_::new(f);
445            connect_raw(
446                self.as_ptr() as *mut _,
447                b"notify::domain\0".as_ptr() as *const _,
448                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
449                    notify_domain_trampoline::<Self, F> as *const (),
450                )),
451                Box_::into_raw(f),
452            )
453        }
454    }
455
456    #[cfg(feature = "v2_58")]
457    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
458    #[doc(alias = "is-tcrypt-hidden-volume")]
459    fn connect_is_tcrypt_hidden_volume_notify<F: Fn(&Self) + 'static>(
460        &self,
461        f: F,
462    ) -> SignalHandlerId {
463        unsafe extern "C" fn notify_is_tcrypt_hidden_volume_trampoline<
464            P: IsA<MountOperation>,
465            F: Fn(&P) + 'static,
466        >(
467            this: *mut ffi::GMountOperation,
468            _param_spec: glib::ffi::gpointer,
469            f: glib::ffi::gpointer,
470        ) {
471            let f: &F = &*(f as *const F);
472            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
473        }
474        unsafe {
475            let f: Box_<F> = Box_::new(f);
476            connect_raw(
477                self.as_ptr() as *mut _,
478                b"notify::is-tcrypt-hidden-volume\0".as_ptr() as *const _,
479                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480                    notify_is_tcrypt_hidden_volume_trampoline::<Self, F> as *const (),
481                )),
482                Box_::into_raw(f),
483            )
484        }
485    }
486
487    #[cfg(feature = "v2_58")]
488    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
489    #[doc(alias = "is-tcrypt-system-volume")]
490    fn connect_is_tcrypt_system_volume_notify<F: Fn(&Self) + 'static>(
491        &self,
492        f: F,
493    ) -> SignalHandlerId {
494        unsafe extern "C" fn notify_is_tcrypt_system_volume_trampoline<
495            P: IsA<MountOperation>,
496            F: Fn(&P) + 'static,
497        >(
498            this: *mut ffi::GMountOperation,
499            _param_spec: glib::ffi::gpointer,
500            f: glib::ffi::gpointer,
501        ) {
502            let f: &F = &*(f as *const F);
503            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
504        }
505        unsafe {
506            let f: Box_<F> = Box_::new(f);
507            connect_raw(
508                self.as_ptr() as *mut _,
509                b"notify::is-tcrypt-system-volume\0".as_ptr() as *const _,
510                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
511                    notify_is_tcrypt_system_volume_trampoline::<Self, F> as *const (),
512                )),
513                Box_::into_raw(f),
514            )
515        }
516    }
517
518    #[doc(alias = "password")]
519    fn connect_password_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
520        unsafe extern "C" fn notify_password_trampoline<
521            P: IsA<MountOperation>,
522            F: Fn(&P) + 'static,
523        >(
524            this: *mut ffi::GMountOperation,
525            _param_spec: glib::ffi::gpointer,
526            f: glib::ffi::gpointer,
527        ) {
528            let f: &F = &*(f as *const F);
529            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
530        }
531        unsafe {
532            let f: Box_<F> = Box_::new(f);
533            connect_raw(
534                self.as_ptr() as *mut _,
535                b"notify::password\0".as_ptr() as *const _,
536                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
537                    notify_password_trampoline::<Self, F> as *const (),
538                )),
539                Box_::into_raw(f),
540            )
541        }
542    }
543
544    #[doc(alias = "password-save")]
545    fn connect_password_save_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
546        unsafe extern "C" fn notify_password_save_trampoline<
547            P: IsA<MountOperation>,
548            F: Fn(&P) + 'static,
549        >(
550            this: *mut ffi::GMountOperation,
551            _param_spec: glib::ffi::gpointer,
552            f: glib::ffi::gpointer,
553        ) {
554            let f: &F = &*(f as *const F);
555            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
556        }
557        unsafe {
558            let f: Box_<F> = Box_::new(f);
559            connect_raw(
560                self.as_ptr() as *mut _,
561                b"notify::password-save\0".as_ptr() as *const _,
562                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
563                    notify_password_save_trampoline::<Self, F> as *const (),
564                )),
565                Box_::into_raw(f),
566            )
567        }
568    }
569
570    #[cfg(feature = "v2_58")]
571    #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
572    #[doc(alias = "pim")]
573    fn connect_pim_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
574        unsafe extern "C" fn notify_pim_trampoline<P: IsA<MountOperation>, F: Fn(&P) + 'static>(
575            this: *mut ffi::GMountOperation,
576            _param_spec: glib::ffi::gpointer,
577            f: glib::ffi::gpointer,
578        ) {
579            let f: &F = &*(f as *const F);
580            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
581        }
582        unsafe {
583            let f: Box_<F> = Box_::new(f);
584            connect_raw(
585                self.as_ptr() as *mut _,
586                b"notify::pim\0".as_ptr() as *const _,
587                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
588                    notify_pim_trampoline::<Self, F> as *const (),
589                )),
590                Box_::into_raw(f),
591            )
592        }
593    }
594
595    #[doc(alias = "username")]
596    fn connect_username_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
597        unsafe extern "C" fn notify_username_trampoline<
598            P: IsA<MountOperation>,
599            F: Fn(&P) + 'static,
600        >(
601            this: *mut ffi::GMountOperation,
602            _param_spec: glib::ffi::gpointer,
603            f: glib::ffi::gpointer,
604        ) {
605            let f: &F = &*(f as *const F);
606            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
607        }
608        unsafe {
609            let f: Box_<F> = Box_::new(f);
610            connect_raw(
611                self.as_ptr() as *mut _,
612                b"notify::username\0".as_ptr() as *const _,
613                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
614                    notify_username_trampoline::<Self, F> as *const (),
615                )),
616                Box_::into_raw(f),
617            )
618        }
619    }
620}
621
622impl<O: IsA<MountOperation>> MountOperationExt for O {}