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