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