[go: up one dir, main page]

gtk4/auto/
file_chooser.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#![allow(deprecated)]
5
6use crate::{ffi, FileChooserAction, FileFilter};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkFileChooser")]
16    pub struct FileChooser(Interface<ffi::GtkFileChooser>);
17
18    match fn {
19        type_ => || ffi::gtk_file_chooser_get_type(),
20    }
21}
22
23impl FileChooser {
24    pub const NONE: Option<&'static FileChooser> = None;
25}
26
27pub trait FileChooserExt: IsA<FileChooser> + 'static {
28    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
29    #[allow(deprecated)]
30    #[doc(alias = "gtk_file_chooser_add_filter")]
31    fn add_filter(&self, filter: &FileFilter) {
32        unsafe {
33            ffi::gtk_file_chooser_add_filter(
34                self.as_ref().to_glib_none().0,
35                filter.to_glib_none().0,
36            );
37        }
38    }
39
40    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
41    #[allow(deprecated)]
42    #[doc(alias = "gtk_file_chooser_add_shortcut_folder")]
43    fn add_shortcut_folder(&self, folder: &impl IsA<gio::File>) -> Result<(), glib::Error> {
44        unsafe {
45            let mut error = std::ptr::null_mut();
46            let is_ok = ffi::gtk_file_chooser_add_shortcut_folder(
47                self.as_ref().to_glib_none().0,
48                folder.as_ref().to_glib_none().0,
49                &mut error,
50            );
51            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
52            if error.is_null() {
53                Ok(())
54            } else {
55                Err(from_glib_full(error))
56            }
57        }
58    }
59
60    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
61    #[allow(deprecated)]
62    #[doc(alias = "gtk_file_chooser_get_action")]
63    #[doc(alias = "get_action")]
64    fn action(&self) -> FileChooserAction {
65        unsafe {
66            from_glib(ffi::gtk_file_chooser_get_action(
67                self.as_ref().to_glib_none().0,
68            ))
69        }
70    }
71
72    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
73    #[allow(deprecated)]
74    #[doc(alias = "gtk_file_chooser_get_choice")]
75    #[doc(alias = "get_choice")]
76    fn choice(&self, id: &str) -> Option<glib::GString> {
77        unsafe {
78            from_glib_none(ffi::gtk_file_chooser_get_choice(
79                self.as_ref().to_glib_none().0,
80                id.to_glib_none().0,
81            ))
82        }
83    }
84
85    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
86    #[allow(deprecated)]
87    #[doc(alias = "gtk_file_chooser_get_create_folders")]
88    #[doc(alias = "get_create_folders")]
89    #[doc(alias = "create-folders")]
90    fn creates_folders(&self) -> bool {
91        unsafe {
92            from_glib(ffi::gtk_file_chooser_get_create_folders(
93                self.as_ref().to_glib_none().0,
94            ))
95        }
96    }
97
98    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
99    #[allow(deprecated)]
100    #[doc(alias = "gtk_file_chooser_get_current_folder")]
101    #[doc(alias = "get_current_folder")]
102    fn current_folder(&self) -> Option<gio::File> {
103        unsafe {
104            from_glib_full(ffi::gtk_file_chooser_get_current_folder(
105                self.as_ref().to_glib_none().0,
106            ))
107        }
108    }
109
110    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
111    #[allow(deprecated)]
112    #[doc(alias = "gtk_file_chooser_get_current_name")]
113    #[doc(alias = "get_current_name")]
114    fn current_name(&self) -> Option<glib::GString> {
115        unsafe {
116            from_glib_full(ffi::gtk_file_chooser_get_current_name(
117                self.as_ref().to_glib_none().0,
118            ))
119        }
120    }
121
122    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
123    #[allow(deprecated)]
124    #[doc(alias = "gtk_file_chooser_get_file")]
125    #[doc(alias = "get_file")]
126    fn file(&self) -> Option<gio::File> {
127        unsafe {
128            from_glib_full(ffi::gtk_file_chooser_get_file(
129                self.as_ref().to_glib_none().0,
130            ))
131        }
132    }
133
134    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
135    #[allow(deprecated)]
136    #[doc(alias = "gtk_file_chooser_get_files")]
137    #[doc(alias = "get_files")]
138    fn files(&self) -> gio::ListModel {
139        unsafe {
140            from_glib_full(ffi::gtk_file_chooser_get_files(
141                self.as_ref().to_glib_none().0,
142            ))
143        }
144    }
145
146    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
147    #[allow(deprecated)]
148    #[doc(alias = "gtk_file_chooser_get_filter")]
149    #[doc(alias = "get_filter")]
150    fn filter(&self) -> Option<FileFilter> {
151        unsafe {
152            from_glib_none(ffi::gtk_file_chooser_get_filter(
153                self.as_ref().to_glib_none().0,
154            ))
155        }
156    }
157
158    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
159    #[allow(deprecated)]
160    #[doc(alias = "gtk_file_chooser_get_filters")]
161    #[doc(alias = "get_filters")]
162    fn filters(&self) -> gio::ListModel {
163        unsafe {
164            from_glib_full(ffi::gtk_file_chooser_get_filters(
165                self.as_ref().to_glib_none().0,
166            ))
167        }
168    }
169
170    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
171    #[allow(deprecated)]
172    #[doc(alias = "gtk_file_chooser_get_select_multiple")]
173    #[doc(alias = "get_select_multiple")]
174    #[doc(alias = "select-multiple")]
175    fn selects_multiple(&self) -> bool {
176        unsafe {
177            from_glib(ffi::gtk_file_chooser_get_select_multiple(
178                self.as_ref().to_glib_none().0,
179            ))
180        }
181    }
182
183    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
184    #[allow(deprecated)]
185    #[doc(alias = "gtk_file_chooser_get_shortcut_folders")]
186    #[doc(alias = "get_shortcut_folders")]
187    #[doc(alias = "shortcut-folders")]
188    fn shortcut_folders(&self) -> gio::ListModel {
189        unsafe {
190            from_glib_full(ffi::gtk_file_chooser_get_shortcut_folders(
191                self.as_ref().to_glib_none().0,
192            ))
193        }
194    }
195
196    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
197    #[allow(deprecated)]
198    #[doc(alias = "gtk_file_chooser_remove_choice")]
199    fn remove_choice(&self, id: &str) {
200        unsafe {
201            ffi::gtk_file_chooser_remove_choice(
202                self.as_ref().to_glib_none().0,
203                id.to_glib_none().0,
204            );
205        }
206    }
207
208    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
209    #[allow(deprecated)]
210    #[doc(alias = "gtk_file_chooser_remove_filter")]
211    fn remove_filter(&self, filter: &FileFilter) {
212        unsafe {
213            ffi::gtk_file_chooser_remove_filter(
214                self.as_ref().to_glib_none().0,
215                filter.to_glib_none().0,
216            );
217        }
218    }
219
220    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
221    #[allow(deprecated)]
222    #[doc(alias = "gtk_file_chooser_remove_shortcut_folder")]
223    fn remove_shortcut_folder(&self, folder: &impl IsA<gio::File>) -> Result<(), glib::Error> {
224        unsafe {
225            let mut error = std::ptr::null_mut();
226            let is_ok = ffi::gtk_file_chooser_remove_shortcut_folder(
227                self.as_ref().to_glib_none().0,
228                folder.as_ref().to_glib_none().0,
229                &mut error,
230            );
231            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
232            if error.is_null() {
233                Ok(())
234            } else {
235                Err(from_glib_full(error))
236            }
237        }
238    }
239
240    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
241    #[allow(deprecated)]
242    #[doc(alias = "gtk_file_chooser_set_action")]
243    #[doc(alias = "action")]
244    fn set_action(&self, action: FileChooserAction) {
245        unsafe {
246            ffi::gtk_file_chooser_set_action(self.as_ref().to_glib_none().0, action.into_glib());
247        }
248    }
249
250    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
251    #[allow(deprecated)]
252    #[doc(alias = "gtk_file_chooser_set_choice")]
253    fn set_choice(&self, id: &str, option: &str) {
254        unsafe {
255            ffi::gtk_file_chooser_set_choice(
256                self.as_ref().to_glib_none().0,
257                id.to_glib_none().0,
258                option.to_glib_none().0,
259            );
260        }
261    }
262
263    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
264    #[allow(deprecated)]
265    #[doc(alias = "gtk_file_chooser_set_create_folders")]
266    #[doc(alias = "create-folders")]
267    fn set_create_folders(&self, create_folders: bool) {
268        unsafe {
269            ffi::gtk_file_chooser_set_create_folders(
270                self.as_ref().to_glib_none().0,
271                create_folders.into_glib(),
272            );
273        }
274    }
275
276    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
277    #[allow(deprecated)]
278    #[doc(alias = "gtk_file_chooser_set_current_name")]
279    fn set_current_name(&self, name: &str) {
280        unsafe {
281            ffi::gtk_file_chooser_set_current_name(
282                self.as_ref().to_glib_none().0,
283                name.to_glib_none().0,
284            );
285        }
286    }
287
288    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
289    #[allow(deprecated)]
290    #[doc(alias = "gtk_file_chooser_set_file")]
291    fn set_file(&self, file: &impl IsA<gio::File>) -> Result<(), glib::Error> {
292        unsafe {
293            let mut error = std::ptr::null_mut();
294            let is_ok = ffi::gtk_file_chooser_set_file(
295                self.as_ref().to_glib_none().0,
296                file.as_ref().to_glib_none().0,
297                &mut error,
298            );
299            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
300            if error.is_null() {
301                Ok(())
302            } else {
303                Err(from_glib_full(error))
304            }
305        }
306    }
307
308    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
309    #[allow(deprecated)]
310    #[doc(alias = "gtk_file_chooser_set_filter")]
311    #[doc(alias = "filter")]
312    fn set_filter(&self, filter: &FileFilter) {
313        unsafe {
314            ffi::gtk_file_chooser_set_filter(
315                self.as_ref().to_glib_none().0,
316                filter.to_glib_none().0,
317            );
318        }
319    }
320
321    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
322    #[allow(deprecated)]
323    #[doc(alias = "gtk_file_chooser_set_select_multiple")]
324    #[doc(alias = "select-multiple")]
325    fn set_select_multiple(&self, select_multiple: bool) {
326        unsafe {
327            ffi::gtk_file_chooser_set_select_multiple(
328                self.as_ref().to_glib_none().0,
329                select_multiple.into_glib(),
330            );
331        }
332    }
333
334    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
335    #[doc(alias = "action")]
336    fn connect_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
337        unsafe extern "C" fn notify_action_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
338            this: *mut ffi::GtkFileChooser,
339            _param_spec: glib::ffi::gpointer,
340            f: glib::ffi::gpointer,
341        ) {
342            let f: &F = &*(f as *const F);
343            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
344        }
345        unsafe {
346            let f: Box_<F> = Box_::new(f);
347            connect_raw(
348                self.as_ptr() as *mut _,
349                c"notify::action".as_ptr() as *const _,
350                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
351                    notify_action_trampoline::<Self, F> as *const (),
352                )),
353                Box_::into_raw(f),
354            )
355        }
356    }
357
358    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
359    #[doc(alias = "create-folders")]
360    fn connect_create_folders_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
361        unsafe extern "C" fn notify_create_folders_trampoline<
362            P: IsA<FileChooser>,
363            F: Fn(&P) + 'static,
364        >(
365            this: *mut ffi::GtkFileChooser,
366            _param_spec: glib::ffi::gpointer,
367            f: glib::ffi::gpointer,
368        ) {
369            let f: &F = &*(f as *const F);
370            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
371        }
372        unsafe {
373            let f: Box_<F> = Box_::new(f);
374            connect_raw(
375                self.as_ptr() as *mut _,
376                c"notify::create-folders".as_ptr() as *const _,
377                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
378                    notify_create_folders_trampoline::<Self, F> as *const (),
379                )),
380                Box_::into_raw(f),
381            )
382        }
383    }
384
385    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
386    #[doc(alias = "filter")]
387    fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
388        unsafe extern "C" fn notify_filter_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
389            this: *mut ffi::GtkFileChooser,
390            _param_spec: glib::ffi::gpointer,
391            f: glib::ffi::gpointer,
392        ) {
393            let f: &F = &*(f as *const F);
394            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
395        }
396        unsafe {
397            let f: Box_<F> = Box_::new(f);
398            connect_raw(
399                self.as_ptr() as *mut _,
400                c"notify::filter".as_ptr() as *const _,
401                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
402                    notify_filter_trampoline::<Self, F> as *const (),
403                )),
404                Box_::into_raw(f),
405            )
406        }
407    }
408
409    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
410    #[doc(alias = "filters")]
411    fn connect_filters_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
412        unsafe extern "C" fn notify_filters_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
413            this: *mut ffi::GtkFileChooser,
414            _param_spec: glib::ffi::gpointer,
415            f: glib::ffi::gpointer,
416        ) {
417            let f: &F = &*(f as *const F);
418            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
419        }
420        unsafe {
421            let f: Box_<F> = Box_::new(f);
422            connect_raw(
423                self.as_ptr() as *mut _,
424                c"notify::filters".as_ptr() as *const _,
425                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
426                    notify_filters_trampoline::<Self, F> as *const (),
427                )),
428                Box_::into_raw(f),
429            )
430        }
431    }
432
433    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
434    #[doc(alias = "select-multiple")]
435    fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
436        unsafe extern "C" fn notify_select_multiple_trampoline<
437            P: IsA<FileChooser>,
438            F: Fn(&P) + 'static,
439        >(
440            this: *mut ffi::GtkFileChooser,
441            _param_spec: glib::ffi::gpointer,
442            f: glib::ffi::gpointer,
443        ) {
444            let f: &F = &*(f as *const F);
445            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
446        }
447        unsafe {
448            let f: Box_<F> = Box_::new(f);
449            connect_raw(
450                self.as_ptr() as *mut _,
451                c"notify::select-multiple".as_ptr() as *const _,
452                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
453                    notify_select_multiple_trampoline::<Self, F> as *const (),
454                )),
455                Box_::into_raw(f),
456            )
457        }
458    }
459
460    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
461    #[doc(alias = "shortcut-folders")]
462    fn connect_shortcut_folders_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
463        unsafe extern "C" fn notify_shortcut_folders_trampoline<
464            P: IsA<FileChooser>,
465            F: Fn(&P) + 'static,
466        >(
467            this: *mut ffi::GtkFileChooser,
468            _param_spec: glib::ffi::gpointer,
469            f: glib::ffi::gpointer,
470        ) {
471            let f: &F = &*(f as *const F);
472            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
473        }
474        unsafe {
475            let f: Box_<F> = Box_::new(f);
476            connect_raw(
477                self.as_ptr() as *mut _,
478                c"notify::shortcut-folders".as_ptr() as *const _,
479                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
480                    notify_shortcut_folders_trampoline::<Self, F> as *const (),
481                )),
482                Box_::into_raw(f),
483            )
484        }
485    }
486}
487
488impl<O: IsA<FileChooser>> FileChooserExt for O {}