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