gtk/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
5use gio;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib::GString;
12use glib_sys;
13use gtk_sys;
14use std;
15use std::boxed::Box as Box_;
16use std::fmt;
17use std::mem::transmute;
18use std::ptr;
19use Error;
20use FileChooserAction;
21use FileChooserConfirmation;
22use FileFilter;
23use Widget;
24
25glib_wrapper! {
26    pub struct FileChooser(Interface<gtk_sys::GtkFileChooser>);
27
28    match fn {
29        get_type => || gtk_sys::gtk_file_chooser_get_type(),
30    }
31}
32
33pub const NONE_FILE_CHOOSER: Option<&FileChooser> = None;
34
35pub trait FileChooserExt: 'static {
36    fn add_filter(&self, filter: &FileFilter);
37
38    fn add_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>;
39
40    fn add_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>;
41
42    fn get_action(&self) -> FileChooserAction;
43
44    #[cfg(any(feature = "v3_22", feature = "dox"))]
45    fn get_choice(&self, id: &str) -> Option<GString>;
46
47    fn get_create_folders(&self) -> bool;
48
49    fn get_current_folder(&self) -> Option<std::path::PathBuf>;
50
51    fn get_current_folder_file(&self) -> Option<gio::File>;
52
53    fn get_current_folder_uri(&self) -> Option<GString>;
54
55    fn get_current_name(&self) -> Option<GString>;
56
57    fn get_do_overwrite_confirmation(&self) -> bool;
58
59    fn get_extra_widget(&self) -> Option<Widget>;
60
61    fn get_file(&self) -> Option<gio::File>;
62
63    fn get_filename(&self) -> Option<std::path::PathBuf>;
64
65    fn get_filenames(&self) -> Vec<std::path::PathBuf>;
66
67    fn get_files(&self) -> Vec<gio::File>;
68
69    fn get_filter(&self) -> Option<FileFilter>;
70
71    fn get_local_only(&self) -> bool;
72
73    fn get_preview_file(&self) -> Option<gio::File>;
74
75    fn get_preview_filename(&self) -> Option<std::path::PathBuf>;
76
77    fn get_preview_uri(&self) -> Option<GString>;
78
79    fn get_preview_widget(&self) -> Option<Widget>;
80
81    fn get_preview_widget_active(&self) -> bool;
82
83    fn get_select_multiple(&self) -> bool;
84
85    fn get_show_hidden(&self) -> bool;
86
87    fn get_uri(&self) -> Option<GString>;
88
89    fn get_uris(&self) -> Vec<GString>;
90
91    fn get_use_preview_label(&self) -> bool;
92
93    fn list_filters(&self) -> Vec<FileFilter>;
94
95    fn list_shortcut_folder_uris(&self) -> Vec<GString>;
96
97    fn list_shortcut_folders(&self) -> Vec<std::path::PathBuf>;
98
99    #[cfg(any(feature = "v3_22", feature = "dox"))]
100    fn remove_choice(&self, id: &str);
101
102    fn remove_filter(&self, filter: &FileFilter);
103
104    fn remove_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error>;
105
106    fn remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error>;
107
108    fn select_all(&self);
109
110    fn select_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>;
111
112    fn select_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool;
113
114    fn select_uri(&self, uri: &str) -> bool;
115
116    fn set_action(&self, action: FileChooserAction);
117
118    #[cfg(any(feature = "v3_22", feature = "dox"))]
119    fn set_choice(&self, id: &str, option: &str);
120
121    fn set_create_folders(&self, create_folders: bool);
122
123    fn set_current_folder<P: AsRef<std::path::Path>>(&self, filename: P) -> bool;
124
125    fn set_current_folder_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>;
126
127    fn set_current_folder_uri(&self, uri: &str) -> bool;
128
129    fn set_current_name<P: AsRef<std::path::Path>>(&self, name: P);
130
131    fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool);
132
133    fn set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P);
134
135    fn set_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error>;
136
137    fn set_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool;
138
139    fn set_filter(&self, filter: &FileFilter);
140
141    fn set_local_only(&self, local_only: bool);
142
143    fn set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P);
144
145    fn set_preview_widget_active(&self, active: bool);
146
147    fn set_select_multiple(&self, select_multiple: bool);
148
149    fn set_show_hidden(&self, show_hidden: bool);
150
151    fn set_uri(&self, uri: &str) -> bool;
152
153    fn set_use_preview_label(&self, use_label: bool);
154
155    fn unselect_all(&self);
156
157    fn unselect_file<P: IsA<gio::File>>(&self, file: &P);
158
159    fn unselect_filename<P: AsRef<std::path::Path>>(&self, filename: P);
160
161    fn unselect_uri(&self, uri: &str);
162
163    fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>(
164        &self,
165        f: F,
166    ) -> SignalHandlerId;
167
168    fn connect_current_folder_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
169
170    fn connect_file_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
171
172    fn connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
173
174    fn connect_update_preview<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
175
176    fn connect_property_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
177
178    fn connect_property_create_folders_notify<F: Fn(&Self) + 'static>(
179        &self,
180        f: F,
181    ) -> SignalHandlerId;
182
183    fn connect_property_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>(
184        &self,
185        f: F,
186    ) -> SignalHandlerId;
187
188    fn connect_property_extra_widget_notify<F: Fn(&Self) + 'static>(&self, f: F)
189        -> SignalHandlerId;
190
191    fn connect_property_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
192
193    fn connect_property_local_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
194
195    fn connect_property_preview_widget_notify<F: Fn(&Self) + 'static>(
196        &self,
197        f: F,
198    ) -> SignalHandlerId;
199
200    fn connect_property_preview_widget_active_notify<F: Fn(&Self) + 'static>(
201        &self,
202        f: F,
203    ) -> SignalHandlerId;
204
205    fn connect_property_select_multiple_notify<F: Fn(&Self) + 'static>(
206        &self,
207        f: F,
208    ) -> SignalHandlerId;
209
210    fn connect_property_show_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
211
212    fn connect_property_use_preview_label_notify<F: Fn(&Self) + 'static>(
213        &self,
214        f: F,
215    ) -> SignalHandlerId;
216}
217
218impl<O: IsA<FileChooser>> FileChooserExt for O {
219    fn add_filter(&self, filter: &FileFilter) {
220        unsafe {
221            gtk_sys::gtk_file_chooser_add_filter(
222                self.as_ref().to_glib_none().0,
223                filter.to_glib_full(),
224            );
225        }
226    }
227
228    fn add_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error> {
229        unsafe {
230            let mut error = ptr::null_mut();
231            let _ = gtk_sys::gtk_file_chooser_add_shortcut_folder(
232                self.as_ref().to_glib_none().0,
233                folder.as_ref().to_glib_none().0,
234                &mut error,
235            );
236            if error.is_null() {
237                Ok(())
238            } else {
239                Err(from_glib_full(error))
240            }
241        }
242    }
243
244    fn add_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error> {
245        unsafe {
246            let mut error = ptr::null_mut();
247            let _ = gtk_sys::gtk_file_chooser_add_shortcut_folder_uri(
248                self.as_ref().to_glib_none().0,
249                uri.to_glib_none().0,
250                &mut error,
251            );
252            if error.is_null() {
253                Ok(())
254            } else {
255                Err(from_glib_full(error))
256            }
257        }
258    }
259
260    fn get_action(&self) -> FileChooserAction {
261        unsafe {
262            from_glib(gtk_sys::gtk_file_chooser_get_action(
263                self.as_ref().to_glib_none().0,
264            ))
265        }
266    }
267
268    #[cfg(any(feature = "v3_22", feature = "dox"))]
269    fn get_choice(&self, id: &str) -> Option<GString> {
270        unsafe {
271            from_glib_none(gtk_sys::gtk_file_chooser_get_choice(
272                self.as_ref().to_glib_none().0,
273                id.to_glib_none().0,
274            ))
275        }
276    }
277
278    fn get_create_folders(&self) -> bool {
279        unsafe {
280            from_glib(gtk_sys::gtk_file_chooser_get_create_folders(
281                self.as_ref().to_glib_none().0,
282            ))
283        }
284    }
285
286    fn get_current_folder(&self) -> Option<std::path::PathBuf> {
287        unsafe {
288            from_glib_full(gtk_sys::gtk_file_chooser_get_current_folder(
289                self.as_ref().to_glib_none().0,
290            ))
291        }
292    }
293
294    fn get_current_folder_file(&self) -> Option<gio::File> {
295        unsafe {
296            from_glib_full(gtk_sys::gtk_file_chooser_get_current_folder_file(
297                self.as_ref().to_glib_none().0,
298            ))
299        }
300    }
301
302    fn get_current_folder_uri(&self) -> Option<GString> {
303        unsafe {
304            from_glib_full(gtk_sys::gtk_file_chooser_get_current_folder_uri(
305                self.as_ref().to_glib_none().0,
306            ))
307        }
308    }
309
310    fn get_current_name(&self) -> Option<GString> {
311        unsafe {
312            from_glib_full(gtk_sys::gtk_file_chooser_get_current_name(
313                self.as_ref().to_glib_none().0,
314            ))
315        }
316    }
317
318    fn get_do_overwrite_confirmation(&self) -> bool {
319        unsafe {
320            from_glib(gtk_sys::gtk_file_chooser_get_do_overwrite_confirmation(
321                self.as_ref().to_glib_none().0,
322            ))
323        }
324    }
325
326    fn get_extra_widget(&self) -> Option<Widget> {
327        unsafe {
328            from_glib_none(gtk_sys::gtk_file_chooser_get_extra_widget(
329                self.as_ref().to_glib_none().0,
330            ))
331        }
332    }
333
334    fn get_file(&self) -> Option<gio::File> {
335        unsafe {
336            from_glib_full(gtk_sys::gtk_file_chooser_get_file(
337                self.as_ref().to_glib_none().0,
338            ))
339        }
340    }
341
342    fn get_filename(&self) -> Option<std::path::PathBuf> {
343        unsafe {
344            from_glib_full(gtk_sys::gtk_file_chooser_get_filename(
345                self.as_ref().to_glib_none().0,
346            ))
347        }
348    }
349
350    fn get_filenames(&self) -> Vec<std::path::PathBuf> {
351        unsafe {
352            FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_get_filenames(
353                self.as_ref().to_glib_none().0,
354            ))
355        }
356    }
357
358    fn get_files(&self) -> Vec<gio::File> {
359        unsafe {
360            FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_get_files(
361                self.as_ref().to_glib_none().0,
362            ))
363        }
364    }
365
366    fn get_filter(&self) -> Option<FileFilter> {
367        unsafe {
368            from_glib_none(gtk_sys::gtk_file_chooser_get_filter(
369                self.as_ref().to_glib_none().0,
370            ))
371        }
372    }
373
374    fn get_local_only(&self) -> bool {
375        unsafe {
376            from_glib(gtk_sys::gtk_file_chooser_get_local_only(
377                self.as_ref().to_glib_none().0,
378            ))
379        }
380    }
381
382    fn get_preview_file(&self) -> Option<gio::File> {
383        unsafe {
384            from_glib_full(gtk_sys::gtk_file_chooser_get_preview_file(
385                self.as_ref().to_glib_none().0,
386            ))
387        }
388    }
389
390    fn get_preview_filename(&self) -> Option<std::path::PathBuf> {
391        unsafe {
392            from_glib_full(gtk_sys::gtk_file_chooser_get_preview_filename(
393                self.as_ref().to_glib_none().0,
394            ))
395        }
396    }
397
398    fn get_preview_uri(&self) -> Option<GString> {
399        unsafe {
400            from_glib_full(gtk_sys::gtk_file_chooser_get_preview_uri(
401                self.as_ref().to_glib_none().0,
402            ))
403        }
404    }
405
406    fn get_preview_widget(&self) -> Option<Widget> {
407        unsafe {
408            from_glib_none(gtk_sys::gtk_file_chooser_get_preview_widget(
409                self.as_ref().to_glib_none().0,
410            ))
411        }
412    }
413
414    fn get_preview_widget_active(&self) -> bool {
415        unsafe {
416            from_glib(gtk_sys::gtk_file_chooser_get_preview_widget_active(
417                self.as_ref().to_glib_none().0,
418            ))
419        }
420    }
421
422    fn get_select_multiple(&self) -> bool {
423        unsafe {
424            from_glib(gtk_sys::gtk_file_chooser_get_select_multiple(
425                self.as_ref().to_glib_none().0,
426            ))
427        }
428    }
429
430    fn get_show_hidden(&self) -> bool {
431        unsafe {
432            from_glib(gtk_sys::gtk_file_chooser_get_show_hidden(
433                self.as_ref().to_glib_none().0,
434            ))
435        }
436    }
437
438    fn get_uri(&self) -> Option<GString> {
439        unsafe {
440            from_glib_full(gtk_sys::gtk_file_chooser_get_uri(
441                self.as_ref().to_glib_none().0,
442            ))
443        }
444    }
445
446    fn get_uris(&self) -> Vec<GString> {
447        unsafe {
448            FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_get_uris(
449                self.as_ref().to_glib_none().0,
450            ))
451        }
452    }
453
454    fn get_use_preview_label(&self) -> bool {
455        unsafe {
456            from_glib(gtk_sys::gtk_file_chooser_get_use_preview_label(
457                self.as_ref().to_glib_none().0,
458            ))
459        }
460    }
461
462    fn list_filters(&self) -> Vec<FileFilter> {
463        unsafe {
464            FromGlibPtrContainer::from_glib_container(gtk_sys::gtk_file_chooser_list_filters(
465                self.as_ref().to_glib_none().0,
466            ))
467        }
468    }
469
470    fn list_shortcut_folder_uris(&self) -> Vec<GString> {
471        unsafe {
472            FromGlibPtrContainer::from_glib_full(
473                gtk_sys::gtk_file_chooser_list_shortcut_folder_uris(self.as_ref().to_glib_none().0),
474            )
475        }
476    }
477
478    fn list_shortcut_folders(&self) -> Vec<std::path::PathBuf> {
479        unsafe {
480            FromGlibPtrContainer::from_glib_full(gtk_sys::gtk_file_chooser_list_shortcut_folders(
481                self.as_ref().to_glib_none().0,
482            ))
483        }
484    }
485
486    #[cfg(any(feature = "v3_22", feature = "dox"))]
487    fn remove_choice(&self, id: &str) {
488        unsafe {
489            gtk_sys::gtk_file_chooser_remove_choice(
490                self.as_ref().to_glib_none().0,
491                id.to_glib_none().0,
492            );
493        }
494    }
495
496    fn remove_filter(&self, filter: &FileFilter) {
497        unsafe {
498            gtk_sys::gtk_file_chooser_remove_filter(
499                self.as_ref().to_glib_none().0,
500                filter.to_glib_none().0,
501            );
502        }
503    }
504
505    fn remove_shortcut_folder<P: AsRef<std::path::Path>>(&self, folder: P) -> Result<(), Error> {
506        unsafe {
507            let mut error = ptr::null_mut();
508            let _ = gtk_sys::gtk_file_chooser_remove_shortcut_folder(
509                self.as_ref().to_glib_none().0,
510                folder.as_ref().to_glib_none().0,
511                &mut error,
512            );
513            if error.is_null() {
514                Ok(())
515            } else {
516                Err(from_glib_full(error))
517            }
518        }
519    }
520
521    fn remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), Error> {
522        unsafe {
523            let mut error = ptr::null_mut();
524            let _ = gtk_sys::gtk_file_chooser_remove_shortcut_folder_uri(
525                self.as_ref().to_glib_none().0,
526                uri.to_glib_none().0,
527                &mut error,
528            );
529            if error.is_null() {
530                Ok(())
531            } else {
532                Err(from_glib_full(error))
533            }
534        }
535    }
536
537    fn select_all(&self) {
538        unsafe {
539            gtk_sys::gtk_file_chooser_select_all(self.as_ref().to_glib_none().0);
540        }
541    }
542
543    fn select_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error> {
544        unsafe {
545            let mut error = ptr::null_mut();
546            let _ = gtk_sys::gtk_file_chooser_select_file(
547                self.as_ref().to_glib_none().0,
548                file.as_ref().to_glib_none().0,
549                &mut error,
550            );
551            if error.is_null() {
552                Ok(())
553            } else {
554                Err(from_glib_full(error))
555            }
556        }
557    }
558
559    fn select_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool {
560        unsafe {
561            from_glib(gtk_sys::gtk_file_chooser_select_filename(
562                self.as_ref().to_glib_none().0,
563                filename.as_ref().to_glib_none().0,
564            ))
565        }
566    }
567
568    fn select_uri(&self, uri: &str) -> bool {
569        unsafe {
570            from_glib(gtk_sys::gtk_file_chooser_select_uri(
571                self.as_ref().to_glib_none().0,
572                uri.to_glib_none().0,
573            ))
574        }
575    }
576
577    fn set_action(&self, action: FileChooserAction) {
578        unsafe {
579            gtk_sys::gtk_file_chooser_set_action(self.as_ref().to_glib_none().0, action.to_glib());
580        }
581    }
582
583    #[cfg(any(feature = "v3_22", feature = "dox"))]
584    fn set_choice(&self, id: &str, option: &str) {
585        unsafe {
586            gtk_sys::gtk_file_chooser_set_choice(
587                self.as_ref().to_glib_none().0,
588                id.to_glib_none().0,
589                option.to_glib_none().0,
590            );
591        }
592    }
593
594    fn set_create_folders(&self, create_folders: bool) {
595        unsafe {
596            gtk_sys::gtk_file_chooser_set_create_folders(
597                self.as_ref().to_glib_none().0,
598                create_folders.to_glib(),
599            );
600        }
601    }
602
603    fn set_current_folder<P: AsRef<std::path::Path>>(&self, filename: P) -> bool {
604        unsafe {
605            from_glib(gtk_sys::gtk_file_chooser_set_current_folder(
606                self.as_ref().to_glib_none().0,
607                filename.as_ref().to_glib_none().0,
608            ))
609        }
610    }
611
612    fn set_current_folder_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error> {
613        unsafe {
614            let mut error = ptr::null_mut();
615            let _ = gtk_sys::gtk_file_chooser_set_current_folder_file(
616                self.as_ref().to_glib_none().0,
617                file.as_ref().to_glib_none().0,
618                &mut error,
619            );
620            if error.is_null() {
621                Ok(())
622            } else {
623                Err(from_glib_full(error))
624            }
625        }
626    }
627
628    fn set_current_folder_uri(&self, uri: &str) -> bool {
629        unsafe {
630            from_glib(gtk_sys::gtk_file_chooser_set_current_folder_uri(
631                self.as_ref().to_glib_none().0,
632                uri.to_glib_none().0,
633            ))
634        }
635    }
636
637    fn set_current_name<P: AsRef<std::path::Path>>(&self, name: P) {
638        unsafe {
639            gtk_sys::gtk_file_chooser_set_current_name(
640                self.as_ref().to_glib_none().0,
641                name.as_ref().to_glib_none().0,
642            );
643        }
644    }
645
646    fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool) {
647        unsafe {
648            gtk_sys::gtk_file_chooser_set_do_overwrite_confirmation(
649                self.as_ref().to_glib_none().0,
650                do_overwrite_confirmation.to_glib(),
651            );
652        }
653    }
654
655    fn set_extra_widget<P: IsA<Widget>>(&self, extra_widget: &P) {
656        unsafe {
657            gtk_sys::gtk_file_chooser_set_extra_widget(
658                self.as_ref().to_glib_none().0,
659                extra_widget.as_ref().to_glib_none().0,
660            );
661        }
662    }
663
664    fn set_file<P: IsA<gio::File>>(&self, file: &P) -> Result<(), Error> {
665        unsafe {
666            let mut error = ptr::null_mut();
667            let _ = gtk_sys::gtk_file_chooser_set_file(
668                self.as_ref().to_glib_none().0,
669                file.as_ref().to_glib_none().0,
670                &mut error,
671            );
672            if error.is_null() {
673                Ok(())
674            } else {
675                Err(from_glib_full(error))
676            }
677        }
678    }
679
680    fn set_filename<P: AsRef<std::path::Path>>(&self, filename: P) -> bool {
681        unsafe {
682            from_glib(gtk_sys::gtk_file_chooser_set_filename(
683                self.as_ref().to_glib_none().0,
684                filename.as_ref().to_glib_none().0,
685            ))
686        }
687    }
688
689    fn set_filter(&self, filter: &FileFilter) {
690        unsafe {
691            gtk_sys::gtk_file_chooser_set_filter(
692                self.as_ref().to_glib_none().0,
693                filter.to_glib_none().0,
694            );
695        }
696    }
697
698    fn set_local_only(&self, local_only: bool) {
699        unsafe {
700            gtk_sys::gtk_file_chooser_set_local_only(
701                self.as_ref().to_glib_none().0,
702                local_only.to_glib(),
703            );
704        }
705    }
706
707    fn set_preview_widget<P: IsA<Widget>>(&self, preview_widget: &P) {
708        unsafe {
709            gtk_sys::gtk_file_chooser_set_preview_widget(
710                self.as_ref().to_glib_none().0,
711                preview_widget.as_ref().to_glib_none().0,
712            );
713        }
714    }
715
716    fn set_preview_widget_active(&self, active: bool) {
717        unsafe {
718            gtk_sys::gtk_file_chooser_set_preview_widget_active(
719                self.as_ref().to_glib_none().0,
720                active.to_glib(),
721            );
722        }
723    }
724
725    fn set_select_multiple(&self, select_multiple: bool) {
726        unsafe {
727            gtk_sys::gtk_file_chooser_set_select_multiple(
728                self.as_ref().to_glib_none().0,
729                select_multiple.to_glib(),
730            );
731        }
732    }
733
734    fn set_show_hidden(&self, show_hidden: bool) {
735        unsafe {
736            gtk_sys::gtk_file_chooser_set_show_hidden(
737                self.as_ref().to_glib_none().0,
738                show_hidden.to_glib(),
739            );
740        }
741    }
742
743    fn set_uri(&self, uri: &str) -> bool {
744        unsafe {
745            from_glib(gtk_sys::gtk_file_chooser_set_uri(
746                self.as_ref().to_glib_none().0,
747                uri.to_glib_none().0,
748            ))
749        }
750    }
751
752    fn set_use_preview_label(&self, use_label: bool) {
753        unsafe {
754            gtk_sys::gtk_file_chooser_set_use_preview_label(
755                self.as_ref().to_glib_none().0,
756                use_label.to_glib(),
757            );
758        }
759    }
760
761    fn unselect_all(&self) {
762        unsafe {
763            gtk_sys::gtk_file_chooser_unselect_all(self.as_ref().to_glib_none().0);
764        }
765    }
766
767    fn unselect_file<P: IsA<gio::File>>(&self, file: &P) {
768        unsafe {
769            gtk_sys::gtk_file_chooser_unselect_file(
770                self.as_ref().to_glib_none().0,
771                file.as_ref().to_glib_none().0,
772            );
773        }
774    }
775
776    fn unselect_filename<P: AsRef<std::path::Path>>(&self, filename: P) {
777        unsafe {
778            gtk_sys::gtk_file_chooser_unselect_filename(
779                self.as_ref().to_glib_none().0,
780                filename.as_ref().to_glib_none().0,
781            );
782        }
783    }
784
785    fn unselect_uri(&self, uri: &str) {
786        unsafe {
787            gtk_sys::gtk_file_chooser_unselect_uri(
788                self.as_ref().to_glib_none().0,
789                uri.to_glib_none().0,
790            );
791        }
792    }
793
794    fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>(
795        &self,
796        f: F,
797    ) -> SignalHandlerId {
798        unsafe extern "C" fn confirm_overwrite_trampoline<
799            P,
800            F: Fn(&P) -> FileChooserConfirmation + 'static,
801        >(
802            this: *mut gtk_sys::GtkFileChooser,
803            f: glib_sys::gpointer,
804        ) -> gtk_sys::GtkFileChooserConfirmation
805        where
806            P: IsA<FileChooser>,
807        {
808            let f: &F = &*(f as *const F);
809            f(&FileChooser::from_glib_borrow(this).unsafe_cast()).to_glib()
810        }
811        unsafe {
812            let f: Box_<F> = Box_::new(f);
813            connect_raw(
814                self.as_ptr() as *mut _,
815                b"confirm-overwrite\0".as_ptr() as *const _,
816                Some(transmute(confirm_overwrite_trampoline::<Self, F> as usize)),
817                Box_::into_raw(f),
818            )
819        }
820    }
821
822    fn connect_current_folder_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
823        unsafe extern "C" fn current_folder_changed_trampoline<P, F: Fn(&P) + 'static>(
824            this: *mut gtk_sys::GtkFileChooser,
825            f: glib_sys::gpointer,
826        ) where
827            P: IsA<FileChooser>,
828        {
829            let f: &F = &*(f as *const F);
830            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
831        }
832        unsafe {
833            let f: Box_<F> = Box_::new(f);
834            connect_raw(
835                self.as_ptr() as *mut _,
836                b"current-folder-changed\0".as_ptr() as *const _,
837                Some(transmute(
838                    current_folder_changed_trampoline::<Self, F> as usize,
839                )),
840                Box_::into_raw(f),
841            )
842        }
843    }
844
845    fn connect_file_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
846        unsafe extern "C" fn file_activated_trampoline<P, F: Fn(&P) + 'static>(
847            this: *mut gtk_sys::GtkFileChooser,
848            f: glib_sys::gpointer,
849        ) where
850            P: IsA<FileChooser>,
851        {
852            let f: &F = &*(f as *const F);
853            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
854        }
855        unsafe {
856            let f: Box_<F> = Box_::new(f);
857            connect_raw(
858                self.as_ptr() as *mut _,
859                b"file-activated\0".as_ptr() as *const _,
860                Some(transmute(file_activated_trampoline::<Self, F> as usize)),
861                Box_::into_raw(f),
862            )
863        }
864    }
865
866    fn connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
867        unsafe extern "C" fn selection_changed_trampoline<P, F: Fn(&P) + 'static>(
868            this: *mut gtk_sys::GtkFileChooser,
869            f: glib_sys::gpointer,
870        ) where
871            P: IsA<FileChooser>,
872        {
873            let f: &F = &*(f as *const F);
874            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
875        }
876        unsafe {
877            let f: Box_<F> = Box_::new(f);
878            connect_raw(
879                self.as_ptr() as *mut _,
880                b"selection-changed\0".as_ptr() as *const _,
881                Some(transmute(selection_changed_trampoline::<Self, F> as usize)),
882                Box_::into_raw(f),
883            )
884        }
885    }
886
887    fn connect_update_preview<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
888        unsafe extern "C" fn update_preview_trampoline<P, F: Fn(&P) + 'static>(
889            this: *mut gtk_sys::GtkFileChooser,
890            f: glib_sys::gpointer,
891        ) where
892            P: IsA<FileChooser>,
893        {
894            let f: &F = &*(f as *const F);
895            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
896        }
897        unsafe {
898            let f: Box_<F> = Box_::new(f);
899            connect_raw(
900                self.as_ptr() as *mut _,
901                b"update-preview\0".as_ptr() as *const _,
902                Some(transmute(update_preview_trampoline::<Self, F> as usize)),
903                Box_::into_raw(f),
904            )
905        }
906    }
907
908    fn connect_property_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
909        unsafe extern "C" fn notify_action_trampoline<P, F: Fn(&P) + 'static>(
910            this: *mut gtk_sys::GtkFileChooser,
911            _param_spec: glib_sys::gpointer,
912            f: glib_sys::gpointer,
913        ) where
914            P: IsA<FileChooser>,
915        {
916            let f: &F = &*(f as *const F);
917            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
918        }
919        unsafe {
920            let f: Box_<F> = Box_::new(f);
921            connect_raw(
922                self.as_ptr() as *mut _,
923                b"notify::action\0".as_ptr() as *const _,
924                Some(transmute(notify_action_trampoline::<Self, F> as usize)),
925                Box_::into_raw(f),
926            )
927        }
928    }
929
930    fn connect_property_create_folders_notify<F: Fn(&Self) + 'static>(
931        &self,
932        f: F,
933    ) -> SignalHandlerId {
934        unsafe extern "C" fn notify_create_folders_trampoline<P, F: Fn(&P) + 'static>(
935            this: *mut gtk_sys::GtkFileChooser,
936            _param_spec: glib_sys::gpointer,
937            f: glib_sys::gpointer,
938        ) where
939            P: IsA<FileChooser>,
940        {
941            let f: &F = &*(f as *const F);
942            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
943        }
944        unsafe {
945            let f: Box_<F> = Box_::new(f);
946            connect_raw(
947                self.as_ptr() as *mut _,
948                b"notify::create-folders\0".as_ptr() as *const _,
949                Some(transmute(
950                    notify_create_folders_trampoline::<Self, F> as usize,
951                )),
952                Box_::into_raw(f),
953            )
954        }
955    }
956
957    fn connect_property_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>(
958        &self,
959        f: F,
960    ) -> SignalHandlerId {
961        unsafe extern "C" fn notify_do_overwrite_confirmation_trampoline<P, F: Fn(&P) + 'static>(
962            this: *mut gtk_sys::GtkFileChooser,
963            _param_spec: glib_sys::gpointer,
964            f: glib_sys::gpointer,
965        ) where
966            P: IsA<FileChooser>,
967        {
968            let f: &F = &*(f as *const F);
969            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
970        }
971        unsafe {
972            let f: Box_<F> = Box_::new(f);
973            connect_raw(
974                self.as_ptr() as *mut _,
975                b"notify::do-overwrite-confirmation\0".as_ptr() as *const _,
976                Some(transmute(
977                    notify_do_overwrite_confirmation_trampoline::<Self, F> as usize,
978                )),
979                Box_::into_raw(f),
980            )
981        }
982    }
983
984    fn connect_property_extra_widget_notify<F: Fn(&Self) + 'static>(
985        &self,
986        f: F,
987    ) -> SignalHandlerId {
988        unsafe extern "C" fn notify_extra_widget_trampoline<P, F: Fn(&P) + 'static>(
989            this: *mut gtk_sys::GtkFileChooser,
990            _param_spec: glib_sys::gpointer,
991            f: glib_sys::gpointer,
992        ) where
993            P: IsA<FileChooser>,
994        {
995            let f: &F = &*(f as *const F);
996            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
997        }
998        unsafe {
999            let f: Box_<F> = Box_::new(f);
1000            connect_raw(
1001                self.as_ptr() as *mut _,
1002                b"notify::extra-widget\0".as_ptr() as *const _,
1003                Some(transmute(
1004                    notify_extra_widget_trampoline::<Self, F> as usize,
1005                )),
1006                Box_::into_raw(f),
1007            )
1008        }
1009    }
1010
1011    fn connect_property_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1012        unsafe extern "C" fn notify_filter_trampoline<P, F: Fn(&P) + 'static>(
1013            this: *mut gtk_sys::GtkFileChooser,
1014            _param_spec: glib_sys::gpointer,
1015            f: glib_sys::gpointer,
1016        ) where
1017            P: IsA<FileChooser>,
1018        {
1019            let f: &F = &*(f as *const F);
1020            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
1021        }
1022        unsafe {
1023            let f: Box_<F> = Box_::new(f);
1024            connect_raw(
1025                self.as_ptr() as *mut _,
1026                b"notify::filter\0".as_ptr() as *const _,
1027                Some(transmute(notify_filter_trampoline::<Self, F> as usize)),
1028                Box_::into_raw(f),
1029            )
1030        }
1031    }
1032
1033    fn connect_property_local_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1034        unsafe extern "C" fn notify_local_only_trampoline<P, F: Fn(&P) + 'static>(
1035            this: *mut gtk_sys::GtkFileChooser,
1036            _param_spec: glib_sys::gpointer,
1037            f: glib_sys::gpointer,
1038        ) where
1039            P: IsA<FileChooser>,
1040        {
1041            let f: &F = &*(f as *const F);
1042            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
1043        }
1044        unsafe {
1045            let f: Box_<F> = Box_::new(f);
1046            connect_raw(
1047                self.as_ptr() as *mut _,
1048                b"notify::local-only\0".as_ptr() as *const _,
1049                Some(transmute(notify_local_only_trampoline::<Self, F> as usize)),
1050                Box_::into_raw(f),
1051            )
1052        }
1053    }
1054
1055    fn connect_property_preview_widget_notify<F: Fn(&Self) + 'static>(
1056        &self,
1057        f: F,
1058    ) -> SignalHandlerId {
1059        unsafe extern "C" fn notify_preview_widget_trampoline<P, F: Fn(&P) + 'static>(
1060            this: *mut gtk_sys::GtkFileChooser,
1061            _param_spec: glib_sys::gpointer,
1062            f: glib_sys::gpointer,
1063        ) where
1064            P: IsA<FileChooser>,
1065        {
1066            let f: &F = &*(f as *const F);
1067            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
1068        }
1069        unsafe {
1070            let f: Box_<F> = Box_::new(f);
1071            connect_raw(
1072                self.as_ptr() as *mut _,
1073                b"notify::preview-widget\0".as_ptr() as *const _,
1074                Some(transmute(
1075                    notify_preview_widget_trampoline::<Self, F> as usize,
1076                )),
1077                Box_::into_raw(f),
1078            )
1079        }
1080    }
1081
1082    fn connect_property_preview_widget_active_notify<F: Fn(&Self) + 'static>(
1083        &self,
1084        f: F,
1085    ) -> SignalHandlerId {
1086        unsafe extern "C" fn notify_preview_widget_active_trampoline<P, F: Fn(&P) + 'static>(
1087            this: *mut gtk_sys::GtkFileChooser,
1088            _param_spec: glib_sys::gpointer,
1089            f: glib_sys::gpointer,
1090        ) where
1091            P: IsA<FileChooser>,
1092        {
1093            let f: &F = &*(f as *const F);
1094            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
1095        }
1096        unsafe {
1097            let f: Box_<F> = Box_::new(f);
1098            connect_raw(
1099                self.as_ptr() as *mut _,
1100                b"notify::preview-widget-active\0".as_ptr() as *const _,
1101                Some(transmute(
1102                    notify_preview_widget_active_trampoline::<Self, F> as usize,
1103                )),
1104                Box_::into_raw(f),
1105            )
1106        }
1107    }
1108
1109    fn connect_property_select_multiple_notify<F: Fn(&Self) + 'static>(
1110        &self,
1111        f: F,
1112    ) -> SignalHandlerId {
1113        unsafe extern "C" fn notify_select_multiple_trampoline<P, F: Fn(&P) + 'static>(
1114            this: *mut gtk_sys::GtkFileChooser,
1115            _param_spec: glib_sys::gpointer,
1116            f: glib_sys::gpointer,
1117        ) where
1118            P: IsA<FileChooser>,
1119        {
1120            let f: &F = &*(f as *const F);
1121            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
1122        }
1123        unsafe {
1124            let f: Box_<F> = Box_::new(f);
1125            connect_raw(
1126                self.as_ptr() as *mut _,
1127                b"notify::select-multiple\0".as_ptr() as *const _,
1128                Some(transmute(
1129                    notify_select_multiple_trampoline::<Self, F> as usize,
1130                )),
1131                Box_::into_raw(f),
1132            )
1133        }
1134    }
1135
1136    fn connect_property_show_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1137        unsafe extern "C" fn notify_show_hidden_trampoline<P, F: Fn(&P) + 'static>(
1138            this: *mut gtk_sys::GtkFileChooser,
1139            _param_spec: glib_sys::gpointer,
1140            f: glib_sys::gpointer,
1141        ) where
1142            P: IsA<FileChooser>,
1143        {
1144            let f: &F = &*(f as *const F);
1145            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
1146        }
1147        unsafe {
1148            let f: Box_<F> = Box_::new(f);
1149            connect_raw(
1150                self.as_ptr() as *mut _,
1151                b"notify::show-hidden\0".as_ptr() as *const _,
1152                Some(transmute(notify_show_hidden_trampoline::<Self, F> as usize)),
1153                Box_::into_raw(f),
1154            )
1155        }
1156    }
1157
1158    fn connect_property_use_preview_label_notify<F: Fn(&Self) + 'static>(
1159        &self,
1160        f: F,
1161    ) -> SignalHandlerId {
1162        unsafe extern "C" fn notify_use_preview_label_trampoline<P, F: Fn(&P) + 'static>(
1163            this: *mut gtk_sys::GtkFileChooser,
1164            _param_spec: glib_sys::gpointer,
1165            f: glib_sys::gpointer,
1166        ) where
1167            P: IsA<FileChooser>,
1168        {
1169            let f: &F = &*(f as *const F);
1170            f(&FileChooser::from_glib_borrow(this).unsafe_cast())
1171        }
1172        unsafe {
1173            let f: Box_<F> = Box_::new(f);
1174            connect_raw(
1175                self.as_ptr() as *mut _,
1176                b"notify::use-preview-label\0".as_ptr() as *const _,
1177                Some(transmute(
1178                    notify_use_preview_label_trampoline::<Self, F> as usize,
1179                )),
1180                Box_::into_raw(f),
1181            )
1182        }
1183    }
1184}
1185
1186impl fmt::Display for FileChooser {
1187    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1188        write!(f, "FileChooser")
1189    }
1190}