[go: up one dir, main page]

gtk4/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::{ffi, Window};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GtkMountOperation")]
15    pub struct MountOperation(Object<ffi::GtkMountOperation, ffi::GtkMountOperationClass>) @extends gio::MountOperation;
16
17    match fn {
18        type_ => || ffi::gtk_mount_operation_get_type(),
19    }
20}
21
22impl MountOperation {
23    pub const NONE: Option<&'static MountOperation> = None;
24
25    #[doc(alias = "gtk_mount_operation_new")]
26    pub fn new(parent: Option<&impl IsA<Window>>) -> MountOperation {
27        assert_initialized_main_thread!();
28        unsafe {
29            gio::MountOperation::from_glib_full(ffi::gtk_mount_operation_new(
30                parent.map(|p| p.as_ref()).to_glib_none().0,
31            ))
32            .unsafe_cast()
33        }
34    }
35
36    // rustdoc-stripper-ignore-next
37    /// Creates a new builder-pattern struct instance to construct [`MountOperation`] objects.
38    ///
39    /// This method returns an instance of [`MountOperationBuilder`](crate::builders::MountOperationBuilder) which can be used to create [`MountOperation`] objects.
40    pub fn builder() -> MountOperationBuilder {
41        MountOperationBuilder::new()
42    }
43}
44
45impl Default for MountOperation {
46    fn default() -> Self {
47        glib::object::Object::new::<Self>()
48    }
49}
50
51// rustdoc-stripper-ignore-next
52/// A [builder-pattern] type to construct [`MountOperation`] objects.
53///
54/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
55#[must_use = "The builder must be built to be used"]
56pub struct MountOperationBuilder {
57    builder: glib::object::ObjectBuilder<'static, MountOperation>,
58}
59
60impl MountOperationBuilder {
61    fn new() -> Self {
62        Self {
63            builder: glib::object::Object::builder(),
64        }
65    }
66
67    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
68        Self {
69            builder: self.builder.property("display", display.clone().upcast()),
70        }
71    }
72
73    pub fn parent(self, parent: &impl IsA<Window>) -> Self {
74        Self {
75            builder: self.builder.property("parent", parent.clone().upcast()),
76        }
77    }
78
79    pub fn anonymous(self, anonymous: bool) -> Self {
80        Self {
81            builder: self.builder.property("anonymous", anonymous),
82        }
83    }
84
85    pub fn choice(self, choice: i32) -> Self {
86        Self {
87            builder: self.builder.property("choice", choice),
88        }
89    }
90
91    pub fn domain(self, domain: impl Into<glib::GString>) -> Self {
92        Self {
93            builder: self.builder.property("domain", domain.into()),
94        }
95    }
96
97    pub fn is_tcrypt_hidden_volume(self, is_tcrypt_hidden_volume: bool) -> Self {
98        Self {
99            builder: self
100                .builder
101                .property("is-tcrypt-hidden-volume", is_tcrypt_hidden_volume),
102        }
103    }
104
105    pub fn is_tcrypt_system_volume(self, is_tcrypt_system_volume: bool) -> Self {
106        Self {
107            builder: self
108                .builder
109                .property("is-tcrypt-system-volume", is_tcrypt_system_volume),
110        }
111    }
112
113    pub fn password(self, password: impl Into<glib::GString>) -> Self {
114        Self {
115            builder: self.builder.property("password", password.into()),
116        }
117    }
118
119    pub fn password_save(self, password_save: gio::PasswordSave) -> Self {
120        Self {
121            builder: self.builder.property("password-save", password_save),
122        }
123    }
124
125    pub fn pim(self, pim: u32) -> Self {
126        Self {
127            builder: self.builder.property("pim", pim),
128        }
129    }
130
131    pub fn username(self, username: impl Into<glib::GString>) -> Self {
132        Self {
133            builder: self.builder.property("username", username.into()),
134        }
135    }
136
137    // rustdoc-stripper-ignore-next
138    /// Build the [`MountOperation`].
139    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
140    pub fn build(self) -> MountOperation {
141        assert_initialized_main_thread!();
142        self.builder.build()
143    }
144}
145
146pub trait GtkMountOperationExt: IsA<MountOperation> + 'static {
147    #[doc(alias = "gtk_mount_operation_get_display")]
148    #[doc(alias = "get_display")]
149    fn display(&self) -> gdk::Display {
150        unsafe {
151            from_glib_none(ffi::gtk_mount_operation_get_display(
152                self.as_ref().to_glib_none().0,
153            ))
154        }
155    }
156
157    #[doc(alias = "gtk_mount_operation_get_parent")]
158    #[doc(alias = "get_parent")]
159    fn parent(&self) -> Option<Window> {
160        unsafe {
161            from_glib_none(ffi::gtk_mount_operation_get_parent(
162                self.as_ref().to_glib_none().0,
163            ))
164        }
165    }
166
167    #[doc(alias = "gtk_mount_operation_is_showing")]
168    #[doc(alias = "is-showing")]
169    fn is_showing(&self) -> bool {
170        unsafe {
171            from_glib(ffi::gtk_mount_operation_is_showing(
172                self.as_ref().to_glib_none().0,
173            ))
174        }
175    }
176
177    #[doc(alias = "gtk_mount_operation_set_display")]
178    #[doc(alias = "display")]
179    fn set_display(&self, display: &impl IsA<gdk::Display>) {
180        unsafe {
181            ffi::gtk_mount_operation_set_display(
182                self.as_ref().to_glib_none().0,
183                display.as_ref().to_glib_none().0,
184            );
185        }
186    }
187
188    #[doc(alias = "gtk_mount_operation_set_parent")]
189    #[doc(alias = "parent")]
190    fn set_parent(&self, parent: Option<&impl IsA<Window>>) {
191        unsafe {
192            ffi::gtk_mount_operation_set_parent(
193                self.as_ref().to_glib_none().0,
194                parent.map(|p| p.as_ref()).to_glib_none().0,
195            );
196        }
197    }
198
199    #[doc(alias = "display")]
200    fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
201        unsafe extern "C" fn notify_display_trampoline<
202            P: IsA<MountOperation>,
203            F: Fn(&P) + 'static,
204        >(
205            this: *mut ffi::GtkMountOperation,
206            _param_spec: glib::ffi::gpointer,
207            f: glib::ffi::gpointer,
208        ) {
209            let f: &F = &*(f as *const F);
210            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
211        }
212        unsafe {
213            let f: Box_<F> = Box_::new(f);
214            connect_raw(
215                self.as_ptr() as *mut _,
216                c"notify::display".as_ptr() as *const _,
217                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
218                    notify_display_trampoline::<Self, F> as *const (),
219                )),
220                Box_::into_raw(f),
221            )
222        }
223    }
224
225    #[doc(alias = "is-showing")]
226    fn connect_is_showing_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
227        unsafe extern "C" fn notify_is_showing_trampoline<
228            P: IsA<MountOperation>,
229            F: Fn(&P) + 'static,
230        >(
231            this: *mut ffi::GtkMountOperation,
232            _param_spec: glib::ffi::gpointer,
233            f: glib::ffi::gpointer,
234        ) {
235            let f: &F = &*(f as *const F);
236            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
237        }
238        unsafe {
239            let f: Box_<F> = Box_::new(f);
240            connect_raw(
241                self.as_ptr() as *mut _,
242                c"notify::is-showing".as_ptr() as *const _,
243                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244                    notify_is_showing_trampoline::<Self, F> as *const (),
245                )),
246                Box_::into_raw(f),
247            )
248        }
249    }
250
251    #[doc(alias = "parent")]
252    fn connect_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
253        unsafe extern "C" fn notify_parent_trampoline<
254            P: IsA<MountOperation>,
255            F: Fn(&P) + 'static,
256        >(
257            this: *mut ffi::GtkMountOperation,
258            _param_spec: glib::ffi::gpointer,
259            f: glib::ffi::gpointer,
260        ) {
261            let f: &F = &*(f as *const F);
262            f(MountOperation::from_glib_borrow(this).unsafe_cast_ref())
263        }
264        unsafe {
265            let f: Box_<F> = Box_::new(f);
266            connect_raw(
267                self.as_ptr() as *mut _,
268                c"notify::parent".as_ptr() as *const _,
269                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
270                    notify_parent_trampoline::<Self, F> as *const (),
271                )),
272                Box_::into_raw(f),
273            )
274        }
275    }
276}
277
278impl<O: IsA<MountOperation>> GtkMountOperationExt for O {}