Skip to main content

gtk/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::{Window, ffi};
6use glib::{
7    prelude::*,
8    signal::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    /// This should not be accessed directly. Use the accessor functions below.
15    ///
16    /// ## Properties
17    ///
18    ///
19    /// #### `is-showing`
20    ///  Readable
21    ///
22    ///
23    /// #### `parent`
24    ///  Readable | Writable
25    ///
26    ///
27    /// #### `screen`
28    ///  Readable | Writable
29    /// <details><summary><h4>MountOperation</h4></summary>
30    ///
31    ///
32    /// #### `anonymous`
33    ///  Whether to use an anonymous user when authenticating.
34    ///
35    /// Readable | Writable
36    ///
37    ///
38    /// #### `choice`
39    ///  The index of the user's choice when a question is asked during the
40    /// mount operation. See the [`ask-question`][struct@crate::gio::MountOperation#ask-question] signal.
41    ///
42    /// Readable | Writable
43    ///
44    ///
45    /// #### `domain`
46    ///  The domain to use for the mount operation.
47    ///
48    /// Readable | Writable
49    ///
50    ///
51    /// #### `is-tcrypt-hidden-volume`
52    ///  Whether the device to be unlocked is a TCRYPT hidden volume.
53    /// See [the VeraCrypt documentation](https://www.veracrypt.fr/en/Hidden`20Volume`).
54    ///
55    /// Readable | Writable
56    ///
57    ///
58    /// #### `is-tcrypt-system-volume`
59    ///  Whether the device to be unlocked is a TCRYPT system volume.
60    /// In this context, a system volume is a volume with a bootloader
61    /// and operating system installed. This is only supported for Windows
62    /// operating systems. For further documentation, see
63    /// [the VeraCrypt documentation](https://www.veracrypt.fr/en/System`20Encryption`).
64    ///
65    /// Readable | Writable
66    ///
67    ///
68    /// #### `password`
69    ///  The password that is used for authentication when carrying out
70    /// the mount operation.
71    ///
72    /// Readable | Writable
73    ///
74    ///
75    /// #### `password-save`
76    ///  Determines if and how the password information should be saved.
77    ///
78    /// Readable | Writable
79    ///
80    ///
81    /// #### `pim`
82    ///  The VeraCrypt PIM value, when unlocking a VeraCrypt volume. See
83    /// [the VeraCrypt documentation](https://www.veracrypt.fr/en/Personal`20Iterations``20Multiplier``20`(PIM).html).
84    ///
85    /// Readable | Writable
86    ///
87    ///
88    /// #### `username`
89    ///  The user name that is used for authentication when carrying out
90    /// the mount operation.
91    ///
92    /// Readable | Writable
93    /// </details>
94    ///
95    /// # Implements
96    ///
97    /// [`GtkMountOperationExt`][trait@crate::prelude::GtkMountOperationExt], [`trait@gio::prelude::MountOperationExt`], [`trait@glib::ObjectExt`]
98    #[doc(alias = "GtkMountOperation")]
99    pub struct MountOperation(Object<ffi::GtkMountOperation, ffi::GtkMountOperationClass>) @extends gio::MountOperation;
100
101    match fn {
102        type_ => || ffi::gtk_mount_operation_get_type(),
103    }
104}
105
106impl MountOperation {
107    pub const NONE: Option<&'static MountOperation> = None;
108
109    /// Creates a new [`MountOperation`][crate::MountOperation]
110    /// ## `parent`
111    /// transient parent of the window, or [`None`]
112    ///
113    /// # Returns
114    ///
115    /// a new [`MountOperation`][crate::MountOperation]
116    #[doc(alias = "gtk_mount_operation_new")]
117    pub fn new(parent: Option<&impl IsA<Window>>) -> MountOperation {
118        assert_initialized_main_thread!();
119        unsafe {
120            gio::MountOperation::from_glib_full(ffi::gtk_mount_operation_new(
121                parent.map(|p| p.as_ref()).to_glib_none().0,
122            ))
123            .unsafe_cast()
124        }
125    }
126
127    // rustdoc-stripper-ignore-next
128    /// Creates a new builder-pattern struct instance to construct [`MountOperation`] objects.
129    ///
130    /// This method returns an instance of [`MountOperationBuilder`](crate::builders::MountOperationBuilder) which can be used to create [`MountOperation`] objects.
131    pub fn builder() -> MountOperationBuilder {
132        MountOperationBuilder::new()
133    }
134}
135
136impl Default for MountOperation {
137    fn default() -> Self {
138        glib::object::Object::new::<Self>()
139    }
140}
141
142// rustdoc-stripper-ignore-next
143/// A [builder-pattern] type to construct [`MountOperation`] objects.
144///
145/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
146#[must_use = "The builder must be built to be used"]
147pub struct MountOperationBuilder {
148    builder: glib::object::ObjectBuilder<'static, MountOperation>,
149}
150
151impl MountOperationBuilder {
152    fn new() -> Self {
153        Self {
154            builder: glib::object::Object::builder(),
155        }
156    }
157
158    pub fn parent(self, parent: &impl IsA<Window>) -> Self {
159        Self {
160            builder: self.builder.property("parent", parent.clone().upcast()),
161        }
162    }
163
164    pub fn screen(self, screen: &gdk::Screen) -> Self {
165        Self {
166            builder: self.builder.property("screen", screen.clone()),
167        }
168    }
169
170    /// Whether to use an anonymous user when authenticating.
171    pub fn anonymous(self, anonymous: bool) -> Self {
172        Self {
173            builder: self.builder.property("anonymous", anonymous),
174        }
175    }
176
177    /// The index of the user's choice when a question is asked during the
178    /// mount operation. See the [`ask-question`][struct@crate::gio::MountOperation#ask-question] signal.
179    pub fn choice(self, choice: i32) -> Self {
180        Self {
181            builder: self.builder.property("choice", choice),
182        }
183    }
184
185    /// The domain to use for the mount operation.
186    pub fn domain(self, domain: impl Into<glib::GString>) -> Self {
187        Self {
188            builder: self.builder.property("domain", domain.into()),
189        }
190    }
191
192    /// Whether the device to be unlocked is a TCRYPT hidden volume.
193    /// See [the VeraCrypt documentation](https://www.veracrypt.fr/en/Hidden`20Volume`).
194    #[cfg(feature = "gio_v2_58")]
195    #[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_58")))]
196    pub fn is_tcrypt_hidden_volume(self, is_tcrypt_hidden_volume: bool) -> Self {
197        Self {
198            builder: self
199                .builder
200                .property("is-tcrypt-hidden-volume", is_tcrypt_hidden_volume),
201        }
202    }
203
204    /// Whether the device to be unlocked is a TCRYPT system volume.
205    /// In this context, a system volume is a volume with a bootloader
206    /// and operating system installed. This is only supported for Windows
207    /// operating systems. For further documentation, see
208    /// [the VeraCrypt documentation](https://www.veracrypt.fr/en/System`20Encryption`).
209    #[cfg(feature = "gio_v2_58")]
210    #[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_58")))]
211    pub fn is_tcrypt_system_volume(self, is_tcrypt_system_volume: bool) -> Self {
212        Self {
213            builder: self
214                .builder
215                .property("is-tcrypt-system-volume", is_tcrypt_system_volume),
216        }
217    }
218
219    /// The password that is used for authentication when carrying out
220    /// the mount operation.
221    pub fn password(self, password: impl Into<glib::GString>) -> Self {
222        Self {
223            builder: self.builder.property("password", password.into()),
224        }
225    }
226
227    /// Determines if and how the password information should be saved.
228    pub fn password_save(self, password_save: gio::PasswordSave) -> Self {
229        Self {
230            builder: self.builder.property("password-save", password_save),
231        }
232    }
233
234    /// The VeraCrypt PIM value, when unlocking a VeraCrypt volume. See
235    /// [the VeraCrypt documentation](https://www.veracrypt.fr/en/Personal`20Iterations``20Multiplier``20`(PIM).html).
236    #[cfg(feature = "gio_v2_58")]
237    #[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_58")))]
238    pub fn pim(self, pim: u32) -> Self {
239        Self {
240            builder: self.builder.property("pim", pim),
241        }
242    }
243
244    /// The user name that is used for authentication when carrying out
245    /// the mount operation.
246    pub fn username(self, username: impl Into<glib::GString>) -> Self {
247        Self {
248            builder: self.builder.property("username", username.into()),
249        }
250    }
251
252    // rustdoc-stripper-ignore-next
253    /// Build the [`MountOperation`].
254    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
255    pub fn build(self) -> MountOperation {
256        assert_initialized_main_thread!();
257        self.builder.build()
258    }
259}
260
261/// Trait containing all [`struct@MountOperation`] methods.
262///
263/// # Implementors
264///
265/// [`MountOperation`][struct@crate::MountOperation]
266pub trait GtkMountOperationExt: IsA<MountOperation> + 'static {
267    /// Gets the transient parent used by the [`MountOperation`][crate::MountOperation]
268    ///
269    /// # Returns
270    ///
271    /// the transient parent for windows shown by `self`
272    #[doc(alias = "gtk_mount_operation_get_parent")]
273    #[doc(alias = "get_parent")]
274    fn parent(&self) -> Option<Window> {
275        unsafe {
276            from_glib_none(ffi::gtk_mount_operation_get_parent(
277                self.as_ref().to_glib_none().0,
278            ))
279        }
280    }
281
282    /// Gets the screen on which windows of the [`MountOperation`][crate::MountOperation]
283    /// will be shown.
284    ///
285    /// # Returns
286    ///
287    /// the screen on which windows of `self` are shown
288    #[doc(alias = "gtk_mount_operation_get_screen")]
289    #[doc(alias = "get_screen")]
290    fn screen(&self) -> Option<gdk::Screen> {
291        unsafe {
292            from_glib_none(ffi::gtk_mount_operation_get_screen(
293                self.as_ref().to_glib_none().0,
294            ))
295        }
296    }
297
298    /// Returns whether the [`MountOperation`][crate::MountOperation] is currently displaying
299    /// a window.
300    ///
301    /// # Returns
302    ///
303    /// [`true`] if `self` is currently displaying a window
304    #[doc(alias = "gtk_mount_operation_is_showing")]
305    #[doc(alias = "is-showing")]
306    fn is_showing(&self) -> bool {
307        unsafe {
308            from_glib(ffi::gtk_mount_operation_is_showing(
309                self.as_ref().to_glib_none().0,
310            ))
311        }
312    }
313
314    /// Sets the transient parent for windows shown by the
315    /// [`MountOperation`][crate::MountOperation].
316    /// ## `parent`
317    /// transient parent of the window, or [`None`]
318    #[doc(alias = "gtk_mount_operation_set_parent")]
319    #[doc(alias = "parent")]
320    fn set_parent(&self, parent: Option<&impl IsA<Window>>) {
321        unsafe {
322            ffi::gtk_mount_operation_set_parent(
323                self.as_ref().to_glib_none().0,
324                parent.map(|p| p.as_ref()).to_glib_none().0,
325            );
326        }
327    }
328
329    /// Sets the screen to show windows of the [`MountOperation`][crate::MountOperation] on.
330    /// ## `screen`
331    /// a [`gdk::Screen`][crate::gdk::Screen]
332    #[doc(alias = "gtk_mount_operation_set_screen")]
333    #[doc(alias = "screen")]
334    fn set_screen(&self, screen: &gdk::Screen) {
335        unsafe {
336            ffi::gtk_mount_operation_set_screen(
337                self.as_ref().to_glib_none().0,
338                screen.to_glib_none().0,
339            );
340        }
341    }
342
343    #[doc(alias = "is-showing")]
344    fn connect_is_showing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
345        unsafe extern "C" fn notify_is_showing_trampoline<
346            P: IsA<MountOperation>,
347            F: Fn(&P) + 'static,
348        >(
349            this: *mut ffi::GtkMountOperation,
350            _param_spec: glib::ffi::gpointer,
351            f: glib::ffi::gpointer,
352        ) {
353            unsafe {
354                let f: &F = &*(f as *const F);
355                f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
356            }
357        }
358        unsafe {
359            let f: Box_<F> = Box_::new(f);
360            connect_raw(
361                self.as_ptr() as *mut _,
362                c"notify::is-showing".as_ptr(),
363                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
364                    notify_is_showing_trampoline::<Self, F> as *const (),
365                )),
366                Box_::into_raw(f),
367            )
368        }
369    }
370
371    #[doc(alias = "parent")]
372    fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
373        unsafe extern "C" fn notify_parent_trampoline<
374            P: IsA<MountOperation>,
375            F: Fn(&P) + 'static,
376        >(
377            this: *mut ffi::GtkMountOperation,
378            _param_spec: glib::ffi::gpointer,
379            f: glib::ffi::gpointer,
380        ) {
381            unsafe {
382                let f: &F = &*(f as *const F);
383                f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
384            }
385        }
386        unsafe {
387            let f: Box_<F> = Box_::new(f);
388            connect_raw(
389                self.as_ptr() as *mut _,
390                c"notify::parent".as_ptr(),
391                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
392                    notify_parent_trampoline::<Self, F> as *const (),
393                )),
394                Box_::into_raw(f),
395            )
396        }
397    }
398
399    #[doc(alias = "screen")]
400    fn connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
401        unsafe extern "C" fn notify_screen_trampoline<
402            P: IsA<MountOperation>,
403            F: Fn(&P) + 'static,
404        >(
405            this: *mut ffi::GtkMountOperation,
406            _param_spec: glib::ffi::gpointer,
407            f: glib::ffi::gpointer,
408        ) {
409            unsafe {
410                let f: &F = &*(f as *const F);
411                f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
412            }
413        }
414        unsafe {
415            let f: Box_<F> = Box_::new(f);
416            connect_raw(
417                self.as_ptr() as *mut _,
418                c"notify::screen".as_ptr(),
419                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
420                    notify_screen_trampoline::<Self, F> as *const (),
421                )),
422                Box_::into_raw(f),
423            )
424        }
425    }
426}
427
428impl<O: IsA<MountOperation>> GtkMountOperationExt for O {}