1use crate::{AskPasswordFlags, MountOperationResult, PasswordSave, ffi};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 #[doc(alias = "GMountOperation")]
167 pub struct MountOperation(Object<ffi::GMountOperation, ffi::GMountOperationClass>);
168
169 match fn {
170 type_ => || ffi::g_mount_operation_get_type(),
171 }
172}
173
174impl MountOperation {
175 pub const NONE: Option<&'static MountOperation> = None;
176
177 #[doc(alias = "g_mount_operation_new")]
183 pub fn new() -> MountOperation {
184 unsafe { from_glib_full(ffi::g_mount_operation_new()) }
185 }
186}
187
188impl Default for MountOperation {
189 fn default() -> Self {
190 Self::new()
191 }
192}
193
194pub trait MountOperationExt: IsA<MountOperation> + 'static {
200 #[doc(alias = "g_mount_operation_get_anonymous")]
207 #[doc(alias = "get_anonymous")]
208 #[doc(alias = "anonymous")]
209 fn is_anonymous(&self) -> bool {
210 unsafe {
211 from_glib(ffi::g_mount_operation_get_anonymous(
212 self.as_ref().to_glib_none().0,
213 ))
214 }
215 }
216
217 #[doc(alias = "g_mount_operation_get_choice")]
224 #[doc(alias = "get_choice")]
225 fn choice(&self) -> i32 {
226 unsafe { ffi::g_mount_operation_get_choice(self.as_ref().to_glib_none().0) }
227 }
228
229 #[doc(alias = "g_mount_operation_get_domain")]
235 #[doc(alias = "get_domain")]
236 fn domain(&self) -> Option<glib::GString> {
237 unsafe {
238 from_glib_none(ffi::g_mount_operation_get_domain(
239 self.as_ref().to_glib_none().0,
240 ))
241 }
242 }
243
244 #[cfg(feature = "v2_58")]
251 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
252 #[doc(alias = "g_mount_operation_get_is_tcrypt_hidden_volume")]
253 #[doc(alias = "get_is_tcrypt_hidden_volume")]
254 #[doc(alias = "is-tcrypt-hidden-volume")]
255 fn is_tcrypt_hidden_volume(&self) -> bool {
256 unsafe {
257 from_glib(ffi::g_mount_operation_get_is_tcrypt_hidden_volume(
258 self.as_ref().to_glib_none().0,
259 ))
260 }
261 }
262
263 #[cfg(feature = "v2_58")]
270 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
271 #[doc(alias = "g_mount_operation_get_is_tcrypt_system_volume")]
272 #[doc(alias = "get_is_tcrypt_system_volume")]
273 #[doc(alias = "is-tcrypt-system-volume")]
274 fn is_tcrypt_system_volume(&self) -> bool {
275 unsafe {
276 from_glib(ffi::g_mount_operation_get_is_tcrypt_system_volume(
277 self.as_ref().to_glib_none().0,
278 ))
279 }
280 }
281
282 #[doc(alias = "g_mount_operation_get_password")]
288 #[doc(alias = "get_password")]
289 fn password(&self) -> Option<glib::GString> {
290 unsafe {
291 from_glib_none(ffi::g_mount_operation_get_password(
292 self.as_ref().to_glib_none().0,
293 ))
294 }
295 }
296
297 #[doc(alias = "g_mount_operation_get_password_save")]
303 #[doc(alias = "get_password_save")]
304 #[doc(alias = "password-save")]
305 fn password_save(&self) -> PasswordSave {
306 unsafe {
307 from_glib(ffi::g_mount_operation_get_password_save(
308 self.as_ref().to_glib_none().0,
309 ))
310 }
311 }
312
313 #[cfg(feature = "v2_58")]
319 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
320 #[doc(alias = "g_mount_operation_get_pim")]
321 #[doc(alias = "get_pim")]
322 fn pim(&self) -> u32 {
323 unsafe { ffi::g_mount_operation_get_pim(self.as_ref().to_glib_none().0) }
324 }
325
326 #[doc(alias = "g_mount_operation_get_username")]
332 #[doc(alias = "get_username")]
333 fn username(&self) -> Option<glib::GString> {
334 unsafe {
335 from_glib_none(ffi::g_mount_operation_get_username(
336 self.as_ref().to_glib_none().0,
337 ))
338 }
339 }
340
341 #[doc(alias = "g_mount_operation_reply")]
345 fn reply(&self, result: MountOperationResult) {
346 unsafe {
347 ffi::g_mount_operation_reply(self.as_ref().to_glib_none().0, result.into_glib());
348 }
349 }
350
351 #[doc(alias = "g_mount_operation_set_anonymous")]
355 #[doc(alias = "anonymous")]
356 fn set_anonymous(&self, anonymous: bool) {
357 unsafe {
358 ffi::g_mount_operation_set_anonymous(
359 self.as_ref().to_glib_none().0,
360 anonymous.into_glib(),
361 );
362 }
363 }
364
365 #[doc(alias = "g_mount_operation_set_choice")]
369 #[doc(alias = "choice")]
370 fn set_choice(&self, choice: i32) {
371 unsafe {
372 ffi::g_mount_operation_set_choice(self.as_ref().to_glib_none().0, choice);
373 }
374 }
375
376 #[doc(alias = "g_mount_operation_set_domain")]
380 #[doc(alias = "domain")]
381 fn set_domain(&self, domain: Option<&str>) {
382 unsafe {
383 ffi::g_mount_operation_set_domain(
384 self.as_ref().to_glib_none().0,
385 domain.to_glib_none().0,
386 );
387 }
388 }
389
390 #[cfg(feature = "v2_58")]
394 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
395 #[doc(alias = "g_mount_operation_set_is_tcrypt_hidden_volume")]
396 #[doc(alias = "is-tcrypt-hidden-volume")]
397 fn set_is_tcrypt_hidden_volume(&self, hidden_volume: bool) {
398 unsafe {
399 ffi::g_mount_operation_set_is_tcrypt_hidden_volume(
400 self.as_ref().to_glib_none().0,
401 hidden_volume.into_glib(),
402 );
403 }
404 }
405
406 #[cfg(feature = "v2_58")]
410 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
411 #[doc(alias = "g_mount_operation_set_is_tcrypt_system_volume")]
412 #[doc(alias = "is-tcrypt-system-volume")]
413 fn set_is_tcrypt_system_volume(&self, system_volume: bool) {
414 unsafe {
415 ffi::g_mount_operation_set_is_tcrypt_system_volume(
416 self.as_ref().to_glib_none().0,
417 system_volume.into_glib(),
418 );
419 }
420 }
421
422 #[doc(alias = "g_mount_operation_set_password")]
426 #[doc(alias = "password")]
427 fn set_password(&self, password: Option<&str>) {
428 unsafe {
429 ffi::g_mount_operation_set_password(
430 self.as_ref().to_glib_none().0,
431 password.to_glib_none().0,
432 );
433 }
434 }
435
436 #[doc(alias = "g_mount_operation_set_password_save")]
440 #[doc(alias = "password-save")]
441 fn set_password_save(&self, save: PasswordSave) {
442 unsafe {
443 ffi::g_mount_operation_set_password_save(
444 self.as_ref().to_glib_none().0,
445 save.into_glib(),
446 );
447 }
448 }
449
450 #[cfg(feature = "v2_58")]
454 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
455 #[doc(alias = "g_mount_operation_set_pim")]
456 #[doc(alias = "pim")]
457 fn set_pim(&self, pim: u32) {
458 unsafe {
459 ffi::g_mount_operation_set_pim(self.as_ref().to_glib_none().0, pim);
460 }
461 }
462
463 #[doc(alias = "g_mount_operation_set_username")]
467 #[doc(alias = "username")]
468 fn set_username(&self, username: Option<&str>) {
469 unsafe {
470 ffi::g_mount_operation_set_username(
471 self.as_ref().to_glib_none().0,
472 username.to_glib_none().0,
473 );
474 }
475 }
476
477 #[doc(alias = "aborted")]
483 fn connect_aborted<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
484 unsafe extern "C" fn aborted_trampoline<P: IsA<MountOperation>, F: Fn(&P) + 'static>(
485 this: *mut ffi::GMountOperation,
486 f: glib::ffi::gpointer,
487 ) {
488 unsafe {
489 let f: &F = &*(f as *const F);
490 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
491 }
492 }
493 unsafe {
494 let f: Box_<F> = Box_::new(f);
495 connect_raw(
496 self.as_ptr() as *mut _,
497 c"aborted".as_ptr(),
498 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
499 aborted_trampoline::<Self, F> as *const (),
500 )),
501 Box_::into_raw(f),
502 )
503 }
504 }
505
506 #[doc(alias = "ask-password")]
520 fn connect_ask_password<F: Fn(&Self, &str, &str, &str, AskPasswordFlags) + 'static>(
521 &self,
522 f: F,
523 ) -> SignalHandlerId {
524 unsafe extern "C" fn ask_password_trampoline<
525 P: IsA<MountOperation>,
526 F: Fn(&P, &str, &str, &str, AskPasswordFlags) + 'static,
527 >(
528 this: *mut ffi::GMountOperation,
529 message: *mut std::ffi::c_char,
530 default_user: *mut std::ffi::c_char,
531 default_domain: *mut std::ffi::c_char,
532 flags: ffi::GAskPasswordFlags,
533 f: glib::ffi::gpointer,
534 ) {
535 unsafe {
536 let f: &F = &*(f as *const F);
537 f(
538 MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
539 &glib::GString::from_glib_borrow(message),
540 &glib::GString::from_glib_borrow(default_user),
541 &glib::GString::from_glib_borrow(default_domain),
542 from_glib(flags),
543 )
544 }
545 }
546 unsafe {
547 let f: Box_<F> = Box_::new(f);
548 connect_raw(
549 self.as_ptr() as *mut _,
550 c"ask-password".as_ptr(),
551 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
552 ask_password_trampoline::<Self, F> as *const (),
553 )),
554 Box_::into_raw(f),
555 )
556 }
557 }
558
559 #[doc(alias = "reply")]
568 fn connect_reply<F: Fn(&Self, MountOperationResult) + 'static>(&self, f: F) -> SignalHandlerId {
569 unsafe extern "C" fn reply_trampoline<
570 P: IsA<MountOperation>,
571 F: Fn(&P, MountOperationResult) + 'static,
572 >(
573 this: *mut ffi::GMountOperation,
574 result: ffi::GMountOperationResult,
575 f: glib::ffi::gpointer,
576 ) {
577 unsafe {
578 let f: &F = &*(f as *const F);
579 f(
580 MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
581 from_glib(result),
582 )
583 }
584 }
585 unsafe {
586 let f: Box_<F> = Box_::new(f);
587 connect_raw(
588 self.as_ptr() as *mut _,
589 c"reply".as_ptr(),
590 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
591 reply_trampoline::<Self, F> as *const (),
592 )),
593 Box_::into_raw(f),
594 )
595 }
596 }
597
598 #[doc(alias = "show-unmount-progress")]
630 fn connect_show_unmount_progress<F: Fn(&Self, &str, i64, i64) + 'static>(
631 &self,
632 f: F,
633 ) -> SignalHandlerId {
634 unsafe extern "C" fn show_unmount_progress_trampoline<
635 P: IsA<MountOperation>,
636 F: Fn(&P, &str, i64, i64) + 'static,
637 >(
638 this: *mut ffi::GMountOperation,
639 message: *mut std::ffi::c_char,
640 time_left: i64,
641 bytes_left: i64,
642 f: glib::ffi::gpointer,
643 ) {
644 unsafe {
645 let f: &F = &*(f as *const F);
646 f(
647 MountOperation::from_glib_borrow(this).unsafe_cast_ref(),
648 &glib::GString::from_glib_borrow(message),
649 time_left,
650 bytes_left,
651 )
652 }
653 }
654 unsafe {
655 let f: Box_<F> = Box_::new(f);
656 connect_raw(
657 self.as_ptr() as *mut _,
658 c"show-unmount-progress".as_ptr(),
659 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
660 show_unmount_progress_trampoline::<Self, F> as *const (),
661 )),
662 Box_::into_raw(f),
663 )
664 }
665 }
666
667 #[doc(alias = "anonymous")]
668 fn connect_anonymous_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
669 unsafe extern "C" fn notify_anonymous_trampoline<
670 P: IsA<MountOperation>,
671 F: Fn(&P) + 'static,
672 >(
673 this: *mut ffi::GMountOperation,
674 _param_spec: glib::ffi::gpointer,
675 f: glib::ffi::gpointer,
676 ) {
677 unsafe {
678 let f: &F = &*(f as *const F);
679 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
680 }
681 }
682 unsafe {
683 let f: Box_<F> = Box_::new(f);
684 connect_raw(
685 self.as_ptr() as *mut _,
686 c"notify::anonymous".as_ptr(),
687 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
688 notify_anonymous_trampoline::<Self, F> as *const (),
689 )),
690 Box_::into_raw(f),
691 )
692 }
693 }
694
695 #[doc(alias = "choice")]
696 fn connect_choice_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
697 unsafe extern "C" fn notify_choice_trampoline<
698 P: IsA<MountOperation>,
699 F: Fn(&P) + 'static,
700 >(
701 this: *mut ffi::GMountOperation,
702 _param_spec: glib::ffi::gpointer,
703 f: glib::ffi::gpointer,
704 ) {
705 unsafe {
706 let f: &F = &*(f as *const F);
707 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
708 }
709 }
710 unsafe {
711 let f: Box_<F> = Box_::new(f);
712 connect_raw(
713 self.as_ptr() as *mut _,
714 c"notify::choice".as_ptr(),
715 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
716 notify_choice_trampoline::<Self, F> as *const (),
717 )),
718 Box_::into_raw(f),
719 )
720 }
721 }
722
723 #[doc(alias = "domain")]
724 fn connect_domain_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
725 unsafe extern "C" fn notify_domain_trampoline<
726 P: IsA<MountOperation>,
727 F: Fn(&P) + 'static,
728 >(
729 this: *mut ffi::GMountOperation,
730 _param_spec: glib::ffi::gpointer,
731 f: glib::ffi::gpointer,
732 ) {
733 unsafe {
734 let f: &F = &*(f as *const F);
735 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
736 }
737 }
738 unsafe {
739 let f: Box_<F> = Box_::new(f);
740 connect_raw(
741 self.as_ptr() as *mut _,
742 c"notify::domain".as_ptr(),
743 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
744 notify_domain_trampoline::<Self, F> as *const (),
745 )),
746 Box_::into_raw(f),
747 )
748 }
749 }
750
751 #[cfg(feature = "v2_58")]
752 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
753 #[doc(alias = "is-tcrypt-hidden-volume")]
754 fn connect_is_tcrypt_hidden_volume_notify<F: Fn(&Self) + 'static>(
755 &self,
756 f: F,
757 ) -> SignalHandlerId {
758 unsafe extern "C" fn notify_is_tcrypt_hidden_volume_trampoline<
759 P: IsA<MountOperation>,
760 F: Fn(&P) + 'static,
761 >(
762 this: *mut ffi::GMountOperation,
763 _param_spec: glib::ffi::gpointer,
764 f: glib::ffi::gpointer,
765 ) {
766 unsafe {
767 let f: &F = &*(f as *const F);
768 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
769 }
770 }
771 unsafe {
772 let f: Box_<F> = Box_::new(f);
773 connect_raw(
774 self.as_ptr() as *mut _,
775 c"notify::is-tcrypt-hidden-volume".as_ptr(),
776 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
777 notify_is_tcrypt_hidden_volume_trampoline::<Self, F> as *const (),
778 )),
779 Box_::into_raw(f),
780 )
781 }
782 }
783
784 #[cfg(feature = "v2_58")]
785 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
786 #[doc(alias = "is-tcrypt-system-volume")]
787 fn connect_is_tcrypt_system_volume_notify<F: Fn(&Self) + 'static>(
788 &self,
789 f: F,
790 ) -> SignalHandlerId {
791 unsafe extern "C" fn notify_is_tcrypt_system_volume_trampoline<
792 P: IsA<MountOperation>,
793 F: Fn(&P) + 'static,
794 >(
795 this: *mut ffi::GMountOperation,
796 _param_spec: glib::ffi::gpointer,
797 f: glib::ffi::gpointer,
798 ) {
799 unsafe {
800 let f: &F = &*(f as *const F);
801 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
802 }
803 }
804 unsafe {
805 let f: Box_<F> = Box_::new(f);
806 connect_raw(
807 self.as_ptr() as *mut _,
808 c"notify::is-tcrypt-system-volume".as_ptr(),
809 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
810 notify_is_tcrypt_system_volume_trampoline::<Self, F> as *const (),
811 )),
812 Box_::into_raw(f),
813 )
814 }
815 }
816
817 #[doc(alias = "password")]
818 fn connect_password_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
819 unsafe extern "C" fn notify_password_trampoline<
820 P: IsA<MountOperation>,
821 F: Fn(&P) + 'static,
822 >(
823 this: *mut ffi::GMountOperation,
824 _param_spec: glib::ffi::gpointer,
825 f: glib::ffi::gpointer,
826 ) {
827 unsafe {
828 let f: &F = &*(f as *const F);
829 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
830 }
831 }
832 unsafe {
833 let f: Box_<F> = Box_::new(f);
834 connect_raw(
835 self.as_ptr() as *mut _,
836 c"notify::password".as_ptr(),
837 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
838 notify_password_trampoline::<Self, F> as *const (),
839 )),
840 Box_::into_raw(f),
841 )
842 }
843 }
844
845 #[doc(alias = "password-save")]
846 fn connect_password_save_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
847 unsafe extern "C" fn notify_password_save_trampoline<
848 P: IsA<MountOperation>,
849 F: Fn(&P) + 'static,
850 >(
851 this: *mut ffi::GMountOperation,
852 _param_spec: glib::ffi::gpointer,
853 f: glib::ffi::gpointer,
854 ) {
855 unsafe {
856 let f: &F = &*(f as *const F);
857 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
858 }
859 }
860 unsafe {
861 let f: Box_<F> = Box_::new(f);
862 connect_raw(
863 self.as_ptr() as *mut _,
864 c"notify::password-save".as_ptr(),
865 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
866 notify_password_save_trampoline::<Self, F> as *const (),
867 )),
868 Box_::into_raw(f),
869 )
870 }
871 }
872
873 #[cfg(feature = "v2_58")]
874 #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
875 #[doc(alias = "pim")]
876 fn connect_pim_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
877 unsafe extern "C" fn notify_pim_trampoline<P: IsA<MountOperation>, F: Fn(&P) + 'static>(
878 this: *mut ffi::GMountOperation,
879 _param_spec: glib::ffi::gpointer,
880 f: glib::ffi::gpointer,
881 ) {
882 unsafe {
883 let f: &F = &*(f as *const F);
884 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
885 }
886 }
887 unsafe {
888 let f: Box_<F> = Box_::new(f);
889 connect_raw(
890 self.as_ptr() as *mut _,
891 c"notify::pim".as_ptr(),
892 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
893 notify_pim_trampoline::<Self, F> as *const (),
894 )),
895 Box_::into_raw(f),
896 )
897 }
898 }
899
900 #[doc(alias = "username")]
901 fn connect_username_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
902 unsafe extern "C" fn notify_username_trampoline<
903 P: IsA<MountOperation>,
904 F: Fn(&P) + 'static,
905 >(
906 this: *mut ffi::GMountOperation,
907 _param_spec: glib::ffi::gpointer,
908 f: glib::ffi::gpointer,
909 ) {
910 unsafe {
911 let f: &F = &*(f as *const F);
912 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
913 }
914 }
915 unsafe {
916 let f: Box_<F> = Box_::new(f);
917 connect_raw(
918 self.as_ptr() as *mut _,
919 c"notify::username".as_ptr(),
920 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
921 notify_username_trampoline::<Self, F> as *const (),
922 )),
923 Box_::into_raw(f),
924 )
925 }
926 }
927}
928
929impl<O: IsA<MountOperation>> MountOperationExt for O {}