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    /// Use [`FileDialog`][crate::FileDialog] instead
16    /// [`FileChooser`][crate::FileChooser] is an interface that can be implemented by file
17    /// selection widgets.
18    ///
19    /// In GTK, the main objects that implement this interface are
20    /// [`FileChooserWidget`][crate::FileChooserWidget] and [`FileChooserDialog`][crate::FileChooserDialog].
21    ///
22    /// You do not need to write an object that implements the [`FileChooser`][crate::FileChooser]
23    /// interface unless you are trying to adapt an existing file selector to
24    /// expose a standard programming interface.
25    ///
26    /// [`FileChooser`][crate::FileChooser] allows for shortcuts to various places in the filesystem.
27    /// In the default implementation these are displayed in the left pane. It
28    /// may be a bit confusing at first that these shortcuts come from various
29    /// sources and in various flavours, so lets explain the terminology here:
30    ///
31    /// - Bookmarks: are created by the user, by dragging folders from the
32    ///   right pane to the left pane, or by using the “Add”. Bookmarks
33    ///   can be renamed and deleted by the user.
34    ///
35    /// - Shortcuts: can be provided by the application. For example, a Paint
36    ///   program may want to add a shortcut for a Clipart folder. Shortcuts
37    ///   cannot be modified by the user.
38    ///
39    /// - Volumes: are provided by the underlying filesystem abstraction. They are
40    ///   the “roots” of the filesystem.
41    ///
42    /// # File Names and Encodings
43    ///
44    /// When the user is finished selecting files in a [`FileChooser`][crate::FileChooser], your
45    /// program can get the selected filenames as `GFile`s.
46    ///
47    /// # Adding options
48    ///
49    /// You can add extra widgets to a file chooser to provide options
50    /// that are not present in the default design, by using
51    /// [`FileChooserExtManual::add_choice()`][crate::prelude::FileChooserExtManual::add_choice()]. Each choice has an identifier and
52    /// a user visible label; additionally, each choice can have multiple
53    /// options. If a choice has no option, it will be rendered as a
54    /// check button with the given label; if a choice has options, it will
55    /// be rendered as a combo box.
56    ///
57    /// ## Properties
58    ///
59    ///
60    /// #### `action`
61    ///  The type of operation that the file chooser is performing.
62    ///
63    /// Readable | Writeable
64    ///
65    ///
66    /// #### `create-folders`
67    ///  Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
68    /// will offer the user to create new folders.
69    ///
70    /// Readable | Writeable
71    ///
72    ///
73    /// #### `filter`
74    ///  The current filter for selecting files that are displayed.
75    ///
76    /// Readable | Writeable
77    ///
78    ///
79    /// #### `filters`
80    ///  A `GListModel` containing the filters that have been
81    /// added with gtk_file_chooser_add_filter().
82    ///
83    /// The returned object should not be modified. It may
84    /// or may not be updated for later changes.
85    ///
86    /// Readable
87    ///
88    ///
89    /// #### `select-multiple`
90    ///  Whether to allow multiple files to be selected.
91    ///
92    /// Readable | Writeable
93    ///
94    ///
95    /// #### `shortcut-folders`
96    ///  A `GListModel` containing the shortcut folders that have been
97    /// added with gtk_file_chooser_add_shortcut_folder().
98    ///
99    /// The returned object should not be modified. It may
100    /// or may not be updated for later changes.
101    ///
102    /// Readable
103    ///
104    /// # Implements
105    ///
106    /// [`FileChooserExt`][trait@crate::prelude::FileChooserExt], [`FileChooserExtManual`][trait@crate::prelude::FileChooserExtManual]
107    #[doc(alias = "GtkFileChooser")]
108    pub struct FileChooser(Interface<ffi::GtkFileChooser>);
109
110    match fn {
111        type_ => || ffi::gtk_file_chooser_get_type(),
112    }
113}
114
115impl FileChooser {
116    pub const NONE: Option<&'static FileChooser> = None;
117}
118
119mod sealed {
120    pub trait Sealed {}
121    impl<T: super::IsA<super::FileChooser>> Sealed for T {}
122}
123
124/// Trait containing all [`struct@FileChooser`] methods.
125///
126/// # Implementors
127///
128/// [`FileChooserDialog`][struct@crate::FileChooserDialog], [`FileChooserNative`][struct@crate::FileChooserNative], [`FileChooserWidget`][struct@crate::FileChooserWidget], [`FileChooser`][struct@crate::FileChooser]
129pub trait FileChooserExt: IsA<FileChooser> + sealed::Sealed + 'static {
130    /// Adds @filter to the list of filters that the user can select between.
131    ///
132    /// When a filter is selected, only files that are passed by that
133    /// filter are displayed.
134    ///
135    /// Note that the @self takes ownership of the filter if it is floating,
136    /// so you have to ref and sink it if you want to keep a reference.
137    ///
138    /// # Deprecated since 4.10
139    ///
140    /// Use [`FileDialog`][crate::FileDialog] instead
141    /// ## `filter`
142    /// a [`FileFilter`][crate::FileFilter]
143    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
144    #[allow(deprecated)]
145    #[doc(alias = "gtk_file_chooser_add_filter")]
146    fn add_filter(&self, filter: &FileFilter) {
147        unsafe {
148            ffi::gtk_file_chooser_add_filter(
149                self.as_ref().to_glib_none().0,
150                filter.to_glib_none().0,
151            );
152        }
153    }
154
155    /// Adds a folder to be displayed with the shortcut folders
156    /// in a file chooser.
157    ///
158    /// # Deprecated since 4.10
159    ///
160    /// Use [`FileDialog`][crate::FileDialog] instead
161    /// ## `folder`
162    /// a `GFile` for the folder to add
163    ///
164    /// # Returns
165    ///
166    /// [`true`] if the folder could be added successfully,
167    ///   [`false`] otherwise.
168    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
169    #[allow(deprecated)]
170    #[doc(alias = "gtk_file_chooser_add_shortcut_folder")]
171    fn add_shortcut_folder(&self, folder: &impl IsA<gio::File>) -> Result<(), glib::Error> {
172        unsafe {
173            let mut error = std::ptr::null_mut();
174            let is_ok = ffi::gtk_file_chooser_add_shortcut_folder(
175                self.as_ref().to_glib_none().0,
176                folder.as_ref().to_glib_none().0,
177                &mut error,
178            );
179            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
180            if error.is_null() {
181                Ok(())
182            } else {
183                Err(from_glib_full(error))
184            }
185        }
186    }
187
188    /// Gets the type of operation that the file chooser is performing.
189    ///
190    /// # Deprecated since 4.10
191    ///
192    /// Use [`FileDialog`][crate::FileDialog] instead
193    ///
194    /// # Returns
195    ///
196    /// the action that the file selector is performing
197    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
198    #[allow(deprecated)]
199    #[doc(alias = "gtk_file_chooser_get_action")]
200    #[doc(alias = "get_action")]
201    fn action(&self) -> FileChooserAction {
202        unsafe {
203            from_glib(ffi::gtk_file_chooser_get_action(
204                self.as_ref().to_glib_none().0,
205            ))
206        }
207    }
208
209    /// Gets the currently selected option in the 'choice' with the given ID.
210    ///
211    /// # Deprecated since 4.10
212    ///
213    /// Use [`FileDialog`][crate::FileDialog] instead
214    /// ## `id`
215    /// the ID of the choice to get
216    ///
217    /// # Returns
218    ///
219    /// the ID of the currently selected option
220    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
221    #[allow(deprecated)]
222    #[doc(alias = "gtk_file_chooser_get_choice")]
223    #[doc(alias = "get_choice")]
224    fn choice(&self, id: &str) -> Option<glib::GString> {
225        unsafe {
226            from_glib_none(ffi::gtk_file_chooser_get_choice(
227                self.as_ref().to_glib_none().0,
228                id.to_glib_none().0,
229            ))
230        }
231    }
232
233    /// Gets whether file chooser will offer to create new folders.
234    ///
235    /// # Deprecated since 4.10
236    ///
237    /// Use [`FileDialog`][crate::FileDialog] instead
238    ///
239    /// # Returns
240    ///
241    /// [`true`] if the Create Folder button should be displayed.
242    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
243    #[allow(deprecated)]
244    #[doc(alias = "gtk_file_chooser_get_create_folders")]
245    #[doc(alias = "get_create_folders")]
246    #[doc(alias = "create-folders")]
247    fn creates_folders(&self) -> bool {
248        unsafe {
249            from_glib(ffi::gtk_file_chooser_get_create_folders(
250                self.as_ref().to_glib_none().0,
251            ))
252        }
253    }
254
255    /// Gets the current folder of @self as `GFile`.
256    ///
257    /// # Deprecated since 4.10
258    ///
259    /// Use [`FileDialog`][crate::FileDialog] instead
260    ///
261    /// # Returns
262    ///
263    /// the `GFile` for the current folder.
264    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
265    #[allow(deprecated)]
266    #[doc(alias = "gtk_file_chooser_get_current_folder")]
267    #[doc(alias = "get_current_folder")]
268    fn current_folder(&self) -> Option<gio::File> {
269        unsafe {
270            from_glib_full(ffi::gtk_file_chooser_get_current_folder(
271                self.as_ref().to_glib_none().0,
272            ))
273        }
274    }
275
276    /// Gets the current name in the file selector, as entered by the user.
277    ///
278    /// This is meant to be used in save dialogs, to get the currently typed
279    /// filename when the file itself does not exist yet.
280    ///
281    /// # Deprecated since 4.10
282    ///
283    /// Use [`FileDialog`][crate::FileDialog] instead
284    ///
285    /// # Returns
286    ///
287    /// The raw text from the file chooser’s “Name” entry. Free with
288    ///   g_free(). Note that this string is not a full pathname or URI; it is
289    ///   whatever the contents of the entry are. Note also that this string is
290    ///   in UTF-8 encoding, which is not necessarily the system’s encoding for
291    ///   filenames.
292    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
293    #[allow(deprecated)]
294    #[doc(alias = "gtk_file_chooser_get_current_name")]
295    #[doc(alias = "get_current_name")]
296    fn current_name(&self) -> Option<glib::GString> {
297        unsafe {
298            from_glib_full(ffi::gtk_file_chooser_get_current_name(
299                self.as_ref().to_glib_none().0,
300            ))
301        }
302    }
303
304    /// Gets the `GFile` for the currently selected file in
305    /// the file selector.
306    ///
307    /// If multiple files are selected, one of the files will be
308    /// returned at random.
309    ///
310    /// If the file chooser is in folder mode, this function returns
311    /// the selected folder.
312    ///
313    /// # Deprecated since 4.10
314    ///
315    /// Use [`FileDialog`][crate::FileDialog] instead
316    ///
317    /// # Returns
318    ///
319    /// a selected `GFile`. You own the
320    ///   returned file; use g_object_unref() to release it.
321    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
322    #[allow(deprecated)]
323    #[doc(alias = "gtk_file_chooser_get_file")]
324    #[doc(alias = "get_file")]
325    fn file(&self) -> Option<gio::File> {
326        unsafe {
327            from_glib_full(ffi::gtk_file_chooser_get_file(
328                self.as_ref().to_glib_none().0,
329            ))
330        }
331    }
332
333    /// Lists all the selected files and subfolders in the current folder
334    /// of @self as `GFile`.
335    ///
336    /// # Deprecated since 4.10
337    ///
338    /// Use [`FileDialog`][crate::FileDialog] instead
339    ///
340    /// # Returns
341    ///
342    /// a list model containing a `GFile` for each
343    ///   selected file and subfolder in the current folder. Free the returned
344    ///   list with g_object_unref().
345    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
346    #[allow(deprecated)]
347    #[doc(alias = "gtk_file_chooser_get_files")]
348    #[doc(alias = "get_files")]
349    fn files(&self) -> gio::ListModel {
350        unsafe {
351            from_glib_full(ffi::gtk_file_chooser_get_files(
352                self.as_ref().to_glib_none().0,
353            ))
354        }
355    }
356
357    /// Gets the current filter.
358    ///
359    /// # Deprecated since 4.10
360    ///
361    /// Use [`FileDialog`][crate::FileDialog] instead
362    ///
363    /// # Returns
364    ///
365    /// the current filter
366    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
367    #[allow(deprecated)]
368    #[doc(alias = "gtk_file_chooser_get_filter")]
369    #[doc(alias = "get_filter")]
370    fn filter(&self) -> Option<FileFilter> {
371        unsafe {
372            from_glib_none(ffi::gtk_file_chooser_get_filter(
373                self.as_ref().to_glib_none().0,
374            ))
375        }
376    }
377
378    /// Gets the current set of user-selectable filters, as a list model.
379    ///
380    /// See [`add_filter()`][Self::add_filter()] and
381    /// [`remove_filter()`][Self::remove_filter()] for changing individual filters.
382    ///
383    /// You should not modify the returned list model. Future changes to
384    /// @self may or may not affect the returned model.
385    ///
386    /// # Deprecated since 4.10
387    ///
388    /// Use [`FileDialog`][crate::FileDialog] instead
389    ///
390    /// # Returns
391    ///
392    /// a `GListModel` containing the current set
393    ///   of user-selectable filters.
394    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
395    #[allow(deprecated)]
396    #[doc(alias = "gtk_file_chooser_get_filters")]
397    #[doc(alias = "get_filters")]
398    fn filters(&self) -> gio::ListModel {
399        unsafe {
400            from_glib_full(ffi::gtk_file_chooser_get_filters(
401                self.as_ref().to_glib_none().0,
402            ))
403        }
404    }
405
406    /// Gets whether multiple files can be selected in the file
407    /// chooser.
408    ///
409    /// # Deprecated since 4.10
410    ///
411    /// Use [`FileDialog`][crate::FileDialog] instead
412    ///
413    /// # Returns
414    ///
415    /// [`true`] if multiple files can be selected.
416    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
417    #[allow(deprecated)]
418    #[doc(alias = "gtk_file_chooser_get_select_multiple")]
419    #[doc(alias = "get_select_multiple")]
420    #[doc(alias = "select-multiple")]
421    fn selects_multiple(&self) -> bool {
422        unsafe {
423            from_glib(ffi::gtk_file_chooser_get_select_multiple(
424                self.as_ref().to_glib_none().0,
425            ))
426        }
427    }
428
429    /// Queries the list of shortcut folders in the file chooser.
430    ///
431    /// You should not modify the returned list model. Future changes to
432    /// @self may or may not affect the returned model.
433    ///
434    /// # Deprecated since 4.10
435    ///
436    /// Use [`FileDialog`][crate::FileDialog] instead
437    ///
438    /// # Returns
439    ///
440    /// A list model of `GFile`s
441    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
442    #[allow(deprecated)]
443    #[doc(alias = "gtk_file_chooser_get_shortcut_folders")]
444    #[doc(alias = "get_shortcut_folders")]
445    #[doc(alias = "shortcut-folders")]
446    fn shortcut_folders(&self) -> gio::ListModel {
447        unsafe {
448            from_glib_full(ffi::gtk_file_chooser_get_shortcut_folders(
449                self.as_ref().to_glib_none().0,
450            ))
451        }
452    }
453
454    /// Removes a 'choice' that has been added with gtk_file_chooser_add_choice().
455    ///
456    /// # Deprecated since 4.10
457    ///
458    /// Use [`FileDialog`][crate::FileDialog] instead
459    /// ## `id`
460    /// the ID of the choice to remove
461    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
462    #[allow(deprecated)]
463    #[doc(alias = "gtk_file_chooser_remove_choice")]
464    fn remove_choice(&self, id: &str) {
465        unsafe {
466            ffi::gtk_file_chooser_remove_choice(
467                self.as_ref().to_glib_none().0,
468                id.to_glib_none().0,
469            );
470        }
471    }
472
473    /// Removes @filter from the list of filters that the user can select between.
474    ///
475    /// # Deprecated since 4.10
476    ///
477    /// Use [`FileDialog`][crate::FileDialog] instead
478    /// ## `filter`
479    /// a [`FileFilter`][crate::FileFilter]
480    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
481    #[allow(deprecated)]
482    #[doc(alias = "gtk_file_chooser_remove_filter")]
483    fn remove_filter(&self, filter: &FileFilter) {
484        unsafe {
485            ffi::gtk_file_chooser_remove_filter(
486                self.as_ref().to_glib_none().0,
487                filter.to_glib_none().0,
488            );
489        }
490    }
491
492    /// Removes a folder from the shortcut folders in a file chooser.
493    ///
494    /// # Deprecated since 4.10
495    ///
496    /// Use [`FileDialog`][crate::FileDialog] instead
497    /// ## `folder`
498    /// a `GFile` for the folder to remove
499    ///
500    /// # Returns
501    ///
502    /// [`true`] if the folder could be removed successfully,
503    ///   [`false`] otherwise.
504    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
505    #[allow(deprecated)]
506    #[doc(alias = "gtk_file_chooser_remove_shortcut_folder")]
507    fn remove_shortcut_folder(&self, folder: &impl IsA<gio::File>) -> Result<(), glib::Error> {
508        unsafe {
509            let mut error = std::ptr::null_mut();
510            let is_ok = ffi::gtk_file_chooser_remove_shortcut_folder(
511                self.as_ref().to_glib_none().0,
512                folder.as_ref().to_glib_none().0,
513                &mut error,
514            );
515            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
516            if error.is_null() {
517                Ok(())
518            } else {
519                Err(from_glib_full(error))
520            }
521        }
522    }
523
524    /// Sets the type of operation that the chooser is performing.
525    ///
526    /// The user interface is adapted to suit the selected action.
527    ///
528    /// For example, an option to create a new folder might be shown
529    /// if the action is [`FileChooserAction::Save`][crate::FileChooserAction::Save] but not if the
530    /// action is [`FileChooserAction::Open`][crate::FileChooserAction::Open].
531    ///
532    /// # Deprecated since 4.10
533    ///
534    /// Use [`FileDialog`][crate::FileDialog] instead
535    /// ## `action`
536    /// the action that the file selector is performing
537    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
538    #[allow(deprecated)]
539    #[doc(alias = "gtk_file_chooser_set_action")]
540    #[doc(alias = "action")]
541    fn set_action(&self, action: FileChooserAction) {
542        unsafe {
543            ffi::gtk_file_chooser_set_action(self.as_ref().to_glib_none().0, action.into_glib());
544        }
545    }
546
547    /// Selects an option in a 'choice' that has been added with
548    /// gtk_file_chooser_add_choice().
549    ///
550    /// For a boolean choice, the possible options are "true" and "false".
551    ///
552    /// # Deprecated since 4.10
553    ///
554    /// Use [`FileDialog`][crate::FileDialog] instead
555    /// ## `id`
556    /// the ID of the choice to set
557    /// ## `option`
558    /// the ID of the option to select
559    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
560    #[allow(deprecated)]
561    #[doc(alias = "gtk_file_chooser_set_choice")]
562    fn set_choice(&self, id: &str, option: &str) {
563        unsafe {
564            ffi::gtk_file_chooser_set_choice(
565                self.as_ref().to_glib_none().0,
566                id.to_glib_none().0,
567                option.to_glib_none().0,
568            );
569        }
570    }
571
572    /// Sets whether file chooser will offer to create new folders.
573    ///
574    /// This is only relevant if the action is not set to be
575    /// [`FileChooserAction::Open`][crate::FileChooserAction::Open].
576    ///
577    /// # Deprecated since 4.10
578    ///
579    /// Use [`FileDialog`][crate::FileDialog] instead
580    /// ## `create_folders`
581    /// [`true`] if the Create Folder button should be displayed
582    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
583    #[allow(deprecated)]
584    #[doc(alias = "gtk_file_chooser_set_create_folders")]
585    #[doc(alias = "create-folders")]
586    fn set_create_folders(&self, create_folders: bool) {
587        unsafe {
588            ffi::gtk_file_chooser_set_create_folders(
589                self.as_ref().to_glib_none().0,
590                create_folders.into_glib(),
591            );
592        }
593    }
594
595    /// Sets the current name in the file selector, as if entered
596    /// by the user.
597    ///
598    /// Note that the name passed in here is a UTF-8 string rather
599    /// than a filename. This function is meant for such uses as a
600    /// suggested name in a “Save As...” dialog.  You can pass
601    /// “Untitled.doc” or a similarly suitable suggestion for the @name.
602    ///
603    /// If you want to preselect a particular existing file, you should
604    /// use [`set_file()`][Self::set_file()] instead.
605    ///
606    /// Please see the documentation for those functions for an example
607    /// of using [`set_current_name()`][Self::set_current_name()] as well.
608    ///
609    /// # Deprecated since 4.10
610    ///
611    /// Use [`FileDialog`][crate::FileDialog] instead
612    /// ## `name`
613    /// the filename to use, as a UTF-8 string
614    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
615    #[allow(deprecated)]
616    #[doc(alias = "gtk_file_chooser_set_current_name")]
617    fn set_current_name(&self, name: &str) {
618        unsafe {
619            ffi::gtk_file_chooser_set_current_name(
620                self.as_ref().to_glib_none().0,
621                name.to_glib_none().0,
622            );
623        }
624    }
625
626    /// Sets @file as the current filename for the file chooser.
627    ///
628    /// This includes changing to the file’s parent folder and actually selecting
629    /// the file in list. If the @self is in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode,
630    /// the file’s base name will also appear in the dialog’s file name entry.
631    ///
632    /// If the file name isn’t in the current folder of @self, then the current
633    /// folder of @self will be changed to the folder containing @file.
634    ///
635    /// Note that the file must exist, or nothing will be done except
636    /// for the directory change.
637    ///
638    /// If you are implementing a save dialog, you should use this function if
639    /// you already have a file name to which the user may save; for example,
640    /// when the user opens an existing file and then does “Save As…”. If you
641    /// don’t have a file name already — for example, if the user just created
642    /// a new file and is saving it for the first time, do not call this function.
643    ///
644    /// Instead, use something similar to this:
645    ///
646    /// **⚠️ The following code is in c ⚠️**
647    ///
648    /// ```c
649    /// static void
650    /// prepare_file_chooser (GtkFileChooser *chooser,
651    ///                       GFile          *existing_file)
652    /// {
653    ///   gboolean document_is_new = (existing_file == NULL);
654    ///
655    ///   if (document_is_new)
656    ///     {
657    ///       GFile *default_file_for_saving = g_file_new_for_path ("./out.txt");
658    ///       // the user just created a new document
659    ///       gtk_file_chooser_set_current_folder (chooser, default_file_for_saving, NULL);
660    ///       gtk_file_chooser_set_current_name (chooser, "Untitled document");
661    ///       g_object_unref (default_file_for_saving);
662    ///     }
663    ///   else
664    ///     {
665    ///       // the user edited an existing document
666    ///       gtk_file_chooser_set_file (chooser, existing_file, NULL);
667    ///     }
668    /// }
669    /// ```
670    ///
671    /// # Deprecated since 4.10
672    ///
673    /// Use [`FileDialog`][crate::FileDialog] instead
674    /// ## `file`
675    /// the `GFile` to set as current
676    ///
677    /// # Returns
678    ///
679    /// Not useful
680    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
681    #[allow(deprecated)]
682    #[doc(alias = "gtk_file_chooser_set_file")]
683    fn set_file(&self, file: &impl IsA<gio::File>) -> Result<(), glib::Error> {
684        unsafe {
685            let mut error = std::ptr::null_mut();
686            let is_ok = ffi::gtk_file_chooser_set_file(
687                self.as_ref().to_glib_none().0,
688                file.as_ref().to_glib_none().0,
689                &mut error,
690            );
691            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
692            if error.is_null() {
693                Ok(())
694            } else {
695                Err(from_glib_full(error))
696            }
697        }
698    }
699
700    /// Sets the current filter.
701    ///
702    /// Only the files that pass the filter will be displayed.
703    /// If the user-selectable list of filters is non-empty, then
704    /// the filter should be one of the filters in that list.
705    ///
706    /// Setting the current filter when the list of filters is
707    /// empty is useful if you want to restrict the displayed
708    /// set of files without letting the user change it.
709    ///
710    /// # Deprecated since 4.10
711    ///
712    /// Use [`FileDialog`][crate::FileDialog] instead
713    /// ## `filter`
714    /// a [`FileFilter`][crate::FileFilter]
715    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
716    #[allow(deprecated)]
717    #[doc(alias = "gtk_file_chooser_set_filter")]
718    #[doc(alias = "filter")]
719    fn set_filter(&self, filter: &FileFilter) {
720        unsafe {
721            ffi::gtk_file_chooser_set_filter(
722                self.as_ref().to_glib_none().0,
723                filter.to_glib_none().0,
724            );
725        }
726    }
727
728    /// Sets whether multiple files can be selected in the file chooser.
729    ///
730    /// This is only relevant if the action is set to be
731    /// [`FileChooserAction::Open`][crate::FileChooserAction::Open] or
732    /// [`FileChooserAction::SelectFolder`][crate::FileChooserAction::SelectFolder].
733    ///
734    /// # Deprecated since 4.10
735    ///
736    /// Use [`FileDialog`][crate::FileDialog] instead
737    /// ## `select_multiple`
738    /// [`true`] if multiple files can be selected.
739    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
740    #[allow(deprecated)]
741    #[doc(alias = "gtk_file_chooser_set_select_multiple")]
742    #[doc(alias = "select-multiple")]
743    fn set_select_multiple(&self, select_multiple: bool) {
744        unsafe {
745            ffi::gtk_file_chooser_set_select_multiple(
746                self.as_ref().to_glib_none().0,
747                select_multiple.into_glib(),
748            );
749        }
750    }
751
752    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
753    #[doc(alias = "action")]
754    fn connect_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
755        unsafe extern "C" fn notify_action_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
756            this: *mut ffi::GtkFileChooser,
757            _param_spec: glib::ffi::gpointer,
758            f: glib::ffi::gpointer,
759        ) {
760            let f: &F = &*(f as *const F);
761            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
762        }
763        unsafe {
764            let f: Box_<F> = Box_::new(f);
765            connect_raw(
766                self.as_ptr() as *mut _,
767                b"notify::action\0".as_ptr() as *const _,
768                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
769                    notify_action_trampoline::<Self, F> as *const (),
770                )),
771                Box_::into_raw(f),
772            )
773        }
774    }
775
776    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
777    #[doc(alias = "create-folders")]
778    fn connect_create_folders_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
779        unsafe extern "C" fn notify_create_folders_trampoline<
780            P: IsA<FileChooser>,
781            F: Fn(&P) + 'static,
782        >(
783            this: *mut ffi::GtkFileChooser,
784            _param_spec: glib::ffi::gpointer,
785            f: glib::ffi::gpointer,
786        ) {
787            let f: &F = &*(f as *const F);
788            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
789        }
790        unsafe {
791            let f: Box_<F> = Box_::new(f);
792            connect_raw(
793                self.as_ptr() as *mut _,
794                b"notify::create-folders\0".as_ptr() as *const _,
795                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
796                    notify_create_folders_trampoline::<Self, F> as *const (),
797                )),
798                Box_::into_raw(f),
799            )
800        }
801    }
802
803    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
804    #[doc(alias = "filter")]
805    fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
806        unsafe extern "C" fn notify_filter_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
807            this: *mut ffi::GtkFileChooser,
808            _param_spec: glib::ffi::gpointer,
809            f: glib::ffi::gpointer,
810        ) {
811            let f: &F = &*(f as *const F);
812            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
813        }
814        unsafe {
815            let f: Box_<F> = Box_::new(f);
816            connect_raw(
817                self.as_ptr() as *mut _,
818                b"notify::filter\0".as_ptr() as *const _,
819                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
820                    notify_filter_trampoline::<Self, F> as *const (),
821                )),
822                Box_::into_raw(f),
823            )
824        }
825    }
826
827    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
828    #[doc(alias = "filters")]
829    fn connect_filters_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
830        unsafe extern "C" fn notify_filters_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
831            this: *mut ffi::GtkFileChooser,
832            _param_spec: glib::ffi::gpointer,
833            f: glib::ffi::gpointer,
834        ) {
835            let f: &F = &*(f as *const F);
836            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
837        }
838        unsafe {
839            let f: Box_<F> = Box_::new(f);
840            connect_raw(
841                self.as_ptr() as *mut _,
842                b"notify::filters\0".as_ptr() as *const _,
843                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
844                    notify_filters_trampoline::<Self, F> as *const (),
845                )),
846                Box_::into_raw(f),
847            )
848        }
849    }
850
851    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
852    #[doc(alias = "select-multiple")]
853    fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
854        unsafe extern "C" fn notify_select_multiple_trampoline<
855            P: IsA<FileChooser>,
856            F: Fn(&P) + 'static,
857        >(
858            this: *mut ffi::GtkFileChooser,
859            _param_spec: glib::ffi::gpointer,
860            f: glib::ffi::gpointer,
861        ) {
862            let f: &F = &*(f as *const F);
863            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
864        }
865        unsafe {
866            let f: Box_<F> = Box_::new(f);
867            connect_raw(
868                self.as_ptr() as *mut _,
869                b"notify::select-multiple\0".as_ptr() as *const _,
870                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
871                    notify_select_multiple_trampoline::<Self, F> as *const (),
872                )),
873                Box_::into_raw(f),
874            )
875        }
876    }
877
878    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
879    #[doc(alias = "shortcut-folders")]
880    fn connect_shortcut_folders_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
881        unsafe extern "C" fn notify_shortcut_folders_trampoline<
882            P: IsA<FileChooser>,
883            F: Fn(&P) + 'static,
884        >(
885            this: *mut ffi::GtkFileChooser,
886            _param_spec: glib::ffi::gpointer,
887            f: glib::ffi::gpointer,
888        ) {
889            let f: &F = &*(f as *const F);
890            f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
891        }
892        unsafe {
893            let f: Box_<F> = Box_::new(f);
894            connect_raw(
895                self.as_ptr() as *mut _,
896                b"notify::shortcut-folders\0".as_ptr() as *const _,
897                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
898                    notify_shortcut_folders_trampoline::<Self, F> as *const (),
899                )),
900                Box_::into_raw(f),
901            )
902        }
903    }
904}
905
906impl<O: IsA<FileChooser>> FileChooserExt for O {}