Skip to main content

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 crate::{FileChooserAction, FileChooserConfirmation, FileFilter, Widget, ffi};
6use glib::{
7    object::ObjectType as _,
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    /// [`FileChooser`][crate::FileChooser] is an interface that can be implemented by file
16    /// selection widgets. In GTK+, the main objects that implement this
17    /// interface are [`FileChooserWidget`][crate::FileChooserWidget], [`FileChooserDialog`][crate::FileChooserDialog], and
18    /// [`FileChooserButton`][crate::FileChooserButton]. You do not need to write an object that
19    /// implements the [`FileChooser`][crate::FileChooser] interface unless you are trying to
20    /// adapt an existing file selector to expose a standard programming
21    /// interface.
22    ///
23    /// [`FileChooser`][crate::FileChooser] allows for shortcuts to various places in the filesystem.
24    /// In the default implementation these are displayed in the left pane. It
25    /// may be a bit confusing at first that these shortcuts come from various
26    /// sources and in various flavours, so lets explain the terminology here:
27    ///
28    /// - Bookmarks: are created by the user, by dragging folders from the
29    ///  right pane to the left pane, or by using the “Add”. Bookmarks
30    ///  can be renamed and deleted by the user.
31    ///
32    /// - Shortcuts: can be provided by the application. For example, a Paint
33    ///  program may want to add a shortcut for a Clipart folder. Shortcuts
34    ///  cannot be modified by the user.
35    ///
36    /// - Volumes: are provided by the underlying filesystem abstraction. They are
37    ///  the “roots” of the filesystem.
38    ///
39    /// # File Names and Encodings
40    ///
41    /// When the user is finished selecting files in a
42    /// [`FileChooser`][crate::FileChooser], your program can get the selected names
43    /// either as filenames or as URIs. For URIs, the normal escaping
44    /// rules are applied if the URI contains non-ASCII characters.
45    /// However, filenames are always returned in
46    /// the character set specified by the
47    /// `G_FILENAME_ENCODING` environment variable.
48    /// Please see the GLib documentation for more details about this
49    /// variable.
50    ///
51    /// This means that while you can pass the result of
52    /// [`FileChooserExt::filename()`][crate::prelude::FileChooserExt::filename()] to `g_open()` or `g_fopen()`,
53    /// you may not be able to directly set it as the text of a
54    /// [`Label`][crate::Label] widget unless you convert it first to UTF-8,
55    /// which all GTK+ widgets expect. You should use `g_filename_to_utf8()`
56    /// to convert filenames into strings that can be passed to GTK+
57    /// widgets.
58    ///
59    /// # Adding a Preview Widget
60    ///
61    /// You can add a custom preview widget to a file chooser and then
62    /// get notification about when the preview needs to be updated.
63    /// To install a preview widget, use
64    /// [`FileChooserExt::set_preview_widget()`][crate::prelude::FileChooserExt::set_preview_widget()]. Then, connect to the
65    /// [`update-preview`][struct@crate::FileChooser#update-preview] signal to get notified when
66    /// you need to update the contents of the preview.
67    ///
68    /// Your callback should use
69    /// [`FileChooserExt::preview_filename()`][crate::prelude::FileChooserExt::preview_filename()] to see what needs
70    /// previewing. Once you have generated the preview for the
71    /// corresponding file, you must call
72    /// [`FileChooserExt::set_preview_widget_active()`][crate::prelude::FileChooserExt::set_preview_widget_active()] with a boolean
73    /// flag that indicates whether your callback could successfully
74    /// generate a preview.
75    ///
76    /// ## Example: Using a Preview Widget ## {`gtkfilechooser`-preview}
77    ///
78    ///
79    /// **⚠️ The following code is in C ⚠️**
80    ///
81    /// ```C
82    /// {
83    ///   GtkImage *preview;
84    ///
85    ///   ...
86    ///
87    ///   preview = gtk_image_new ();
88    ///
89    ///   gtk_file_chooser_set_preview_widget (my_file_chooser, preview);
90    ///   g_signal_connect (my_file_chooser, "update-preview",
91    ///             G_CALLBACK (update_preview_cb), preview);
92    /// }
93    ///
94    /// static void
95    /// update_preview_cb (GtkFileChooser *file_chooser, gpointer data)
96    /// {
97    ///   GtkWidget *preview;
98    ///   char *filename;
99    ///   GdkPixbuf *pixbuf;
100    ///   gboolean have_preview;
101    ///
102    ///   preview = GTK_WIDGET (data);
103    ///   filename = gtk_file_chooser_get_preview_filename (file_chooser);
104    ///
105    ///   pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 128, 128, NULL);
106    ///   have_preview = (pixbuf != NULL);
107    ///   g_free (filename);
108    ///
109    ///   gtk_image_set_from_pixbuf (GTK_IMAGE (preview), pixbuf);
110    ///   if (pixbuf)
111    ///     g_object_unref (pixbuf);
112    ///
113    ///   gtk_file_chooser_set_preview_widget_active (file_chooser, have_preview);
114    /// }
115    /// ```
116    ///
117    /// # Adding Extra Widgets
118    ///
119    /// You can add extra widgets to a file chooser to provide options
120    /// that are not present in the default design. For example, you
121    /// can add a toggle button to give the user the option to open a
122    /// file in read-only mode. You can use
123    /// [`FileChooserExt::set_extra_widget()`][crate::prelude::FileChooserExt::set_extra_widget()] to insert additional
124    /// widgets in a file chooser.
125    ///
126    /// An example for adding extra widgets:
127    ///
128    ///
129    /// **⚠️ The following code is in C ⚠️**
130    ///
131    /// ```C
132    ///
133    ///   GtkWidget *toggle;
134    ///
135    ///   ...
136    ///
137    ///   toggle = gtk_check_button_new_with_label ("Open file read-only");
138    ///   gtk_widget_show (toggle);
139    ///   gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
140    /// }
141    /// ```
142    ///
143    /// If you want to set more than one extra widget in the file
144    /// chooser, you can a container such as a [`Box`][crate::Box] or a [`Grid`][crate::Grid]
145    /// and include your widgets in it. Then, set the container as
146    /// the whole extra widget.
147    ///
148    /// ## Properties
149    ///
150    ///
151    /// #### `action`
152    ///  Readable | Writable
153    ///
154    ///
155    /// #### `create-folders`
156    ///  Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
157    /// will offer the user to create new folders.
158    ///
159    /// Readable | Writable
160    ///
161    ///
162    /// #### `do-overwrite-confirmation`
163    ///  Whether a file chooser in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode
164    /// will present an overwrite confirmation dialog if the user
165    /// selects a file name that already exists.
166    ///
167    /// Readable | Writable
168    ///
169    ///
170    /// #### `extra-widget`
171    ///  Readable | Writable
172    ///
173    ///
174    /// #### `filter`
175    ///  Readable | Writable
176    ///
177    ///
178    /// #### `local-only`
179    ///  Readable | Writable
180    ///
181    ///
182    /// #### `preview-widget`
183    ///  Readable | Writable
184    ///
185    ///
186    /// #### `preview-widget-active`
187    ///  Readable | Writable
188    ///
189    ///
190    /// #### `select-multiple`
191    ///  Readable | Writable
192    ///
193    ///
194    /// #### `show-hidden`
195    ///  Readable | Writable
196    ///
197    ///
198    /// #### `use-preview-label`
199    ///  Readable | Writable
200    ///
201    /// ## Signals
202    ///
203    ///
204    /// #### `confirm-overwrite`
205    ///  This signal gets emitted whenever it is appropriate to present a
206    /// confirmation dialog when the user has selected a file name that
207    /// already exists. The signal only gets emitted when the file
208    /// chooser is in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode.
209    ///
210    /// Most applications just need to turn on the
211    /// [`do-overwrite-confirmation`][struct@crate::FileChooser#do-overwrite-confirmation] property (or call the
212    /// [`FileChooserExt::set_do_overwrite_confirmation()`][crate::prelude::FileChooserExt::set_do_overwrite_confirmation()] function), and
213    /// they will automatically get a stock confirmation dialog.
214    /// Applications which need to customize this behavior should do
215    /// that, and also connect to the [`confirm-overwrite`][struct@crate::FileChooser#confirm-overwrite]
216    /// signal.
217    ///
218    /// A signal handler for this signal must return a
219    /// [`FileChooserConfirmation`][crate::FileChooserConfirmation] value, which indicates the action to
220    /// take. If the handler determines that the user wants to select a
221    /// different filename, it should return
222    /// [`FileChooserConfirmation::SelectAgain`][crate::FileChooserConfirmation::SelectAgain]. If it determines
223    /// that the user is satisfied with his choice of file name, it
224    /// should return [`FileChooserConfirmation::AcceptFilename`][crate::FileChooserConfirmation::AcceptFilename].
225    /// On the other hand, if it determines that the stock confirmation
226    /// dialog should be used, it should return
227    /// [`FileChooserConfirmation::Confirm`][crate::FileChooserConfirmation::Confirm]. The following example
228    /// illustrates this.
229    ///
230    /// ## Custom confirmation ## {`gtkfilechooser`-confirmation}
231    ///
232    ///
233    ///
234    /// **⚠️ The following code is in C ⚠️**
235    ///
236    /// ```C
237    /// static GtkFileChooserConfirmation
238    /// confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
239    /// {
240    ///   char *uri;
241    ///
242    ///   uri = gtk_file_chooser_get_uri (chooser);
243    ///
244    ///   if (is_uri_read_only (uri))
245    ///     {
246    ///       if (user_wants_to_replace_read_only_file (uri))
247    ///         return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
248    ///       else
249    ///         return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
250    ///     } else
251    ///       return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
252    /// }
253    ///
254    /// ...
255    ///
256    /// chooser = gtk_file_chooser_dialog_new (...);
257    ///
258    /// gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
259    /// g_signal_connect (chooser, "confirm-overwrite",
260    ///                   G_CALLBACK (confirm_overwrite_callback), NULL);
261    ///
262    /// if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
263    ///         save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
264    ///
265    /// gtk_widget_destroy (chooser);
266    /// ```
267    ///
268    ///
269    ///
270    ///
271    /// #### `current-folder-changed`
272    ///  This signal is emitted when the current folder in a [`FileChooser`][crate::FileChooser]
273    /// changes. This can happen due to the user performing some action that
274    /// changes folders, such as selecting a bookmark or visiting a folder on the
275    /// file list. It can also happen as a result of calling a function to
276    /// explicitly change the current folder in a file chooser.
277    ///
278    /// Normally you do not need to connect to this signal, unless you need to keep
279    /// track of which folder a file chooser is showing.
280    ///
281    /// See also: [`FileChooserExt::set_current_folder()`][crate::prelude::FileChooserExt::set_current_folder()],
282    /// [`FileChooserExt::current_folder()`][crate::prelude::FileChooserExt::current_folder()],
283    /// [`FileChooserExt::set_current_folder_uri()`][crate::prelude::FileChooserExt::set_current_folder_uri()],
284    /// [`FileChooserExt::current_folder_uri()`][crate::prelude::FileChooserExt::current_folder_uri()].
285    ///
286    ///
287    ///
288    ///
289    /// #### `file-activated`
290    ///  This signal is emitted when the user "activates" a file in the file
291    /// chooser. This can happen by double-clicking on a file in the file list, or
292    /// by pressing `Enter`.
293    ///
294    /// Normally you do not need to connect to this signal. It is used internally
295    /// by [`FileChooserDialog`][crate::FileChooserDialog] to know when to activate the default button in the
296    /// dialog.
297    ///
298    /// See also: [`FileChooserExt::filename()`][crate::prelude::FileChooserExt::filename()],
299    /// [`FileChooserExt::filenames()`][crate::prelude::FileChooserExt::filenames()], [`FileChooserExt::uri()`][crate::prelude::FileChooserExt::uri()],
300    /// [`FileChooserExt::uris()`][crate::prelude::FileChooserExt::uris()].
301    ///
302    ///
303    ///
304    ///
305    /// #### `selection-changed`
306    ///  This signal is emitted when there is a change in the set of selected files
307    /// in a [`FileChooser`][crate::FileChooser]. This can happen when the user modifies the selection
308    /// with the mouse or the keyboard, or when explicitly calling functions to
309    /// change the selection.
310    ///
311    /// Normally you do not need to connect to this signal, as it is easier to wait
312    /// for the file chooser to finish running, and then to get the list of
313    /// selected files using the functions mentioned below.
314    ///
315    /// See also: [`FileChooserExt::select_filename()`][crate::prelude::FileChooserExt::select_filename()],
316    /// [`FileChooserExt::unselect_filename()`][crate::prelude::FileChooserExt::unselect_filename()], [`FileChooserExt::filename()`][crate::prelude::FileChooserExt::filename()],
317    /// [`FileChooserExt::filenames()`][crate::prelude::FileChooserExt::filenames()], [`FileChooserExt::select_uri()`][crate::prelude::FileChooserExt::select_uri()],
318    /// [`FileChooserExt::unselect_uri()`][crate::prelude::FileChooserExt::unselect_uri()], [`FileChooserExt::uri()`][crate::prelude::FileChooserExt::uri()],
319    /// [`FileChooserExt::uris()`][crate::prelude::FileChooserExt::uris()].
320    ///
321    ///
322    ///
323    ///
324    /// #### `update-preview`
325    ///  This signal is emitted when the preview in a file chooser should be
326    /// regenerated. For example, this can happen when the currently selected file
327    /// changes. You should use this signal if you want your file chooser to have
328    /// a preview widget.
329    ///
330    /// Once you have installed a preview widget with
331    /// [`FileChooserExt::set_preview_widget()`][crate::prelude::FileChooserExt::set_preview_widget()], you should update it when this
332    /// signal is emitted. You can use the functions
333    /// [`FileChooserExt::preview_filename()`][crate::prelude::FileChooserExt::preview_filename()] or
334    /// [`FileChooserExt::preview_uri()`][crate::prelude::FileChooserExt::preview_uri()] to get the name of the file to preview.
335    /// Your widget may not be able to preview all kinds of files; your callback
336    /// must call [`FileChooserExt::set_preview_widget_active()`][crate::prelude::FileChooserExt::set_preview_widget_active()] to inform the file
337    /// chooser about whether the preview was generated successfully or not.
338    ///
339    /// Please see the example code in
340    /// [Using a Preview Widget][gtkfilechooser-preview].
341    ///
342    /// See also: [`FileChooserExt::set_preview_widget()`][crate::prelude::FileChooserExt::set_preview_widget()],
343    /// [`FileChooserExt::set_preview_widget_active()`][crate::prelude::FileChooserExt::set_preview_widget_active()],
344    /// [`FileChooserExt::set_use_preview_label()`][crate::prelude::FileChooserExt::set_use_preview_label()],
345    /// [`FileChooserExt::preview_filename()`][crate::prelude::FileChooserExt::preview_filename()],
346    /// [`FileChooserExt::preview_uri()`][crate::prelude::FileChooserExt::preview_uri()].
347    ///
348    ///
349    ///
350    /// # Implements
351    ///
352    /// [`FileChooserExt`][trait@crate::prelude::FileChooserExt], [`FileChooserExtManual`][trait@crate::prelude::FileChooserExtManual]
353    #[doc(alias = "GtkFileChooser")]
354    pub struct FileChooser(Interface<ffi::GtkFileChooser>);
355
356    match fn {
357        type_ => || ffi::gtk_file_chooser_get_type(),
358    }
359}
360
361impl FileChooser {
362    pub const NONE: Option<&'static FileChooser> = None;
363}
364
365/// Trait containing all [`struct@FileChooser`] methods.
366///
367/// # Implementors
368///
369/// [`FileChooserButton`][struct@crate::FileChooserButton], [`FileChooserDialog`][struct@crate::FileChooserDialog], [`FileChooserNative`][struct@crate::FileChooserNative], [`FileChooserWidget`][struct@crate::FileChooserWidget], [`FileChooser`][struct@crate::FileChooser]
370pub trait FileChooserExt: IsA<FileChooser> + 'static {
371    /// Adds `filter` to the list of filters that the user can select between.
372    /// When a filter is selected, only files that are passed by that
373    /// filter are displayed.
374    ///
375    /// Note that the `self` takes ownership of the filter, so you have to
376    /// ref and sink it if you want to keep a reference.
377    /// ## `filter`
378    /// a [`FileFilter`][crate::FileFilter]
379    #[doc(alias = "gtk_file_chooser_add_filter")]
380    fn add_filter(&self, filter: FileFilter) {
381        unsafe {
382            ffi::gtk_file_chooser_add_filter(
383                self.as_ref().to_glib_none().0,
384                filter.into_glib_ptr(),
385            );
386        }
387    }
388
389    /// Adds a folder to be displayed with the shortcut folders in a file chooser.
390    /// Note that shortcut folders do not get saved, as they are provided by the
391    /// application. For example, you can use this to add a
392    /// “/usr/share/mydrawprogram/Clipart” folder to the volume list.
393    /// ## `folder`
394    /// filename of the folder to add
395    ///
396    /// # Returns
397    ///
398    /// [`true`] if the folder could be added successfully, [`false`]
399    /// otherwise. In the latter case, the `error` will be set as appropriate.
400    #[doc(alias = "gtk_file_chooser_add_shortcut_folder")]
401    fn add_shortcut_folder(&self, folder: impl AsRef<std::path::Path>) -> Result<(), glib::Error> {
402        unsafe {
403            let mut error = std::ptr::null_mut();
404            let is_ok = ffi::gtk_file_chooser_add_shortcut_folder(
405                self.as_ref().to_glib_none().0,
406                folder.as_ref().to_glib_none().0,
407                &mut error,
408            );
409            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
410            if error.is_null() {
411                Ok(())
412            } else {
413                Err(from_glib_full(error))
414            }
415        }
416    }
417
418    /// Adds a folder URI to be displayed with the shortcut folders in a file
419    /// chooser. Note that shortcut folders do not get saved, as they are provided
420    /// by the application. For example, you can use this to add a
421    /// “file:///usr/share/mydrawprogram/Clipart” folder to the volume list.
422    /// ## `uri`
423    /// URI of the folder to add
424    ///
425    /// # Returns
426    ///
427    /// [`true`] if the folder could be added successfully, [`false`]
428    /// otherwise. In the latter case, the `error` will be set as appropriate.
429    #[doc(alias = "gtk_file_chooser_add_shortcut_folder_uri")]
430    fn add_shortcut_folder_uri(&self, uri: &str) -> Result<(), glib::Error> {
431        unsafe {
432            let mut error = std::ptr::null_mut();
433            let is_ok = ffi::gtk_file_chooser_add_shortcut_folder_uri(
434                self.as_ref().to_glib_none().0,
435                uri.to_glib_none().0,
436                &mut error,
437            );
438            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
439            if error.is_null() {
440                Ok(())
441            } else {
442                Err(from_glib_full(error))
443            }
444        }
445    }
446
447    /// Gets the type of operation that the file chooser is performing; see
448    /// [`set_action()`][Self::set_action()].
449    ///
450    /// # Returns
451    ///
452    /// the action that the file selector is performing
453    #[doc(alias = "gtk_file_chooser_get_action")]
454    #[doc(alias = "get_action")]
455    fn action(&self) -> FileChooserAction {
456        unsafe {
457            from_glib(ffi::gtk_file_chooser_get_action(
458                self.as_ref().to_glib_none().0,
459            ))
460        }
461    }
462
463    /// Gets the currently selected option in the 'choice' with the given ID.
464    /// ## `id`
465    /// the ID of the choice to get
466    ///
467    /// # Returns
468    ///
469    /// the ID of the currenly selected option
470    #[doc(alias = "gtk_file_chooser_get_choice")]
471    #[doc(alias = "get_choice")]
472    fn choice(&self, id: &str) -> Option<glib::GString> {
473        unsafe {
474            from_glib_none(ffi::gtk_file_chooser_get_choice(
475                self.as_ref().to_glib_none().0,
476                id.to_glib_none().0,
477            ))
478        }
479    }
480
481    /// Gets whether file choser will offer to create new folders.
482    /// See [`set_create_folders()`][Self::set_create_folders()].
483    ///
484    /// # Returns
485    ///
486    /// [`true`] if the Create Folder button should be displayed.
487    #[doc(alias = "gtk_file_chooser_get_create_folders")]
488    #[doc(alias = "get_create_folders")]
489    #[doc(alias = "create-folders")]
490    fn creates_folders(&self) -> bool {
491        unsafe {
492            from_glib(ffi::gtk_file_chooser_get_create_folders(
493                self.as_ref().to_glib_none().0,
494            ))
495        }
496    }
497
498    /// Gets the current folder of `self` as a local filename.
499    /// See [`set_current_folder()`][Self::set_current_folder()].
500    ///
501    /// Note that this is the folder that the file chooser is currently displaying
502    /// (e.g. "/home/username/Documents"), which is not the same
503    /// as the currently-selected folder if the chooser is in
504    /// [`FileChooserAction::SelectFolder`][crate::FileChooserAction::SelectFolder] mode
505    /// (e.g. "/home/username/Documents/selected-folder/". To get the
506    /// currently-selected folder in that mode, use [`uri()`][Self::uri()] as the
507    /// usual way to get the selection.
508    ///
509    /// # Returns
510    ///
511    /// the full path of the current
512    /// folder, or [`None`] if the current path cannot be represented as a local
513    /// filename. Free with `g_free()`. This function will also return
514    /// [`None`] if the file chooser was unable to load the last folder that
515    /// was requested from it; for example, as would be for calling
516    /// [`set_current_folder()`][Self::set_current_folder()] on a nonexistent folder.
517    #[doc(alias = "gtk_file_chooser_get_current_folder")]
518    #[doc(alias = "get_current_folder")]
519    fn current_folder(&self) -> Option<std::path::PathBuf> {
520        unsafe {
521            from_glib_full(ffi::gtk_file_chooser_get_current_folder(
522                self.as_ref().to_glib_none().0,
523            ))
524        }
525    }
526
527    /// Gets the current folder of `self` as [`gio::File`][crate::gio::File].
528    /// See [`current_folder_uri()`][Self::current_folder_uri()].
529    ///
530    /// # Returns
531    ///
532    /// the [`gio::File`][crate::gio::File] for the current folder.
533    #[doc(alias = "gtk_file_chooser_get_current_folder_file")]
534    #[doc(alias = "get_current_folder_file")]
535    fn current_folder_file(&self) -> Option<gio::File> {
536        unsafe {
537            from_glib_full(ffi::gtk_file_chooser_get_current_folder_file(
538                self.as_ref().to_glib_none().0,
539            ))
540        }
541    }
542
543    /// Gets the current folder of `self` as an URI.
544    /// See [`set_current_folder_uri()`][Self::set_current_folder_uri()].
545    ///
546    /// Note that this is the folder that the file chooser is currently displaying
547    /// (e.g. "file:///home/username/Documents"), which is not the same
548    /// as the currently-selected folder if the chooser is in
549    /// [`FileChooserAction::SelectFolder`][crate::FileChooserAction::SelectFolder] mode
550    /// (e.g. "file:///home/username/Documents/selected-folder/". To get the
551    /// currently-selected folder in that mode, use [`uri()`][Self::uri()] as the
552    /// usual way to get the selection.
553    ///
554    /// # Returns
555    ///
556    /// the URI for the current folder.
557    /// Free with `g_free()`. This function will also return [`None`] if the file chooser
558    /// was unable to load the last folder that was requested from it; for example,
559    /// as would be for calling [`set_current_folder_uri()`][Self::set_current_folder_uri()] on a
560    /// nonexistent folder.
561    #[doc(alias = "gtk_file_chooser_get_current_folder_uri")]
562    #[doc(alias = "get_current_folder_uri")]
563    fn current_folder_uri(&self) -> Option<glib::GString> {
564        unsafe {
565            from_glib_full(ffi::gtk_file_chooser_get_current_folder_uri(
566                self.as_ref().to_glib_none().0,
567            ))
568        }
569    }
570
571    /// Gets the current name in the file selector, as entered by the user in the
572    /// text entry for “Name”.
573    ///
574    /// This is meant to be used in save dialogs, to get the currently typed filename
575    /// when the file itself does not exist yet. For example, an application that
576    /// adds a custom extra widget to the file chooser for “file format” may want to
577    /// change the extension of the typed filename based on the chosen format, say,
578    /// from “.jpg” to “.png”.
579    ///
580    /// # Returns
581    ///
582    /// The raw text from the file chooser’s “Name” entry. Free this with
583    /// `g_free()`. Note that this string is not a full pathname or URI; it is
584    /// whatever the contents of the entry are. Note also that this string is in
585    /// UTF-8 encoding, which is not necessarily the system’s encoding for filenames.
586    #[doc(alias = "gtk_file_chooser_get_current_name")]
587    #[doc(alias = "get_current_name")]
588    fn current_name(&self) -> Option<glib::GString> {
589        unsafe {
590            from_glib_full(ffi::gtk_file_chooser_get_current_name(
591                self.as_ref().to_glib_none().0,
592            ))
593        }
594    }
595
596    /// Queries whether a file chooser is set to confirm for overwriting when the user
597    /// types a file name that already exists.
598    ///
599    /// # Returns
600    ///
601    /// [`true`] if the file chooser will present a confirmation dialog;
602    /// [`false`] otherwise.
603    #[doc(alias = "gtk_file_chooser_get_do_overwrite_confirmation")]
604    #[doc(alias = "get_do_overwrite_confirmation")]
605    #[doc(alias = "do-overwrite-confirmation")]
606    fn does_overwrite_confirmation(&self) -> bool {
607        unsafe {
608            from_glib(ffi::gtk_file_chooser_get_do_overwrite_confirmation(
609                self.as_ref().to_glib_none().0,
610            ))
611        }
612    }
613
614    /// Gets the current extra widget; see
615    /// [`set_extra_widget()`][Self::set_extra_widget()].
616    ///
617    /// # Returns
618    ///
619    /// the current extra widget, or [`None`]
620    #[doc(alias = "gtk_file_chooser_get_extra_widget")]
621    #[doc(alias = "get_extra_widget")]
622    #[doc(alias = "extra-widget")]
623    fn extra_widget(&self) -> Option<Widget> {
624        unsafe {
625            from_glib_none(ffi::gtk_file_chooser_get_extra_widget(
626                self.as_ref().to_glib_none().0,
627            ))
628        }
629    }
630
631    /// Gets the [`gio::File`][crate::gio::File] for the currently selected file in
632    /// the file selector. If multiple files are selected,
633    /// one of the files will be returned at random.
634    ///
635    /// If the file chooser is in folder mode, this function returns the selected
636    /// folder.
637    ///
638    /// # Returns
639    ///
640    /// a selected [`gio::File`][crate::gio::File]. You own the returned file;
641    ///  use `g_object_unref()` to release it.
642    #[doc(alias = "gtk_file_chooser_get_file")]
643    #[doc(alias = "get_file")]
644    fn file(&self) -> Option<gio::File> {
645        unsafe {
646            from_glib_full(ffi::gtk_file_chooser_get_file(
647                self.as_ref().to_glib_none().0,
648            ))
649        }
650    }
651
652    /// Gets the filename for the currently selected file in
653    /// the file selector. The filename is returned as an absolute path. If
654    /// multiple files are selected, one of the filenames will be returned at
655    /// random.
656    ///
657    /// If the file chooser is in folder mode, this function returns the selected
658    /// folder.
659    ///
660    /// # Returns
661    ///
662    /// The currently selected filename,
663    ///  or [`None`] if no file is selected, or the selected file can't
664    ///  be represented with a local filename. Free with `g_free()`.
665    #[doc(alias = "gtk_file_chooser_get_filename")]
666    #[doc(alias = "get_filename")]
667    fn filename(&self) -> Option<std::path::PathBuf> {
668        unsafe {
669            from_glib_full(ffi::gtk_file_chooser_get_filename(
670                self.as_ref().to_glib_none().0,
671            ))
672        }
673    }
674
675    /// Lists all the selected files and subfolders in the current folder of
676    /// `self`. The returned names are full absolute paths. If files in the current
677    /// folder cannot be represented as local filenames they will be ignored. (See
678    /// [`uris()`][Self::uris()])
679    ///
680    /// # Returns
681    ///
682    /// a `GSList`
683    ///  containing the filenames of all selected files and subfolders in
684    ///  the current folder. Free the returned list with `g_slist_free()`,
685    ///  and the filenames with `g_free()`.
686    #[doc(alias = "gtk_file_chooser_get_filenames")]
687    #[doc(alias = "get_filenames")]
688    fn filenames(&self) -> Vec<std::path::PathBuf> {
689        unsafe {
690            FromGlibPtrContainer::from_glib_full(ffi::gtk_file_chooser_get_filenames(
691                self.as_ref().to_glib_none().0,
692            ))
693        }
694    }
695
696    /// Lists all the selected files and subfolders in the current folder of `self`
697    /// as [`gio::File`][crate::gio::File]. An internal function, see [`uris()`][Self::uris()].
698    ///
699    /// # Returns
700    ///
701    /// a `GSList`
702    ///  containing a [`gio::File`][crate::gio::File] for each selected file and subfolder in the
703    ///  current folder. Free the returned list with `g_slist_free()`, and
704    ///  the files with `g_object_unref()`.
705    #[doc(alias = "gtk_file_chooser_get_files")]
706    #[doc(alias = "get_files")]
707    fn files(&self) -> Vec<gio::File> {
708        unsafe {
709            FromGlibPtrContainer::from_glib_full(ffi::gtk_file_chooser_get_files(
710                self.as_ref().to_glib_none().0,
711            ))
712        }
713    }
714
715    /// Gets the current filter; see [`set_filter()`][Self::set_filter()].
716    ///
717    /// # Returns
718    ///
719    /// the current filter, or [`None`]
720    #[doc(alias = "gtk_file_chooser_get_filter")]
721    #[doc(alias = "get_filter")]
722    fn filter(&self) -> Option<FileFilter> {
723        unsafe {
724            from_glib_none(ffi::gtk_file_chooser_get_filter(
725                self.as_ref().to_glib_none().0,
726            ))
727        }
728    }
729
730    /// Gets whether only local files can be selected in the
731    /// file selector. See [`set_local_only()`][Self::set_local_only()]
732    ///
733    /// # Returns
734    ///
735    /// [`true`] if only local files can be selected.
736    #[doc(alias = "gtk_file_chooser_get_local_only")]
737    #[doc(alias = "get_local_only")]
738    #[doc(alias = "local-only")]
739    fn is_local_only(&self) -> bool {
740        unsafe {
741            from_glib(ffi::gtk_file_chooser_get_local_only(
742                self.as_ref().to_glib_none().0,
743            ))
744        }
745    }
746
747    /// Gets the [`gio::File`][crate::gio::File] that should be previewed in a custom preview
748    /// Internal function, see [`preview_uri()`][Self::preview_uri()].
749    ///
750    /// # Returns
751    ///
752    /// the [`gio::File`][crate::gio::File] for the file to preview,
753    ///  or [`None`] if no file is selected. Free with `g_object_unref()`.
754    #[doc(alias = "gtk_file_chooser_get_preview_file")]
755    #[doc(alias = "get_preview_file")]
756    fn preview_file(&self) -> Option<gio::File> {
757        unsafe {
758            from_glib_full(ffi::gtk_file_chooser_get_preview_file(
759                self.as_ref().to_glib_none().0,
760            ))
761        }
762    }
763
764    /// Gets the filename that should be previewed in a custom preview
765    /// widget. See [`set_preview_widget()`][Self::set_preview_widget()].
766    ///
767    /// # Returns
768    ///
769    /// the filename to preview, or [`None`] if
770    ///  no file is selected, or if the selected file cannot be represented
771    ///  as a local filename. Free with `g_free()`
772    #[doc(alias = "gtk_file_chooser_get_preview_filename")]
773    #[doc(alias = "get_preview_filename")]
774    fn preview_filename(&self) -> Option<std::path::PathBuf> {
775        unsafe {
776            from_glib_full(ffi::gtk_file_chooser_get_preview_filename(
777                self.as_ref().to_glib_none().0,
778            ))
779        }
780    }
781
782    /// Gets the URI that should be previewed in a custom preview
783    /// widget. See [`set_preview_widget()`][Self::set_preview_widget()].
784    ///
785    /// # Returns
786    ///
787    /// the URI for the file to preview,
788    ///  or [`None`] if no file is selected. Free with `g_free()`.
789    #[doc(alias = "gtk_file_chooser_get_preview_uri")]
790    #[doc(alias = "get_preview_uri")]
791    fn preview_uri(&self) -> Option<glib::GString> {
792        unsafe {
793            from_glib_full(ffi::gtk_file_chooser_get_preview_uri(
794                self.as_ref().to_glib_none().0,
795            ))
796        }
797    }
798
799    /// Gets the current preview widget; see
800    /// [`set_preview_widget()`][Self::set_preview_widget()].
801    ///
802    /// # Returns
803    ///
804    /// the current preview widget, or [`None`]
805    #[doc(alias = "gtk_file_chooser_get_preview_widget")]
806    #[doc(alias = "get_preview_widget")]
807    #[doc(alias = "preview-widget")]
808    fn preview_widget(&self) -> Option<Widget> {
809        unsafe {
810            from_glib_none(ffi::gtk_file_chooser_get_preview_widget(
811                self.as_ref().to_glib_none().0,
812            ))
813        }
814    }
815
816    /// Gets whether the preview widget set by [`set_preview_widget()`][Self::set_preview_widget()]
817    /// should be shown for the current filename. See
818    /// [`set_preview_widget_active()`][Self::set_preview_widget_active()].
819    ///
820    /// # Returns
821    ///
822    /// [`true`] if the preview widget is active for the current filename.
823    #[doc(alias = "gtk_file_chooser_get_preview_widget_active")]
824    #[doc(alias = "get_preview_widget_active")]
825    #[doc(alias = "preview-widget-active")]
826    fn is_preview_widget_active(&self) -> bool {
827        unsafe {
828            from_glib(ffi::gtk_file_chooser_get_preview_widget_active(
829                self.as_ref().to_glib_none().0,
830            ))
831        }
832    }
833
834    /// Gets whether multiple files can be selected in the file
835    /// selector. See [`set_select_multiple()`][Self::set_select_multiple()].
836    ///
837    /// # Returns
838    ///
839    /// [`true`] if multiple files can be selected.
840    #[doc(alias = "gtk_file_chooser_get_select_multiple")]
841    #[doc(alias = "get_select_multiple")]
842    #[doc(alias = "select-multiple")]
843    fn selects_multiple(&self) -> bool {
844        unsafe {
845            from_glib(ffi::gtk_file_chooser_get_select_multiple(
846                self.as_ref().to_glib_none().0,
847            ))
848        }
849    }
850
851    /// Gets whether hidden files and folders are displayed in the file selector.
852    /// See [`set_show_hidden()`][Self::set_show_hidden()].
853    ///
854    /// # Returns
855    ///
856    /// [`true`] if hidden files and folders are displayed.
857    #[doc(alias = "gtk_file_chooser_get_show_hidden")]
858    #[doc(alias = "get_show_hidden")]
859    #[doc(alias = "show-hidden")]
860    fn shows_hidden(&self) -> bool {
861        unsafe {
862            from_glib(ffi::gtk_file_chooser_get_show_hidden(
863                self.as_ref().to_glib_none().0,
864            ))
865        }
866    }
867
868    /// Gets the URI for the currently selected file in
869    /// the file selector. If multiple files are selected,
870    /// one of the filenames will be returned at random.
871    ///
872    /// If the file chooser is in folder mode, this function returns the selected
873    /// folder.
874    ///
875    /// # Returns
876    ///
877    /// The currently selected URI, or [`None`]
878    ///  if no file is selected. If [`set_local_only()`][Self::set_local_only()] is set to
879    ///  [`true`] (the default) a local URI will be returned for any FUSE locations.
880    ///  Free with `g_free()`
881    #[doc(alias = "gtk_file_chooser_get_uri")]
882    #[doc(alias = "get_uri")]
883    fn uri(&self) -> Option<glib::GString> {
884        unsafe {
885            from_glib_full(ffi::gtk_file_chooser_get_uri(
886                self.as_ref().to_glib_none().0,
887            ))
888        }
889    }
890
891    /// Lists all the selected files and subfolders in the current folder of
892    /// `self`. The returned names are full absolute URIs.
893    ///
894    /// # Returns
895    ///
896    /// a `GSList` containing the URIs of all selected
897    ///  files and subfolders in the current folder. Free the returned list
898    ///  with `g_slist_free()`, and the filenames with `g_free()`.
899    #[doc(alias = "gtk_file_chooser_get_uris")]
900    #[doc(alias = "get_uris")]
901    fn uris(&self) -> Vec<glib::GString> {
902        unsafe {
903            FromGlibPtrContainer::from_glib_full(ffi::gtk_file_chooser_get_uris(
904                self.as_ref().to_glib_none().0,
905            ))
906        }
907    }
908
909    /// Gets whether a stock label should be drawn with the name of the previewed
910    /// file. See [`set_use_preview_label()`][Self::set_use_preview_label()].
911    ///
912    /// # Returns
913    ///
914    /// [`true`] if the file chooser is set to display a label with the
915    /// name of the previewed file, [`false`] otherwise.
916    #[doc(alias = "gtk_file_chooser_get_use_preview_label")]
917    #[doc(alias = "get_use_preview_label")]
918    #[doc(alias = "use-preview-label")]
919    fn uses_preview_label(&self) -> bool {
920        unsafe {
921            from_glib(ffi::gtk_file_chooser_get_use_preview_label(
922                self.as_ref().to_glib_none().0,
923            ))
924        }
925    }
926
927    /// Lists the current set of user-selectable filters; see
928    /// [`add_filter()`][Self::add_filter()], [`remove_filter()`][Self::remove_filter()].
929    ///
930    /// # Returns
931    ///
932    /// a
933    ///  `GSList` containing the current set of user selectable filters. The
934    ///  contents of the list are owned by GTK+, but you must free the list
935    ///  itself with `g_slist_free()` when you are done with it.
936    #[doc(alias = "gtk_file_chooser_list_filters")]
937    fn list_filters(&self) -> Vec<FileFilter> {
938        unsafe {
939            FromGlibPtrContainer::from_glib_container(ffi::gtk_file_chooser_list_filters(
940                self.as_ref().to_glib_none().0,
941            ))
942        }
943    }
944
945    /// Queries the list of shortcut folders in the file chooser, as set by
946    /// [`add_shortcut_folder_uri()`][Self::add_shortcut_folder_uri()].
947    ///
948    /// # Returns
949    ///
950    /// A list of
951    /// folder URIs, or [`None`] if there are no shortcut folders. Free the
952    /// returned list with `g_slist_free()`, and the URIs with `g_free()`.
953    #[doc(alias = "gtk_file_chooser_list_shortcut_folder_uris")]
954    fn list_shortcut_folder_uris(&self) -> Vec<glib::GString> {
955        unsafe {
956            FromGlibPtrContainer::from_glib_full(ffi::gtk_file_chooser_list_shortcut_folder_uris(
957                self.as_ref().to_glib_none().0,
958            ))
959        }
960    }
961
962    /// Queries the list of shortcut folders in the file chooser, as set by
963    /// [`add_shortcut_folder()`][Self::add_shortcut_folder()].
964    ///
965    /// # Returns
966    ///
967    /// A list
968    /// of folder filenames, or [`None`] if there are no shortcut folders.
969    /// Free the returned list with `g_slist_free()`, and the filenames with
970    /// `g_free()`.
971    #[doc(alias = "gtk_file_chooser_list_shortcut_folders")]
972    fn list_shortcut_folders(&self) -> Vec<std::path::PathBuf> {
973        unsafe {
974            FromGlibPtrContainer::from_glib_full(ffi::gtk_file_chooser_list_shortcut_folders(
975                self.as_ref().to_glib_none().0,
976            ))
977        }
978    }
979
980    /// Removes a 'choice' that has been added with [`FileChooserExtManual::add_choice()`][crate::prelude::FileChooserExtManual::add_choice()].
981    /// ## `id`
982    /// the ID of the choice to remove
983    #[doc(alias = "gtk_file_chooser_remove_choice")]
984    fn remove_choice(&self, id: &str) {
985        unsafe {
986            ffi::gtk_file_chooser_remove_choice(
987                self.as_ref().to_glib_none().0,
988                id.to_glib_none().0,
989            );
990        }
991    }
992
993    /// Removes `filter` from the list of filters that the user can select between.
994    /// ## `filter`
995    /// a [`FileFilter`][crate::FileFilter]
996    #[doc(alias = "gtk_file_chooser_remove_filter")]
997    fn remove_filter(&self, filter: &FileFilter) {
998        unsafe {
999            ffi::gtk_file_chooser_remove_filter(
1000                self.as_ref().to_glib_none().0,
1001                filter.to_glib_none().0,
1002            );
1003        }
1004    }
1005
1006    /// Removes a folder from a file chooser’s list of shortcut folders.
1007    /// ## `folder`
1008    /// filename of the folder to remove
1009    ///
1010    /// # Returns
1011    ///
1012    /// [`true`] if the operation succeeds, [`false`] otherwise.
1013    /// In the latter case, the `error` will be set as appropriate.
1014    ///
1015    /// See also: [`add_shortcut_folder()`][Self::add_shortcut_folder()]
1016    #[doc(alias = "gtk_file_chooser_remove_shortcut_folder")]
1017    fn remove_shortcut_folder(
1018        &self,
1019        folder: impl AsRef<std::path::Path>,
1020    ) -> Result<(), glib::Error> {
1021        unsafe {
1022            let mut error = std::ptr::null_mut();
1023            let is_ok = ffi::gtk_file_chooser_remove_shortcut_folder(
1024                self.as_ref().to_glib_none().0,
1025                folder.as_ref().to_glib_none().0,
1026                &mut error,
1027            );
1028            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1029            if error.is_null() {
1030                Ok(())
1031            } else {
1032                Err(from_glib_full(error))
1033            }
1034        }
1035    }
1036
1037    /// Removes a folder URI from a file chooser’s list of shortcut folders.
1038    /// ## `uri`
1039    /// URI of the folder to remove
1040    ///
1041    /// # Returns
1042    ///
1043    /// [`true`] if the operation succeeds, [`false`] otherwise.
1044    /// In the latter case, the `error` will be set as appropriate.
1045    ///
1046    /// See also: [`add_shortcut_folder_uri()`][Self::add_shortcut_folder_uri()]
1047    #[doc(alias = "gtk_file_chooser_remove_shortcut_folder_uri")]
1048    fn remove_shortcut_folder_uri(&self, uri: &str) -> Result<(), glib::Error> {
1049        unsafe {
1050            let mut error = std::ptr::null_mut();
1051            let is_ok = ffi::gtk_file_chooser_remove_shortcut_folder_uri(
1052                self.as_ref().to_glib_none().0,
1053                uri.to_glib_none().0,
1054                &mut error,
1055            );
1056            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1057            if error.is_null() {
1058                Ok(())
1059            } else {
1060                Err(from_glib_full(error))
1061            }
1062        }
1063    }
1064
1065    /// Selects all the files in the current folder of a file chooser.
1066    #[doc(alias = "gtk_file_chooser_select_all")]
1067    fn select_all(&self) {
1068        unsafe {
1069            ffi::gtk_file_chooser_select_all(self.as_ref().to_glib_none().0);
1070        }
1071    }
1072
1073    /// Selects the file referred to by `file`. An internal function. See
1074    /// `_gtk_file_chooser_select_uri()`.
1075    /// ## `file`
1076    /// the file to select
1077    ///
1078    /// # Returns
1079    ///
1080    /// Not useful.
1081    #[doc(alias = "gtk_file_chooser_select_file")]
1082    fn select_file(&self, file: &impl IsA<gio::File>) -> Result<(), glib::Error> {
1083        unsafe {
1084            let mut error = std::ptr::null_mut();
1085            let is_ok = ffi::gtk_file_chooser_select_file(
1086                self.as_ref().to_glib_none().0,
1087                file.as_ref().to_glib_none().0,
1088                &mut error,
1089            );
1090            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1091            if error.is_null() {
1092                Ok(())
1093            } else {
1094                Err(from_glib_full(error))
1095            }
1096        }
1097    }
1098
1099    /// Selects a filename. If the file name isn’t in the current
1100    /// folder of `self`, then the current folder of `self` will
1101    /// be changed to the folder containing `filename`.
1102    /// ## `filename`
1103    /// the filename to select
1104    ///
1105    /// # Returns
1106    ///
1107    /// Not useful.
1108    ///
1109    /// See also: [`set_filename()`][Self::set_filename()]
1110    #[doc(alias = "gtk_file_chooser_select_filename")]
1111    fn select_filename(&self, filename: impl AsRef<std::path::Path>) -> bool {
1112        unsafe {
1113            from_glib(ffi::gtk_file_chooser_select_filename(
1114                self.as_ref().to_glib_none().0,
1115                filename.as_ref().to_glib_none().0,
1116            ))
1117        }
1118    }
1119
1120    /// Selects the file to by `uri`. If the URI doesn’t refer to a
1121    /// file in the current folder of `self`, then the current folder of
1122    /// `self` will be changed to the folder containing `filename`.
1123    /// ## `uri`
1124    /// the URI to select
1125    ///
1126    /// # Returns
1127    ///
1128    /// Not useful.
1129    #[doc(alias = "gtk_file_chooser_select_uri")]
1130    fn select_uri(&self, uri: &str) -> bool {
1131        unsafe {
1132            from_glib(ffi::gtk_file_chooser_select_uri(
1133                self.as_ref().to_glib_none().0,
1134                uri.to_glib_none().0,
1135            ))
1136        }
1137    }
1138
1139    /// Sets the type of operation that the chooser is performing; the
1140    /// user interface is adapted to suit the selected action. For example,
1141    /// an option to create a new folder might be shown if the action is
1142    /// [`FileChooserAction::Save`][crate::FileChooserAction::Save] but not if the action is
1143    /// [`FileChooserAction::Open`][crate::FileChooserAction::Open].
1144    /// ## `action`
1145    /// the action that the file selector is performing
1146    #[doc(alias = "gtk_file_chooser_set_action")]
1147    #[doc(alias = "action")]
1148    fn set_action(&self, action: FileChooserAction) {
1149        unsafe {
1150            ffi::gtk_file_chooser_set_action(self.as_ref().to_glib_none().0, action.into_glib());
1151        }
1152    }
1153
1154    /// Selects an option in a 'choice' that has been added with
1155    /// [`FileChooserExtManual::add_choice()`][crate::prelude::FileChooserExtManual::add_choice()]. For a boolean choice, the
1156    /// possible options are "true" and "false".
1157    /// ## `id`
1158    /// the ID of the choice to set
1159    /// ## `option`
1160    /// the ID of the option to select
1161    #[doc(alias = "gtk_file_chooser_set_choice")]
1162    fn set_choice(&self, id: &str, option: &str) {
1163        unsafe {
1164            ffi::gtk_file_chooser_set_choice(
1165                self.as_ref().to_glib_none().0,
1166                id.to_glib_none().0,
1167                option.to_glib_none().0,
1168            );
1169        }
1170    }
1171
1172    /// Sets whether file choser will offer to create new folders.
1173    /// This is only relevant if the action is not set to be
1174    /// [`FileChooserAction::Open`][crate::FileChooserAction::Open].
1175    /// ## `create_folders`
1176    /// [`true`] if the Create Folder button should be displayed
1177    #[doc(alias = "gtk_file_chooser_set_create_folders")]
1178    #[doc(alias = "create-folders")]
1179    fn set_create_folders(&self, create_folders: bool) {
1180        unsafe {
1181            ffi::gtk_file_chooser_set_create_folders(
1182                self.as_ref().to_glib_none().0,
1183                create_folders.into_glib(),
1184            );
1185        }
1186    }
1187
1188    /// Sets the current folder for `self` from a local filename.
1189    /// The user will be shown the full contents of the current folder,
1190    /// plus user interface elements for navigating to other folders.
1191    ///
1192    /// In general, you should not use this function. See the
1193    /// [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up]
1194    /// for the rationale behind this.
1195    /// ## `filename`
1196    /// the full path of the new current folder
1197    ///
1198    /// # Returns
1199    ///
1200    /// Not useful.
1201    #[doc(alias = "gtk_file_chooser_set_current_folder")]
1202    fn set_current_folder(&self, filename: impl AsRef<std::path::Path>) -> bool {
1203        unsafe {
1204            from_glib(ffi::gtk_file_chooser_set_current_folder(
1205                self.as_ref().to_glib_none().0,
1206                filename.as_ref().to_glib_none().0,
1207            ))
1208        }
1209    }
1210
1211    /// Sets the current folder for `self` from a [`gio::File`][crate::gio::File].
1212    /// Internal function, see [`set_current_folder_uri()`][Self::set_current_folder_uri()].
1213    /// ## `file`
1214    /// the [`gio::File`][crate::gio::File] for the new folder
1215    ///
1216    /// # Returns
1217    ///
1218    /// [`true`] if the folder could be changed successfully, [`false`]
1219    /// otherwise.
1220    #[doc(alias = "gtk_file_chooser_set_current_folder_file")]
1221    fn set_current_folder_file(&self, file: &impl IsA<gio::File>) -> Result<(), glib::Error> {
1222        unsafe {
1223            let mut error = std::ptr::null_mut();
1224            let is_ok = ffi::gtk_file_chooser_set_current_folder_file(
1225                self.as_ref().to_glib_none().0,
1226                file.as_ref().to_glib_none().0,
1227                &mut error,
1228            );
1229            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1230            if error.is_null() {
1231                Ok(())
1232            } else {
1233                Err(from_glib_full(error))
1234            }
1235        }
1236    }
1237
1238    /// Sets the current folder for `self` from an URI.
1239    /// The user will be shown the full contents of the current folder,
1240    /// plus user interface elements for navigating to other folders.
1241    ///
1242    /// In general, you should not use this function. See the
1243    /// [section on setting up a file chooser dialog][gtkfilechooserdialog-setting-up]
1244    /// for the rationale behind this.
1245    /// ## `uri`
1246    /// the URI for the new current folder
1247    ///
1248    /// # Returns
1249    ///
1250    /// [`true`] if the folder could be changed successfully, [`false`]
1251    /// otherwise.
1252    #[doc(alias = "gtk_file_chooser_set_current_folder_uri")]
1253    fn set_current_folder_uri(&self, uri: &str) -> bool {
1254        unsafe {
1255            from_glib(ffi::gtk_file_chooser_set_current_folder_uri(
1256                self.as_ref().to_glib_none().0,
1257                uri.to_glib_none().0,
1258            ))
1259        }
1260    }
1261
1262    /// Sets the current name in the file selector, as if entered
1263    /// by the user. Note that the name passed in here is a UTF-8
1264    /// string rather than a filename. This function is meant for
1265    /// such uses as a suggested name in a “Save As...” dialog. You can
1266    /// pass “Untitled.doc” or a similarly suitable suggestion for the `name`.
1267    ///
1268    /// If you want to preselect a particular existing file, you should use
1269    /// [`set_filename()`][Self::set_filename()] or [`set_uri()`][Self::set_uri()] instead.
1270    /// Please see the documentation for those functions for an example of using
1271    /// [`set_current_name()`][Self::set_current_name()] as well.
1272    /// ## `name`
1273    /// the filename to use, as a UTF-8 string
1274    #[doc(alias = "gtk_file_chooser_set_current_name")]
1275    fn set_current_name(&self, name: &str) {
1276        unsafe {
1277            ffi::gtk_file_chooser_set_current_name(
1278                self.as_ref().to_glib_none().0,
1279                name.to_glib_none().0,
1280            );
1281        }
1282    }
1283
1284    /// Sets whether a file chooser in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode will present
1285    /// a confirmation dialog if the user types a file name that already exists. This
1286    /// is [`false`] by default.
1287    ///
1288    /// If set to [`true`], the `self` will emit the
1289    /// [`confirm-overwrite`][struct@crate::FileChooser#confirm-overwrite] signal when appropriate.
1290    ///
1291    /// If all you need is the stock confirmation dialog, set this property to [`true`].
1292    /// You can override the way confirmation is done by actually handling the
1293    /// [`confirm-overwrite`][struct@crate::FileChooser#confirm-overwrite] signal; please refer to its documentation
1294    /// for the details.
1295    /// ## `do_overwrite_confirmation`
1296    /// whether to confirm overwriting in save mode
1297    #[doc(alias = "gtk_file_chooser_set_do_overwrite_confirmation")]
1298    #[doc(alias = "do-overwrite-confirmation")]
1299    fn set_do_overwrite_confirmation(&self, do_overwrite_confirmation: bool) {
1300        unsafe {
1301            ffi::gtk_file_chooser_set_do_overwrite_confirmation(
1302                self.as_ref().to_glib_none().0,
1303                do_overwrite_confirmation.into_glib(),
1304            );
1305        }
1306    }
1307
1308    /// Sets an application-supplied widget to provide extra options to the user.
1309    /// ## `extra_widget`
1310    /// widget for extra options
1311    #[doc(alias = "gtk_file_chooser_set_extra_widget")]
1312    #[doc(alias = "extra-widget")]
1313    fn set_extra_widget(&self, extra_widget: &impl IsA<Widget>) {
1314        unsafe {
1315            ffi::gtk_file_chooser_set_extra_widget(
1316                self.as_ref().to_glib_none().0,
1317                extra_widget.as_ref().to_glib_none().0,
1318            );
1319        }
1320    }
1321
1322    /// Sets `file` as the current filename for the file chooser, by changing
1323    /// to the file’s parent folder and actually selecting the file in list. If
1324    /// the `self` is in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode, the file’s base name
1325    /// will also appear in the dialog’s file name entry.
1326    ///
1327    /// If the file name isn’t in the current folder of `self`, then the current
1328    /// folder of `self` will be changed to the folder containing `filename`. This
1329    /// is equivalent to a sequence of [`unselect_all()`][Self::unselect_all()] followed by
1330    /// [`select_filename()`][Self::select_filename()].
1331    ///
1332    /// Note that the file must exist, or nothing will be done except
1333    /// for the directory change.
1334    ///
1335    /// If you are implementing a save dialog,
1336    /// you should use this function if you already have a file name to which the
1337    /// user may save; for example, when the user opens an existing file and then
1338    /// does Save As... If you don’t have
1339    /// a file name already — for example, if the user just created a new
1340    /// file and is saving it for the first time, do not call this function.
1341    /// Instead, use something similar to this:
1342    ///
1343    ///
1344    /// **⚠️ The following code is in C ⚠️**
1345    ///
1346    /// ```C
1347    /// if (document_is_new)
1348    ///   {
1349    ///     // the user just created a new document
1350    ///     gtk_file_chooser_set_current_folder_file (chooser, default_file_for_saving);
1351    ///     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1352    ///   }
1353    /// else
1354    ///   {
1355    ///     // the user edited an existing document
1356    ///     gtk_file_chooser_set_file (chooser, existing_file);
1357    ///   }
1358    /// ```
1359    /// ## `file`
1360    /// the [`gio::File`][crate::gio::File] to set as current
1361    ///
1362    /// # Returns
1363    ///
1364    /// Not useful.
1365    #[doc(alias = "gtk_file_chooser_set_file")]
1366    fn set_file(&self, file: &impl IsA<gio::File>) -> Result<(), glib::Error> {
1367        unsafe {
1368            let mut error = std::ptr::null_mut();
1369            let is_ok = ffi::gtk_file_chooser_set_file(
1370                self.as_ref().to_glib_none().0,
1371                file.as_ref().to_glib_none().0,
1372                &mut error,
1373            );
1374            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1375            if error.is_null() {
1376                Ok(())
1377            } else {
1378                Err(from_glib_full(error))
1379            }
1380        }
1381    }
1382
1383    /// Sets `filename` as the current filename for the file chooser, by changing to
1384    /// the file’s parent folder and actually selecting the file in list; all other
1385    /// files will be unselected. If the `self` is in
1386    /// [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode, the file’s base name will also appear in
1387    /// the dialog’s file name entry.
1388    ///
1389    /// Note that the file must exist, or nothing will be done except
1390    /// for the directory change.
1391    ///
1392    /// You should use this function only when implementing a save
1393    /// dialog for which you already have a file name to which
1394    /// the user may save. For example, when the user opens an existing file and
1395    /// then does Save As... to save a copy or
1396    /// a modified version. If you don’t have a file name already — for
1397    /// example, if the user just created a new file and is saving it for the first
1398    /// time, do not call this function. Instead, use something similar to this:
1399    ///
1400    ///
1401    /// **⚠️ The following code is in C ⚠️**
1402    ///
1403    /// ```C
1404    /// if (document_is_new)
1405    ///   {
1406    ///     // the user just created a new document
1407    ///     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1408    ///   }
1409    /// else
1410    ///   {
1411    ///     // the user edited an existing document
1412    ///     gtk_file_chooser_set_filename (chooser, existing_filename);
1413    ///   }
1414    /// ```
1415    ///
1416    /// In the first case, the file chooser will present the user with useful suggestions
1417    /// as to where to save his new file. In the second case, the file’s existing location
1418    /// is already known, so the file chooser will use it.
1419    /// ## `filename`
1420    /// the filename to set as current
1421    ///
1422    /// # Returns
1423    ///
1424    /// Not useful.
1425    #[doc(alias = "gtk_file_chooser_set_filename")]
1426    fn set_filename(&self, filename: impl AsRef<std::path::Path>) -> bool {
1427        unsafe {
1428            from_glib(ffi::gtk_file_chooser_set_filename(
1429                self.as_ref().to_glib_none().0,
1430                filename.as_ref().to_glib_none().0,
1431            ))
1432        }
1433    }
1434
1435    /// Sets the current filter; only the files that pass the
1436    /// filter will be displayed. If the user-selectable list of filters
1437    /// is non-empty, then the filter should be one of the filters
1438    /// in that list. Setting the current filter when the list of
1439    /// filters is empty is useful if you want to restrict the displayed
1440    /// set of files without letting the user change it.
1441    /// ## `filter`
1442    /// a [`FileFilter`][crate::FileFilter]
1443    #[doc(alias = "gtk_file_chooser_set_filter")]
1444    #[doc(alias = "filter")]
1445    fn set_filter(&self, filter: &FileFilter) {
1446        unsafe {
1447            ffi::gtk_file_chooser_set_filter(
1448                self.as_ref().to_glib_none().0,
1449                filter.to_glib_none().0,
1450            );
1451        }
1452    }
1453
1454    /// Sets whether only local files can be selected in the
1455    /// file selector. If `local_only` is [`true`] (the default),
1456    /// then the selected file or files are guaranteed to be
1457    /// accessible through the operating systems native file
1458    /// system and therefore the application only
1459    /// needs to worry about the filename functions in
1460    /// [`FileChooser`][crate::FileChooser], like [`filename()`][Self::filename()],
1461    /// rather than the URI functions like
1462    /// [`uri()`][Self::uri()],
1463    ///
1464    /// On some systems non-native files may still be
1465    /// available using the native filesystem via a userspace
1466    /// filesystem (FUSE).
1467    /// ## `local_only`
1468    /// [`true`] if only local files can be selected
1469    #[doc(alias = "gtk_file_chooser_set_local_only")]
1470    #[doc(alias = "local-only")]
1471    fn set_local_only(&self, local_only: bool) {
1472        unsafe {
1473            ffi::gtk_file_chooser_set_local_only(
1474                self.as_ref().to_glib_none().0,
1475                local_only.into_glib(),
1476            );
1477        }
1478    }
1479
1480    /// Sets an application-supplied widget to use to display a custom preview
1481    /// of the currently selected file. To implement a preview, after setting the
1482    /// preview widget, you connect to the [`update-preview`][struct@crate::FileChooser#update-preview]
1483    /// signal, and call [`preview_filename()`][Self::preview_filename()] or
1484    /// [`preview_uri()`][Self::preview_uri()] on each change. If you can
1485    /// display a preview of the new file, update your widget and
1486    /// set the preview active using [`set_preview_widget_active()`][Self::set_preview_widget_active()].
1487    /// Otherwise, set the preview inactive.
1488    ///
1489    /// When there is no application-supplied preview widget, or the
1490    /// application-supplied preview widget is not active, the file chooser
1491    /// will display no preview at all.
1492    /// ## `preview_widget`
1493    /// widget for displaying preview.
1494    #[doc(alias = "gtk_file_chooser_set_preview_widget")]
1495    #[doc(alias = "preview-widget")]
1496    fn set_preview_widget(&self, preview_widget: &impl IsA<Widget>) {
1497        unsafe {
1498            ffi::gtk_file_chooser_set_preview_widget(
1499                self.as_ref().to_glib_none().0,
1500                preview_widget.as_ref().to_glib_none().0,
1501            );
1502        }
1503    }
1504
1505    /// Sets whether the preview widget set by
1506    /// [`set_preview_widget()`][Self::set_preview_widget()] should be shown for the
1507    /// current filename. When `active` is set to false, the file chooser
1508    /// may display an internally generated preview of the current file
1509    /// or it may display no preview at all. See
1510    /// [`set_preview_widget()`][Self::set_preview_widget()] for more details.
1511    /// ## `active`
1512    /// whether to display the user-specified preview widget
1513    #[doc(alias = "gtk_file_chooser_set_preview_widget_active")]
1514    #[doc(alias = "preview-widget-active")]
1515    fn set_preview_widget_active(&self, active: bool) {
1516        unsafe {
1517            ffi::gtk_file_chooser_set_preview_widget_active(
1518                self.as_ref().to_glib_none().0,
1519                active.into_glib(),
1520            );
1521        }
1522    }
1523
1524    /// Sets whether multiple files can be selected in the file selector. This is
1525    /// only relevant if the action is set to be [`FileChooserAction::Open`][crate::FileChooserAction::Open] or
1526    /// [`FileChooserAction::SelectFolder`][crate::FileChooserAction::SelectFolder].
1527    /// ## `select_multiple`
1528    /// [`true`] if multiple files can be selected.
1529    #[doc(alias = "gtk_file_chooser_set_select_multiple")]
1530    #[doc(alias = "select-multiple")]
1531    fn set_select_multiple(&self, select_multiple: bool) {
1532        unsafe {
1533            ffi::gtk_file_chooser_set_select_multiple(
1534                self.as_ref().to_glib_none().0,
1535                select_multiple.into_glib(),
1536            );
1537        }
1538    }
1539
1540    /// Sets whether hidden files and folders are displayed in the file selector.
1541    /// ## `show_hidden`
1542    /// [`true`] if hidden files and folders should be displayed.
1543    #[doc(alias = "gtk_file_chooser_set_show_hidden")]
1544    #[doc(alias = "show-hidden")]
1545    fn set_show_hidden(&self, show_hidden: bool) {
1546        unsafe {
1547            ffi::gtk_file_chooser_set_show_hidden(
1548                self.as_ref().to_glib_none().0,
1549                show_hidden.into_glib(),
1550            );
1551        }
1552    }
1553
1554    /// Sets the file referred to by `uri` as the current file for the file chooser,
1555    /// by changing to the URI’s parent folder and actually selecting the URI in the
1556    /// list. If the `self` is [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode, the URI’s base
1557    /// name will also appear in the dialog’s file name entry.
1558    ///
1559    /// Note that the URI must exist, or nothing will be done except for the
1560    /// directory change.
1561    ///
1562    /// You should use this function only when implementing a save
1563    /// dialog for which you already have a file name to which
1564    /// the user may save. For example, when the user opens an existing file and then
1565    /// does Save As... to save a copy or a
1566    /// modified version. If you don’t have a file name already — for example,
1567    /// if the user just created a new file and is saving it for the first time, do
1568    /// not call this function. Instead, use something similar to this:
1569    ///
1570    ///
1571    /// **⚠️ The following code is in C ⚠️**
1572    ///
1573    /// ```C
1574    /// if (document_is_new)
1575    ///   {
1576    ///     // the user just created a new document
1577    ///     gtk_file_chooser_set_current_name (chooser, "Untitled document");
1578    ///   }
1579    /// else
1580    ///   {
1581    ///     // the user edited an existing document
1582    ///     gtk_file_chooser_set_uri (chooser, existing_uri);
1583    ///   }
1584    /// ```
1585    ///
1586    ///
1587    /// In the first case, the file chooser will present the user with useful suggestions
1588    /// as to where to save his new file. In the second case, the file’s existing location
1589    /// is already known, so the file chooser will use it.
1590    /// ## `uri`
1591    /// the URI to set as current
1592    ///
1593    /// # Returns
1594    ///
1595    /// Not useful.
1596    #[doc(alias = "gtk_file_chooser_set_uri")]
1597    fn set_uri(&self, uri: &str) -> bool {
1598        unsafe {
1599            from_glib(ffi::gtk_file_chooser_set_uri(
1600                self.as_ref().to_glib_none().0,
1601                uri.to_glib_none().0,
1602            ))
1603        }
1604    }
1605
1606    /// Sets whether the file chooser should display a stock label with the name of
1607    /// the file that is being previewed; the default is [`true`]. Applications that
1608    /// want to draw the whole preview area themselves should set this to [`false`] and
1609    /// display the name themselves in their preview widget.
1610    ///
1611    /// See also: [`set_preview_widget()`][Self::set_preview_widget()]
1612    /// ## `use_label`
1613    /// whether to display a stock label with the name of the previewed file
1614    #[doc(alias = "gtk_file_chooser_set_use_preview_label")]
1615    #[doc(alias = "use-preview-label")]
1616    fn set_use_preview_label(&self, use_label: bool) {
1617        unsafe {
1618            ffi::gtk_file_chooser_set_use_preview_label(
1619                self.as_ref().to_glib_none().0,
1620                use_label.into_glib(),
1621            );
1622        }
1623    }
1624
1625    /// Unselects all the files in the current folder of a file chooser.
1626    #[doc(alias = "gtk_file_chooser_unselect_all")]
1627    fn unselect_all(&self) {
1628        unsafe {
1629            ffi::gtk_file_chooser_unselect_all(self.as_ref().to_glib_none().0);
1630        }
1631    }
1632
1633    /// Unselects the file referred to by `file`. If the file is not in the current
1634    /// directory, does not exist, or is otherwise not currently selected, does nothing.
1635    /// ## `file`
1636    /// a [`gio::File`][crate::gio::File]
1637    #[doc(alias = "gtk_file_chooser_unselect_file")]
1638    fn unselect_file(&self, file: &impl IsA<gio::File>) {
1639        unsafe {
1640            ffi::gtk_file_chooser_unselect_file(
1641                self.as_ref().to_glib_none().0,
1642                file.as_ref().to_glib_none().0,
1643            );
1644        }
1645    }
1646
1647    /// Unselects a currently selected filename. If the filename
1648    /// is not in the current directory, does not exist, or
1649    /// is otherwise not currently selected, does nothing.
1650    /// ## `filename`
1651    /// the filename to unselect
1652    #[doc(alias = "gtk_file_chooser_unselect_filename")]
1653    fn unselect_filename(&self, filename: impl AsRef<std::path::Path>) {
1654        unsafe {
1655            ffi::gtk_file_chooser_unselect_filename(
1656                self.as_ref().to_glib_none().0,
1657                filename.as_ref().to_glib_none().0,
1658            );
1659        }
1660    }
1661
1662    /// Unselects the file referred to by `uri`. If the file
1663    /// is not in the current directory, does not exist, or
1664    /// is otherwise not currently selected, does nothing.
1665    /// ## `uri`
1666    /// the URI to unselect
1667    #[doc(alias = "gtk_file_chooser_unselect_uri")]
1668    fn unselect_uri(&self, uri: &str) {
1669        unsafe {
1670            ffi::gtk_file_chooser_unselect_uri(
1671                self.as_ref().to_glib_none().0,
1672                uri.to_glib_none().0,
1673            );
1674        }
1675    }
1676
1677    /// This signal gets emitted whenever it is appropriate to present a
1678    /// confirmation dialog when the user has selected a file name that
1679    /// already exists. The signal only gets emitted when the file
1680    /// chooser is in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode.
1681    ///
1682    /// Most applications just need to turn on the
1683    /// [`do-overwrite-confirmation`][struct@crate::FileChooser#do-overwrite-confirmation] property (or call the
1684    /// [`set_do_overwrite_confirmation()`][Self::set_do_overwrite_confirmation()] function), and
1685    /// they will automatically get a stock confirmation dialog.
1686    /// Applications which need to customize this behavior should do
1687    /// that, and also connect to the [`confirm-overwrite`][struct@crate::FileChooser#confirm-overwrite]
1688    /// signal.
1689    ///
1690    /// A signal handler for this signal must return a
1691    /// [`FileChooserConfirmation`][crate::FileChooserConfirmation] value, which indicates the action to
1692    /// take. If the handler determines that the user wants to select a
1693    /// different filename, it should return
1694    /// [`FileChooserConfirmation::SelectAgain`][crate::FileChooserConfirmation::SelectAgain]. If it determines
1695    /// that the user is satisfied with his choice of file name, it
1696    /// should return [`FileChooserConfirmation::AcceptFilename`][crate::FileChooserConfirmation::AcceptFilename].
1697    /// On the other hand, if it determines that the stock confirmation
1698    /// dialog should be used, it should return
1699    /// [`FileChooserConfirmation::Confirm`][crate::FileChooserConfirmation::Confirm]. The following example
1700    /// illustrates this.
1701    ///
1702    /// ## Custom confirmation ## {`gtkfilechooser`-confirmation}
1703    ///
1704    ///
1705    ///
1706    /// **⚠️ The following code is in C ⚠️**
1707    ///
1708    /// ```C
1709    /// static GtkFileChooserConfirmation
1710    /// confirm_overwrite_callback (GtkFileChooser *chooser, gpointer data)
1711    /// {
1712    ///   char *uri;
1713    ///
1714    ///   uri = gtk_file_chooser_get_uri (chooser);
1715    ///
1716    ///   if (is_uri_read_only (uri))
1717    ///     {
1718    ///       if (user_wants_to_replace_read_only_file (uri))
1719    ///         return GTK_FILE_CHOOSER_CONFIRMATION_ACCEPT_FILENAME;
1720    ///       else
1721    ///         return GTK_FILE_CHOOSER_CONFIRMATION_SELECT_AGAIN;
1722    ///     } else
1723    ///       return GTK_FILE_CHOOSER_CONFIRMATION_CONFIRM; // fall back to the default dialog
1724    /// }
1725    ///
1726    /// ...
1727    ///
1728    /// chooser = gtk_file_chooser_dialog_new (...);
1729    ///
1730    /// gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
1731    /// g_signal_connect (chooser, "confirm-overwrite",
1732    ///                   G_CALLBACK (confirm_overwrite_callback), NULL);
1733    ///
1734    /// if (gtk_dialog_run (chooser) == GTK_RESPONSE_ACCEPT)
1735    ///         save_to_file (gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
1736    ///
1737    /// gtk_widget_destroy (chooser);
1738    /// ```
1739    ///
1740    /// # Returns
1741    ///
1742    /// a [`FileChooserConfirmation`][crate::FileChooserConfirmation] value that indicates which
1743    ///  action to take after emitting the signal.
1744    #[doc(alias = "confirm-overwrite")]
1745    fn connect_confirm_overwrite<F: Fn(&Self) -> FileChooserConfirmation + 'static>(
1746        &self,
1747        f: F,
1748    ) -> SignalHandlerId {
1749        unsafe extern "C" fn confirm_overwrite_trampoline<
1750            P: IsA<FileChooser>,
1751            F: Fn(&P) -> FileChooserConfirmation + 'static,
1752        >(
1753            this: *mut ffi::GtkFileChooser,
1754            f: glib::ffi::gpointer,
1755        ) -> ffi::GtkFileChooserConfirmation {
1756            unsafe {
1757                let f: &F = &*(f as *const F);
1758                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
1759            }
1760        }
1761        unsafe {
1762            let f: Box_<F> = Box_::new(f);
1763            connect_raw(
1764                self.as_ptr() as *mut _,
1765                c"confirm-overwrite".as_ptr(),
1766                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1767                    confirm_overwrite_trampoline::<Self, F> as *const (),
1768                )),
1769                Box_::into_raw(f),
1770            )
1771        }
1772    }
1773
1774    /// This signal is emitted when the current folder in a [`FileChooser`][crate::FileChooser]
1775    /// changes. This can happen due to the user performing some action that
1776    /// changes folders, such as selecting a bookmark or visiting a folder on the
1777    /// file list. It can also happen as a result of calling a function to
1778    /// explicitly change the current folder in a file chooser.
1779    ///
1780    /// Normally you do not need to connect to this signal, unless you need to keep
1781    /// track of which folder a file chooser is showing.
1782    ///
1783    /// See also: [`set_current_folder()`][Self::set_current_folder()],
1784    /// [`current_folder()`][Self::current_folder()],
1785    /// [`set_current_folder_uri()`][Self::set_current_folder_uri()],
1786    /// [`current_folder_uri()`][Self::current_folder_uri()].
1787    #[doc(alias = "current-folder-changed")]
1788    fn connect_current_folder_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1789        unsafe extern "C" fn current_folder_changed_trampoline<
1790            P: IsA<FileChooser>,
1791            F: Fn(&P) + 'static,
1792        >(
1793            this: *mut ffi::GtkFileChooser,
1794            f: glib::ffi::gpointer,
1795        ) {
1796            unsafe {
1797                let f: &F = &*(f as *const F);
1798                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
1799            }
1800        }
1801        unsafe {
1802            let f: Box_<F> = Box_::new(f);
1803            connect_raw(
1804                self.as_ptr() as *mut _,
1805                c"current-folder-changed".as_ptr(),
1806                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1807                    current_folder_changed_trampoline::<Self, F> as *const (),
1808                )),
1809                Box_::into_raw(f),
1810            )
1811        }
1812    }
1813
1814    /// This signal is emitted when the user "activates" a file in the file
1815    /// chooser. This can happen by double-clicking on a file in the file list, or
1816    /// by pressing `Enter`.
1817    ///
1818    /// Normally you do not need to connect to this signal. It is used internally
1819    /// by [`FileChooserDialog`][crate::FileChooserDialog] to know when to activate the default button in the
1820    /// dialog.
1821    ///
1822    /// See also: [`filename()`][Self::filename()],
1823    /// [`filenames()`][Self::filenames()], [`uri()`][Self::uri()],
1824    /// [`uris()`][Self::uris()].
1825    #[doc(alias = "file-activated")]
1826    fn connect_file_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1827        unsafe extern "C" fn file_activated_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
1828            this: *mut ffi::GtkFileChooser,
1829            f: glib::ffi::gpointer,
1830        ) {
1831            unsafe {
1832                let f: &F = &*(f as *const F);
1833                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
1834            }
1835        }
1836        unsafe {
1837            let f: Box_<F> = Box_::new(f);
1838            connect_raw(
1839                self.as_ptr() as *mut _,
1840                c"file-activated".as_ptr(),
1841                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1842                    file_activated_trampoline::<Self, F> as *const (),
1843                )),
1844                Box_::into_raw(f),
1845            )
1846        }
1847    }
1848
1849    /// This signal is emitted when there is a change in the set of selected files
1850    /// in a [`FileChooser`][crate::FileChooser]. This can happen when the user modifies the selection
1851    /// with the mouse or the keyboard, or when explicitly calling functions to
1852    /// change the selection.
1853    ///
1854    /// Normally you do not need to connect to this signal, as it is easier to wait
1855    /// for the file chooser to finish running, and then to get the list of
1856    /// selected files using the functions mentioned below.
1857    ///
1858    /// See also: [`select_filename()`][Self::select_filename()],
1859    /// [`unselect_filename()`][Self::unselect_filename()], [`filename()`][Self::filename()],
1860    /// [`filenames()`][Self::filenames()], [`select_uri()`][Self::select_uri()],
1861    /// [`unselect_uri()`][Self::unselect_uri()], [`uri()`][Self::uri()],
1862    /// [`uris()`][Self::uris()].
1863    #[doc(alias = "selection-changed")]
1864    fn connect_selection_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1865        unsafe extern "C" fn selection_changed_trampoline<
1866            P: IsA<FileChooser>,
1867            F: Fn(&P) + 'static,
1868        >(
1869            this: *mut ffi::GtkFileChooser,
1870            f: glib::ffi::gpointer,
1871        ) {
1872            unsafe {
1873                let f: &F = &*(f as *const F);
1874                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
1875            }
1876        }
1877        unsafe {
1878            let f: Box_<F> = Box_::new(f);
1879            connect_raw(
1880                self.as_ptr() as *mut _,
1881                c"selection-changed".as_ptr(),
1882                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1883                    selection_changed_trampoline::<Self, F> as *const (),
1884                )),
1885                Box_::into_raw(f),
1886            )
1887        }
1888    }
1889
1890    /// This signal is emitted when the preview in a file chooser should be
1891    /// regenerated. For example, this can happen when the currently selected file
1892    /// changes. You should use this signal if you want your file chooser to have
1893    /// a preview widget.
1894    ///
1895    /// Once you have installed a preview widget with
1896    /// [`set_preview_widget()`][Self::set_preview_widget()], you should update it when this
1897    /// signal is emitted. You can use the functions
1898    /// [`preview_filename()`][Self::preview_filename()] or
1899    /// [`preview_uri()`][Self::preview_uri()] to get the name of the file to preview.
1900    /// Your widget may not be able to preview all kinds of files; your callback
1901    /// must call [`set_preview_widget_active()`][Self::set_preview_widget_active()] to inform the file
1902    /// chooser about whether the preview was generated successfully or not.
1903    ///
1904    /// Please see the example code in
1905    /// [Using a Preview Widget][gtkfilechooser-preview].
1906    ///
1907    /// See also: [`set_preview_widget()`][Self::set_preview_widget()],
1908    /// [`set_preview_widget_active()`][Self::set_preview_widget_active()],
1909    /// [`set_use_preview_label()`][Self::set_use_preview_label()],
1910    /// [`preview_filename()`][Self::preview_filename()],
1911    /// [`preview_uri()`][Self::preview_uri()].
1912    #[doc(alias = "update-preview")]
1913    fn connect_update_preview<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1914        unsafe extern "C" fn update_preview_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
1915            this: *mut ffi::GtkFileChooser,
1916            f: glib::ffi::gpointer,
1917        ) {
1918            unsafe {
1919                let f: &F = &*(f as *const F);
1920                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
1921            }
1922        }
1923        unsafe {
1924            let f: Box_<F> = Box_::new(f);
1925            connect_raw(
1926                self.as_ptr() as *mut _,
1927                c"update-preview".as_ptr(),
1928                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1929                    update_preview_trampoline::<Self, F> as *const (),
1930                )),
1931                Box_::into_raw(f),
1932            )
1933        }
1934    }
1935
1936    #[doc(alias = "action")]
1937    fn connect_action_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1938        unsafe extern "C" fn notify_action_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
1939            this: *mut ffi::GtkFileChooser,
1940            _param_spec: glib::ffi::gpointer,
1941            f: glib::ffi::gpointer,
1942        ) {
1943            unsafe {
1944                let f: &F = &*(f as *const F);
1945                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
1946            }
1947        }
1948        unsafe {
1949            let f: Box_<F> = Box_::new(f);
1950            connect_raw(
1951                self.as_ptr() as *mut _,
1952                c"notify::action".as_ptr(),
1953                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1954                    notify_action_trampoline::<Self, F> as *const (),
1955                )),
1956                Box_::into_raw(f),
1957            )
1958        }
1959    }
1960
1961    #[doc(alias = "create-folders")]
1962    fn connect_create_folders_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1963        unsafe extern "C" fn notify_create_folders_trampoline<
1964            P: IsA<FileChooser>,
1965            F: Fn(&P) + 'static,
1966        >(
1967            this: *mut ffi::GtkFileChooser,
1968            _param_spec: glib::ffi::gpointer,
1969            f: glib::ffi::gpointer,
1970        ) {
1971            unsafe {
1972                let f: &F = &*(f as *const F);
1973                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
1974            }
1975        }
1976        unsafe {
1977            let f: Box_<F> = Box_::new(f);
1978            connect_raw(
1979                self.as_ptr() as *mut _,
1980                c"notify::create-folders".as_ptr(),
1981                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1982                    notify_create_folders_trampoline::<Self, F> as *const (),
1983                )),
1984                Box_::into_raw(f),
1985            )
1986        }
1987    }
1988
1989    #[doc(alias = "do-overwrite-confirmation")]
1990    fn connect_do_overwrite_confirmation_notify<F: Fn(&Self) + 'static>(
1991        &self,
1992        f: F,
1993    ) -> SignalHandlerId {
1994        unsafe extern "C" fn notify_do_overwrite_confirmation_trampoline<
1995            P: IsA<FileChooser>,
1996            F: Fn(&P) + 'static,
1997        >(
1998            this: *mut ffi::GtkFileChooser,
1999            _param_spec: glib::ffi::gpointer,
2000            f: glib::ffi::gpointer,
2001        ) {
2002            unsafe {
2003                let f: &F = &*(f as *const F);
2004                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2005            }
2006        }
2007        unsafe {
2008            let f: Box_<F> = Box_::new(f);
2009            connect_raw(
2010                self.as_ptr() as *mut _,
2011                c"notify::do-overwrite-confirmation".as_ptr(),
2012                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2013                    notify_do_overwrite_confirmation_trampoline::<Self, F> as *const (),
2014                )),
2015                Box_::into_raw(f),
2016            )
2017        }
2018    }
2019
2020    #[doc(alias = "extra-widget")]
2021    fn connect_extra_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2022        unsafe extern "C" fn notify_extra_widget_trampoline<
2023            P: IsA<FileChooser>,
2024            F: Fn(&P) + 'static,
2025        >(
2026            this: *mut ffi::GtkFileChooser,
2027            _param_spec: glib::ffi::gpointer,
2028            f: glib::ffi::gpointer,
2029        ) {
2030            unsafe {
2031                let f: &F = &*(f as *const F);
2032                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2033            }
2034        }
2035        unsafe {
2036            let f: Box_<F> = Box_::new(f);
2037            connect_raw(
2038                self.as_ptr() as *mut _,
2039                c"notify::extra-widget".as_ptr(),
2040                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2041                    notify_extra_widget_trampoline::<Self, F> as *const (),
2042                )),
2043                Box_::into_raw(f),
2044            )
2045        }
2046    }
2047
2048    #[doc(alias = "filter")]
2049    fn connect_filter_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2050        unsafe extern "C" fn notify_filter_trampoline<P: IsA<FileChooser>, F: Fn(&P) + 'static>(
2051            this: *mut ffi::GtkFileChooser,
2052            _param_spec: glib::ffi::gpointer,
2053            f: glib::ffi::gpointer,
2054        ) {
2055            unsafe {
2056                let f: &F = &*(f as *const F);
2057                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2058            }
2059        }
2060        unsafe {
2061            let f: Box_<F> = Box_::new(f);
2062            connect_raw(
2063                self.as_ptr() as *mut _,
2064                c"notify::filter".as_ptr(),
2065                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2066                    notify_filter_trampoline::<Self, F> as *const (),
2067                )),
2068                Box_::into_raw(f),
2069            )
2070        }
2071    }
2072
2073    #[doc(alias = "local-only")]
2074    fn connect_local_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2075        unsafe extern "C" fn notify_local_only_trampoline<
2076            P: IsA<FileChooser>,
2077            F: Fn(&P) + 'static,
2078        >(
2079            this: *mut ffi::GtkFileChooser,
2080            _param_spec: glib::ffi::gpointer,
2081            f: glib::ffi::gpointer,
2082        ) {
2083            unsafe {
2084                let f: &F = &*(f as *const F);
2085                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2086            }
2087        }
2088        unsafe {
2089            let f: Box_<F> = Box_::new(f);
2090            connect_raw(
2091                self.as_ptr() as *mut _,
2092                c"notify::local-only".as_ptr(),
2093                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2094                    notify_local_only_trampoline::<Self, F> as *const (),
2095                )),
2096                Box_::into_raw(f),
2097            )
2098        }
2099    }
2100
2101    #[doc(alias = "preview-widget")]
2102    fn connect_preview_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2103        unsafe extern "C" fn notify_preview_widget_trampoline<
2104            P: IsA<FileChooser>,
2105            F: Fn(&P) + 'static,
2106        >(
2107            this: *mut ffi::GtkFileChooser,
2108            _param_spec: glib::ffi::gpointer,
2109            f: glib::ffi::gpointer,
2110        ) {
2111            unsafe {
2112                let f: &F = &*(f as *const F);
2113                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2114            }
2115        }
2116        unsafe {
2117            let f: Box_<F> = Box_::new(f);
2118            connect_raw(
2119                self.as_ptr() as *mut _,
2120                c"notify::preview-widget".as_ptr(),
2121                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2122                    notify_preview_widget_trampoline::<Self, F> as *const (),
2123                )),
2124                Box_::into_raw(f),
2125            )
2126        }
2127    }
2128
2129    #[doc(alias = "preview-widget-active")]
2130    fn connect_preview_widget_active_notify<F: Fn(&Self) + 'static>(
2131        &self,
2132        f: F,
2133    ) -> SignalHandlerId {
2134        unsafe extern "C" fn notify_preview_widget_active_trampoline<
2135            P: IsA<FileChooser>,
2136            F: Fn(&P) + 'static,
2137        >(
2138            this: *mut ffi::GtkFileChooser,
2139            _param_spec: glib::ffi::gpointer,
2140            f: glib::ffi::gpointer,
2141        ) {
2142            unsafe {
2143                let f: &F = &*(f as *const F);
2144                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2145            }
2146        }
2147        unsafe {
2148            let f: Box_<F> = Box_::new(f);
2149            connect_raw(
2150                self.as_ptr() as *mut _,
2151                c"notify::preview-widget-active".as_ptr(),
2152                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2153                    notify_preview_widget_active_trampoline::<Self, F> as *const (),
2154                )),
2155                Box_::into_raw(f),
2156            )
2157        }
2158    }
2159
2160    #[doc(alias = "select-multiple")]
2161    fn connect_select_multiple_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2162        unsafe extern "C" fn notify_select_multiple_trampoline<
2163            P: IsA<FileChooser>,
2164            F: Fn(&P) + 'static,
2165        >(
2166            this: *mut ffi::GtkFileChooser,
2167            _param_spec: glib::ffi::gpointer,
2168            f: glib::ffi::gpointer,
2169        ) {
2170            unsafe {
2171                let f: &F = &*(f as *const F);
2172                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2173            }
2174        }
2175        unsafe {
2176            let f: Box_<F> = Box_::new(f);
2177            connect_raw(
2178                self.as_ptr() as *mut _,
2179                c"notify::select-multiple".as_ptr(),
2180                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2181                    notify_select_multiple_trampoline::<Self, F> as *const (),
2182                )),
2183                Box_::into_raw(f),
2184            )
2185        }
2186    }
2187
2188    #[doc(alias = "show-hidden")]
2189    fn connect_show_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2190        unsafe extern "C" fn notify_show_hidden_trampoline<
2191            P: IsA<FileChooser>,
2192            F: Fn(&P) + 'static,
2193        >(
2194            this: *mut ffi::GtkFileChooser,
2195            _param_spec: glib::ffi::gpointer,
2196            f: glib::ffi::gpointer,
2197        ) {
2198            unsafe {
2199                let f: &F = &*(f as *const F);
2200                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2201            }
2202        }
2203        unsafe {
2204            let f: Box_<F> = Box_::new(f);
2205            connect_raw(
2206                self.as_ptr() as *mut _,
2207                c"notify::show-hidden".as_ptr(),
2208                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2209                    notify_show_hidden_trampoline::<Self, F> as *const (),
2210                )),
2211                Box_::into_raw(f),
2212            )
2213        }
2214    }
2215
2216    #[doc(alias = "use-preview-label")]
2217    fn connect_use_preview_label_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2218        unsafe extern "C" fn notify_use_preview_label_trampoline<
2219            P: IsA<FileChooser>,
2220            F: Fn(&P) + 'static,
2221        >(
2222            this: *mut ffi::GtkFileChooser,
2223            _param_spec: glib::ffi::gpointer,
2224            f: glib::ffi::gpointer,
2225        ) {
2226            unsafe {
2227                let f: &F = &*(f as *const F);
2228                f(FileChooser::from_glib_borrow(this).unsafe_cast_ref())
2229            }
2230        }
2231        unsafe {
2232            let f: Box_<F> = Box_::new(f);
2233            connect_raw(
2234                self.as_ptr() as *mut _,
2235                c"notify::use-preview-label".as_ptr(),
2236                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2237                    notify_use_preview_label_trampoline::<Self, F> as *const (),
2238                )),
2239                Box_::into_raw(f),
2240            )
2241        }
2242    }
2243}
2244
2245impl<O: IsA<FileChooser>> FileChooserExt for O {}