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;
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
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 | Writeable
25 ///
26 ///
27 /// #### `screen`
28 /// Readable | Writeable
29 /// <details><summary><h4>MountOperation</h4></summary>
30 ///
31 ///
32 /// #### `anonymous`
33 /// Whether to use an anonymous user when authenticating.
34 ///
35 /// Readable | Writeable
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 | Writeable
43 ///
44 ///
45 /// #### `domain`
46 /// The domain to use for the mount operation.
47 ///
48 /// Readable | Writeable
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 | Writeable
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 | Writeable
66 ///
67 ///
68 /// #### `password`
69 /// The password that is used for authentication when carrying out
70 /// the mount operation.
71 ///
72 /// Readable | Writeable
73 ///
74 ///
75 /// #### `password-save`
76 /// Determines if and how the password information should be saved.
77 ///
78 /// Readable | Writeable
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 | Writeable
86 ///
87 ///
88 /// #### `username`
89 /// The user name that is used for authentication when carrying out
90 /// the mount operation.
91 ///
92 /// Readable | Writeable
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 self.builder.build()
257 }
258}
259
260mod sealed {
261 pub trait Sealed {}
262 impl<T: super::IsA<super::MountOperation>> Sealed for T {}
263}
264
265/// Trait containing all [`struct@MountOperation`] methods.
266///
267/// # Implementors
268///
269/// [`MountOperation`][struct@crate::MountOperation]
270pub trait GtkMountOperationExt: IsA<MountOperation> + sealed::Sealed + 'static {
271 /// Gets the transient parent used by the [`MountOperation`][crate::MountOperation]
272 ///
273 /// # Returns
274 ///
275 /// the transient parent for windows shown by `self`
276 #[doc(alias = "gtk_mount_operation_get_parent")]
277 #[doc(alias = "get_parent")]
278 fn parent(&self) -> Option<Window> {
279 unsafe {
280 from_glib_none(ffi::gtk_mount_operation_get_parent(
281 self.as_ref().to_glib_none().0,
282 ))
283 }
284 }
285
286 /// Gets the screen on which windows of the [`MountOperation`][crate::MountOperation]
287 /// will be shown.
288 ///
289 /// # Returns
290 ///
291 /// the screen on which windows of `self` are shown
292 #[doc(alias = "gtk_mount_operation_get_screen")]
293 #[doc(alias = "get_screen")]
294 fn screen(&self) -> Option<gdk::Screen> {
295 unsafe {
296 from_glib_none(ffi::gtk_mount_operation_get_screen(
297 self.as_ref().to_glib_none().0,
298 ))
299 }
300 }
301
302 /// Returns whether the [`MountOperation`][crate::MountOperation] is currently displaying
303 /// a window.
304 ///
305 /// # Returns
306 ///
307 /// [`true`] if `self` is currently displaying a window
308 #[doc(alias = "gtk_mount_operation_is_showing")]
309 fn is_showing(&self) -> bool {
310 unsafe {
311 from_glib(ffi::gtk_mount_operation_is_showing(
312 self.as_ref().to_glib_none().0,
313 ))
314 }
315 }
316
317 /// Sets the transient parent for windows shown by the
318 /// [`MountOperation`][crate::MountOperation].
319 /// ## `parent`
320 /// transient parent of the window, or [`None`]
321 #[doc(alias = "gtk_mount_operation_set_parent")]
322 fn set_parent(&self, parent: Option<&impl IsA<Window>>) {
323 unsafe {
324 ffi::gtk_mount_operation_set_parent(
325 self.as_ref().to_glib_none().0,
326 parent.map(|p| p.as_ref()).to_glib_none().0,
327 );
328 }
329 }
330
331 /// Sets the screen to show windows of the [`MountOperation`][crate::MountOperation] on.
332 /// ## `screen`
333 /// a [`gdk::Screen`][crate::gdk::Screen]
334 #[doc(alias = "gtk_mount_operation_set_screen")]
335 fn set_screen(&self, screen: &gdk::Screen) {
336 unsafe {
337 ffi::gtk_mount_operation_set_screen(
338 self.as_ref().to_glib_none().0,
339 screen.to_glib_none().0,
340 );
341 }
342 }
343
344 #[doc(alias = "is-showing")]
345 fn connect_is_showing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
346 unsafe extern "C" fn notify_is_showing_trampoline<
347 P: IsA<MountOperation>,
348 F: Fn(&P) + 'static,
349 >(
350 this: *mut ffi::GtkMountOperation,
351 _param_spec: glib::ffi::gpointer,
352 f: glib::ffi::gpointer,
353 ) {
354 let f: &F = &*(f as *const F);
355 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
356 }
357 unsafe {
358 let f: Box_<F> = Box_::new(f);
359 connect_raw(
360 self.as_ptr() as *mut _,
361 b"notify::is-showing\0".as_ptr() as *const _,
362 Some(transmute::<_, unsafe extern "C" fn()>(
363 notify_is_showing_trampoline::<Self, F> as *const (),
364 )),
365 Box_::into_raw(f),
366 )
367 }
368 }
369
370 #[doc(alias = "parent")]
371 fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
372 unsafe extern "C" fn notify_parent_trampoline<
373 P: IsA<MountOperation>,
374 F: Fn(&P) + 'static,
375 >(
376 this: *mut ffi::GtkMountOperation,
377 _param_spec: glib::ffi::gpointer,
378 f: glib::ffi::gpointer,
379 ) {
380 let f: &F = &*(f as *const F);
381 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
382 }
383 unsafe {
384 let f: Box_<F> = Box_::new(f);
385 connect_raw(
386 self.as_ptr() as *mut _,
387 b"notify::parent\0".as_ptr() as *const _,
388 Some(transmute::<_, unsafe extern "C" fn()>(
389 notify_parent_trampoline::<Self, F> as *const (),
390 )),
391 Box_::into_raw(f),
392 )
393 }
394 }
395
396 #[doc(alias = "screen")]
397 fn connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
398 unsafe extern "C" fn notify_screen_trampoline<
399 P: IsA<MountOperation>,
400 F: Fn(&P) + 'static,
401 >(
402 this: *mut ffi::GtkMountOperation,
403 _param_spec: glib::ffi::gpointer,
404 f: glib::ffi::gpointer,
405 ) {
406 let f: &F = &*(f as *const F);
407 f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
408 }
409 unsafe {
410 let f: Box_<F> = Box_::new(f);
411 connect_raw(
412 self.as_ptr() as *mut _,
413 b"notify::screen\0".as_ptr() as *const _,
414 Some(transmute::<_, unsafe extern "C" fn()>(
415 notify_screen_trampoline::<Self, F> as *const (),
416 )),
417 Box_::into_raw(f),
418 )
419 }
420 }
421}
422
423impl<O: IsA<MountOperation>> GtkMountOperationExt for O {}
424
425impl fmt::Display for MountOperation {
426 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
427 f.write_str("MountOperation")
428 }
429}