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