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