gtk/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
5#[cfg(any(feature = "v3_20", feature = "dox"))]
6use glib::object::Cast;
7use glib::object::IsA;
8#[cfg(any(feature = "v3_20", feature = "dox"))]
9use glib::signal::connect_raw;
10#[cfg(any(feature = "v3_20", feature = "dox"))]
11use glib::signal::SignalHandlerId;
12use glib::translate::*;
13#[cfg(any(feature = "v3_20", feature = "dox"))]
14use glib::GString;
15#[cfg(any(feature = "v3_20", feature = "dox"))]
16use glib::Value;
17#[cfg(any(feature = "v3_20", feature = "dox"))]
18use glib_sys;
19#[cfg(any(feature = "v3_20", feature = "dox"))]
20use gobject_sys;
21use gtk_sys;
22#[cfg(any(feature = "v3_20", feature = "dox"))]
23use std::boxed::Box as Box_;
24use std::fmt;
25#[cfg(any(feature = "v3_20", feature = "dox"))]
26use std::mem::transmute;
27#[cfg(any(feature = "v3_20", feature = "dox"))]
28use ResponseType;
29#[cfg(any(feature = "v3_20", feature = "dox"))]
30use Window;
31
32glib_wrapper! {
33    pub struct NativeDialog(Object<gtk_sys::GtkNativeDialog, gtk_sys::GtkNativeDialogClass, NativeDialogClass>);
34
35    match fn {
36        get_type => || gtk_sys::gtk_native_dialog_get_type(),
37    }
38}
39
40pub const NONE_NATIVE_DIALOG: Option<&NativeDialog> = None;
41
42pub trait NativeDialogExt: 'static {
43    #[cfg(any(feature = "v3_20", feature = "dox"))]
44    fn destroy(&self);
45
46    #[cfg(any(feature = "v3_20", feature = "dox"))]
47    fn get_modal(&self) -> bool;
48
49    #[cfg(any(feature = "v3_20", feature = "dox"))]
50    fn get_title(&self) -> Option<GString>;
51
52    #[cfg(any(feature = "v3_20", feature = "dox"))]
53    fn get_transient_for(&self) -> Option<Window>;
54
55    #[cfg(any(feature = "v3_20", feature = "dox"))]
56    fn get_visible(&self) -> bool;
57
58    #[cfg(any(feature = "v3_20", feature = "dox"))]
59    fn hide(&self);
60
61    #[cfg(any(feature = "v3_20", feature = "dox"))]
62    fn run(&self) -> i32;
63
64    #[cfg(any(feature = "v3_20", feature = "dox"))]
65    fn set_modal(&self, modal: bool);
66
67    #[cfg(any(feature = "v3_20", feature = "dox"))]
68    fn set_title(&self, title: &str);
69
70    #[cfg(any(feature = "v3_20", feature = "dox"))]
71    fn set_transient_for<P: IsA<Window>>(&self, parent: Option<&P>);
72
73    #[cfg(any(feature = "v3_20", feature = "dox"))]
74    fn show(&self);
75
76    #[cfg(any(feature = "v3_20", feature = "dox"))]
77    fn set_property_visible(&self, visible: bool);
78
79    #[cfg(any(feature = "v3_20", feature = "dox"))]
80    fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId;
81
82    #[cfg(any(feature = "v3_20", feature = "dox"))]
83    fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
84
85    #[cfg(any(feature = "v3_20", feature = "dox"))]
86    fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
87
88    #[cfg(any(feature = "v3_20", feature = "dox"))]
89    fn connect_property_transient_for_notify<F: Fn(&Self) + 'static>(
90        &self,
91        f: F,
92    ) -> SignalHandlerId;
93
94    #[cfg(any(feature = "v3_20", feature = "dox"))]
95    fn connect_property_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
96}
97
98impl<O: IsA<NativeDialog>> NativeDialogExt for O {
99    #[cfg(any(feature = "v3_20", feature = "dox"))]
100    fn destroy(&self) {
101        unsafe {
102            gtk_sys::gtk_native_dialog_destroy(self.as_ref().to_glib_none().0);
103        }
104    }
105
106    #[cfg(any(feature = "v3_20", feature = "dox"))]
107    fn get_modal(&self) -> bool {
108        unsafe {
109            from_glib(gtk_sys::gtk_native_dialog_get_modal(
110                self.as_ref().to_glib_none().0,
111            ))
112        }
113    }
114
115    #[cfg(any(feature = "v3_20", feature = "dox"))]
116    fn get_title(&self) -> Option<GString> {
117        unsafe {
118            from_glib_none(gtk_sys::gtk_native_dialog_get_title(
119                self.as_ref().to_glib_none().0,
120            ))
121        }
122    }
123
124    #[cfg(any(feature = "v3_20", feature = "dox"))]
125    fn get_transient_for(&self) -> Option<Window> {
126        unsafe {
127            from_glib_none(gtk_sys::gtk_native_dialog_get_transient_for(
128                self.as_ref().to_glib_none().0,
129            ))
130        }
131    }
132
133    #[cfg(any(feature = "v3_20", feature = "dox"))]
134    fn get_visible(&self) -> bool {
135        unsafe {
136            from_glib(gtk_sys::gtk_native_dialog_get_visible(
137                self.as_ref().to_glib_none().0,
138            ))
139        }
140    }
141
142    #[cfg(any(feature = "v3_20", feature = "dox"))]
143    fn hide(&self) {
144        unsafe {
145            gtk_sys::gtk_native_dialog_hide(self.as_ref().to_glib_none().0);
146        }
147    }
148
149    #[cfg(any(feature = "v3_20", feature = "dox"))]
150    fn run(&self) -> i32 {
151        unsafe { gtk_sys::gtk_native_dialog_run(self.as_ref().to_glib_none().0) }
152    }
153
154    #[cfg(any(feature = "v3_20", feature = "dox"))]
155    fn set_modal(&self, modal: bool) {
156        unsafe {
157            gtk_sys::gtk_native_dialog_set_modal(self.as_ref().to_glib_none().0, modal.to_glib());
158        }
159    }
160
161    #[cfg(any(feature = "v3_20", feature = "dox"))]
162    fn set_title(&self, title: &str) {
163        unsafe {
164            gtk_sys::gtk_native_dialog_set_title(
165                self.as_ref().to_glib_none().0,
166                title.to_glib_none().0,
167            );
168        }
169    }
170
171    #[cfg(any(feature = "v3_20", feature = "dox"))]
172    fn set_transient_for<P: IsA<Window>>(&self, parent: Option<&P>) {
173        unsafe {
174            gtk_sys::gtk_native_dialog_set_transient_for(
175                self.as_ref().to_glib_none().0,
176                parent.map(|p| p.as_ref()).to_glib_none().0,
177            );
178        }
179    }
180
181    #[cfg(any(feature = "v3_20", feature = "dox"))]
182    fn show(&self) {
183        unsafe {
184            gtk_sys::gtk_native_dialog_show(self.as_ref().to_glib_none().0);
185        }
186    }
187
188    #[cfg(any(feature = "v3_20", feature = "dox"))]
189    fn set_property_visible(&self, visible: bool) {
190        unsafe {
191            gobject_sys::g_object_set_property(
192                self.to_glib_none().0 as *mut gobject_sys::GObject,
193                b"visible\0".as_ptr() as *const _,
194                Value::from(&visible).to_glib_none().0,
195            );
196        }
197    }
198
199    #[cfg(any(feature = "v3_20", feature = "dox"))]
200    fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
201        unsafe extern "C" fn response_trampoline<P, F: Fn(&P, ResponseType) + 'static>(
202            this: *mut gtk_sys::GtkNativeDialog,
203            response_id: gtk_sys::GtkResponseType,
204            f: glib_sys::gpointer,
205        ) where
206            P: IsA<NativeDialog>,
207        {
208            let f: &F = &*(f as *const F);
209            f(
210                &NativeDialog::from_glib_borrow(this).unsafe_cast(),
211                from_glib(response_id),
212            )
213        }
214        unsafe {
215            let f: Box_<F> = Box_::new(f);
216            connect_raw(
217                self.as_ptr() as *mut _,
218                b"response\0".as_ptr() as *const _,
219                Some(transmute(response_trampoline::<Self, F> as usize)),
220                Box_::into_raw(f),
221            )
222        }
223    }
224
225    #[cfg(any(feature = "v3_20", feature = "dox"))]
226    fn connect_property_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
227        unsafe extern "C" fn notify_modal_trampoline<P, F: Fn(&P) + 'static>(
228            this: *mut gtk_sys::GtkNativeDialog,
229            _param_spec: glib_sys::gpointer,
230            f: glib_sys::gpointer,
231        ) where
232            P: IsA<NativeDialog>,
233        {
234            let f: &F = &*(f as *const F);
235            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
236        }
237        unsafe {
238            let f: Box_<F> = Box_::new(f);
239            connect_raw(
240                self.as_ptr() as *mut _,
241                b"notify::modal\0".as_ptr() as *const _,
242                Some(transmute(notify_modal_trampoline::<Self, F> as usize)),
243                Box_::into_raw(f),
244            )
245        }
246    }
247
248    #[cfg(any(feature = "v3_20", feature = "dox"))]
249    fn connect_property_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
250        unsafe extern "C" fn notify_title_trampoline<P, F: Fn(&P) + 'static>(
251            this: *mut gtk_sys::GtkNativeDialog,
252            _param_spec: glib_sys::gpointer,
253            f: glib_sys::gpointer,
254        ) where
255            P: IsA<NativeDialog>,
256        {
257            let f: &F = &*(f as *const F);
258            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
259        }
260        unsafe {
261            let f: Box_<F> = Box_::new(f);
262            connect_raw(
263                self.as_ptr() as *mut _,
264                b"notify::title\0".as_ptr() as *const _,
265                Some(transmute(notify_title_trampoline::<Self, F> as usize)),
266                Box_::into_raw(f),
267            )
268        }
269    }
270
271    #[cfg(any(feature = "v3_20", feature = "dox"))]
272    fn connect_property_transient_for_notify<F: Fn(&Self) + 'static>(
273        &self,
274        f: F,
275    ) -> SignalHandlerId {
276        unsafe extern "C" fn notify_transient_for_trampoline<P, F: Fn(&P) + 'static>(
277            this: *mut gtk_sys::GtkNativeDialog,
278            _param_spec: glib_sys::gpointer,
279            f: glib_sys::gpointer,
280        ) where
281            P: IsA<NativeDialog>,
282        {
283            let f: &F = &*(f as *const F);
284            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
285        }
286        unsafe {
287            let f: Box_<F> = Box_::new(f);
288            connect_raw(
289                self.as_ptr() as *mut _,
290                b"notify::transient-for\0".as_ptr() as *const _,
291                Some(transmute(
292                    notify_transient_for_trampoline::<Self, F> as usize,
293                )),
294                Box_::into_raw(f),
295            )
296        }
297    }
298
299    #[cfg(any(feature = "v3_20", feature = "dox"))]
300    fn connect_property_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
301        unsafe extern "C" fn notify_visible_trampoline<P, F: Fn(&P) + 'static>(
302            this: *mut gtk_sys::GtkNativeDialog,
303            _param_spec: glib_sys::gpointer,
304            f: glib_sys::gpointer,
305        ) where
306            P: IsA<NativeDialog>,
307        {
308            let f: &F = &*(f as *const F);
309            f(&NativeDialog::from_glib_borrow(this).unsafe_cast())
310        }
311        unsafe {
312            let f: Box_<F> = Box_::new(f);
313            connect_raw(
314                self.as_ptr() as *mut _,
315                b"notify::visible\0".as_ptr() as *const _,
316                Some(transmute(notify_visible_trampoline::<Self, F> as usize)),
317                Box_::into_raw(f),
318            )
319        }
320    }
321}
322
323impl fmt::Display for NativeDialog {
324    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
325        write!(f, "NativeDialog")
326    }
327}