gtk4/auto/
native_dialog.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, ResponseType, Window};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkNativeDialog")]
16    pub struct NativeDialog(Object<ffi::GtkNativeDialog, ffi::GtkNativeDialogClass>);
17
18    match fn {
19        type_ => || ffi::gtk_native_dialog_get_type(),
20    }
21}
22
23impl NativeDialog {
24    pub const NONE: Option<&'static NativeDialog> = None;
25}
26
27pub trait NativeDialogExt: IsA<NativeDialog> + 'static {
28    #[doc(alias = "gtk_native_dialog_destroy")]
29    fn destroy(&self) {
30        unsafe {
31            ffi::gtk_native_dialog_destroy(self.as_ref().to_glib_none().0);
32        }
33    }
34
35    #[doc(alias = "gtk_native_dialog_get_modal")]
36    #[doc(alias = "get_modal")]
37    #[doc(alias = "modal")]
38    fn is_modal(&self) -> bool {
39        unsafe {
40            from_glib(ffi::gtk_native_dialog_get_modal(
41                self.as_ref().to_glib_none().0,
42            ))
43        }
44    }
45
46    #[doc(alias = "gtk_native_dialog_get_title")]
47    #[doc(alias = "get_title")]
48    fn title(&self) -> Option<glib::GString> {
49        unsafe {
50            from_glib_none(ffi::gtk_native_dialog_get_title(
51                self.as_ref().to_glib_none().0,
52            ))
53        }
54    }
55
56    #[doc(alias = "gtk_native_dialog_get_transient_for")]
57    #[doc(alias = "get_transient_for")]
58    #[doc(alias = "transient-for")]
59    fn transient_for(&self) -> Option<Window> {
60        unsafe {
61            from_glib_none(ffi::gtk_native_dialog_get_transient_for(
62                self.as_ref().to_glib_none().0,
63            ))
64        }
65    }
66
67    #[doc(alias = "gtk_native_dialog_get_visible")]
68    #[doc(alias = "get_visible")]
69    #[doc(alias = "visible")]
70    fn is_visible(&self) -> bool {
71        unsafe {
72            from_glib(ffi::gtk_native_dialog_get_visible(
73                self.as_ref().to_glib_none().0,
74            ))
75        }
76    }
77
78    #[doc(alias = "gtk_native_dialog_hide")]
79    fn hide(&self) {
80        unsafe {
81            ffi::gtk_native_dialog_hide(self.as_ref().to_glib_none().0);
82        }
83    }
84
85    #[doc(alias = "gtk_native_dialog_set_modal")]
86    #[doc(alias = "modal")]
87    fn set_modal(&self, modal: bool) {
88        unsafe {
89            ffi::gtk_native_dialog_set_modal(self.as_ref().to_glib_none().0, modal.into_glib());
90        }
91    }
92
93    #[doc(alias = "gtk_native_dialog_set_title")]
94    #[doc(alias = "title")]
95    fn set_title(&self, title: &str) {
96        unsafe {
97            ffi::gtk_native_dialog_set_title(
98                self.as_ref().to_glib_none().0,
99                title.to_glib_none().0,
100            );
101        }
102    }
103
104    #[doc(alias = "gtk_native_dialog_set_transient_for")]
105    #[doc(alias = "transient-for")]
106    fn set_transient_for(&self, parent: Option<&impl IsA<Window>>) {
107        unsafe {
108            ffi::gtk_native_dialog_set_transient_for(
109                self.as_ref().to_glib_none().0,
110                parent.map(|p| p.as_ref()).to_glib_none().0,
111            );
112        }
113    }
114
115    #[doc(alias = "gtk_native_dialog_show")]
116    fn show(&self) {
117        unsafe {
118            ffi::gtk_native_dialog_show(self.as_ref().to_glib_none().0);
119        }
120    }
121
122    fn set_visible(&self, visible: bool) {
123        ObjectExt::set_property(self.as_ref(), "visible", visible)
124    }
125
126    #[doc(alias = "response")]
127    fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
128        unsafe extern "C" fn response_trampoline<
129            P: IsA<NativeDialog>,
130            F: Fn(&P, ResponseType) + 'static,
131        >(
132            this: *mut ffi::GtkNativeDialog,
133            response_id: ffi::GtkResponseType,
134            f: glib::ffi::gpointer,
135        ) {
136            let f: &F = &*(f as *const F);
137            f(
138                NativeDialog::from_glib_borrow(this).unsafe_cast_ref(),
139                from_glib(response_id),
140            )
141        }
142        unsafe {
143            let f: Box_<F> = Box_::new(f);
144            connect_raw(
145                self.as_ptr() as *mut _,
146                c"response".as_ptr() as *const _,
147                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
148                    response_trampoline::<Self, F> as *const (),
149                )),
150                Box_::into_raw(f),
151            )
152        }
153    }
154
155    #[doc(alias = "modal")]
156    fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
157        unsafe extern "C" fn notify_modal_trampoline<P: IsA<NativeDialog>, F: Fn(&P) + 'static>(
158            this: *mut ffi::GtkNativeDialog,
159            _param_spec: glib::ffi::gpointer,
160            f: glib::ffi::gpointer,
161        ) {
162            let f: &F = &*(f as *const F);
163            f(NativeDialog::from_glib_borrow(this).unsafe_cast_ref())
164        }
165        unsafe {
166            let f: Box_<F> = Box_::new(f);
167            connect_raw(
168                self.as_ptr() as *mut _,
169                c"notify::modal".as_ptr() as *const _,
170                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
171                    notify_modal_trampoline::<Self, F> as *const (),
172                )),
173                Box_::into_raw(f),
174            )
175        }
176    }
177
178    #[doc(alias = "title")]
179    fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
180        unsafe extern "C" fn notify_title_trampoline<P: IsA<NativeDialog>, F: Fn(&P) + 'static>(
181            this: *mut ffi::GtkNativeDialog,
182            _param_spec: glib::ffi::gpointer,
183            f: glib::ffi::gpointer,
184        ) {
185            let f: &F = &*(f as *const F);
186            f(NativeDialog::from_glib_borrow(this).unsafe_cast_ref())
187        }
188        unsafe {
189            let f: Box_<F> = Box_::new(f);
190            connect_raw(
191                self.as_ptr() as *mut _,
192                c"notify::title".as_ptr() as *const _,
193                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
194                    notify_title_trampoline::<Self, F> as *const (),
195                )),
196                Box_::into_raw(f),
197            )
198        }
199    }
200
201    #[doc(alias = "transient-for")]
202    fn connect_transient_for_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
203        unsafe extern "C" fn notify_transient_for_trampoline<
204            P: IsA<NativeDialog>,
205            F: Fn(&P) + 'static,
206        >(
207            this: *mut ffi::GtkNativeDialog,
208            _param_spec: glib::ffi::gpointer,
209            f: glib::ffi::gpointer,
210        ) {
211            let f: &F = &*(f as *const F);
212            f(NativeDialog::from_glib_borrow(this).unsafe_cast_ref())
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(
217                self.as_ptr() as *mut _,
218                c"notify::transient-for".as_ptr() as *const _,
219                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
220                    notify_transient_for_trampoline::<Self, F> as *const (),
221                )),
222                Box_::into_raw(f),
223            )
224        }
225    }
226
227    #[doc(alias = "visible")]
228    fn connect_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
229        unsafe extern "C" fn notify_visible_trampoline<
230            P: IsA<NativeDialog>,
231            F: Fn(&P) + 'static,
232        >(
233            this: *mut ffi::GtkNativeDialog,
234            _param_spec: glib::ffi::gpointer,
235            f: glib::ffi::gpointer,
236        ) {
237            let f: &F = &*(f as *const F);
238            f(NativeDialog::from_glib_borrow(this).unsafe_cast_ref())
239        }
240        unsafe {
241            let f: Box_<F> = Box_::new(f);
242            connect_raw(
243                self.as_ptr() as *mut _,
244                c"notify::visible".as_ptr() as *const _,
245                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
246                    notify_visible_trampoline::<Self, F> as *const (),
247                )),
248                Box_::into_raw(f),
249            )
250        }
251    }
252}
253
254impl<O: IsA<NativeDialog>> NativeDialogExt for O {}