gtk4/auto/file_chooser_widget.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::{
7 ffi, Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, FileChooser,
8 FileChooserAction, FileFilter, LayoutManager, Overflow, Widget,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{connect_raw, SignalHandlerId},
14 translate::*,
15};
16use std::boxed::Box as Box_;
17
18glib::wrapper! {
19 /// Direct use of [`FileChooserWidget`][crate::FileChooserWidget] is deprecated
20 /// [`FileChooserWidget`][crate::FileChooserWidget] is a widget for choosing files.
21 ///
22 /// It exposes the [`FileChooser`][crate::FileChooser] interface, and you should
23 /// use the methods of this interface to interact with the
24 /// widget.
25 ///
26 /// # Shortcuts and Gestures
27 ///
28 /// [`FileChooserWidget`][crate::FileChooserWidget] supports the following keyboard shortcuts:
29 ///
30 /// - <kbd>Shift</kbd>+<kbd>F10</kbd> or <kbd>Menu</kbd> opens the context menu.
31 ///
32 /// The following signals have default keybindings:
33 ///
34 /// - [`desktop-folder`][struct@crate::FileChooserWidget#desktop-folder]
35 /// - [`down-folder`][struct@crate::FileChooserWidget#down-folder]
36 /// - [`home-folder`][struct@crate::FileChooserWidget#home-folder]
37 /// - [`location-popup`][struct@crate::FileChooserWidget#location-popup]
38 /// - [`location-popup-on-paste`][struct@crate::FileChooserWidget#location-popup-on-paste]
39 /// - [`location-toggle-popup`][struct@crate::FileChooserWidget#location-toggle-popup]
40 /// - [`places-shortcut`][struct@crate::FileChooserWidget#places-shortcut]
41 /// - [`quick-bookmark`][struct@crate::FileChooserWidget#quick-bookmark]
42 /// - [`recent-shortcut`][struct@crate::FileChooserWidget#recent-shortcut]
43 /// - [`search-shortcut`][struct@crate::FileChooserWidget#search-shortcut]
44 /// - [`show-hidden`][struct@crate::FileChooserWidget#show-hidden]
45 /// - [`up-folder`][struct@crate::FileChooserWidget#up-folder]
46 ///
47 /// # CSS nodes
48 ///
49 /// [`FileChooserWidget`][crate::FileChooserWidget] has a single CSS node with name filechooser.
50 ///
51 /// ## Properties
52 ///
53 ///
54 /// #### `search-mode`
55 /// Whether search mode is enabled.
56 ///
57 /// Readable | Writeable
58 ///
59 ///
60 /// #### `show-time`
61 /// Whether to show the time.
62 ///
63 /// Readable
64 ///
65 ///
66 /// #### `subtitle`
67 /// The subtitle of the file chooser widget.
68 ///
69 /// Readable
70 /// <details><summary><h4>Widget</h4></summary>
71 ///
72 ///
73 /// #### `can-focus`
74 /// Whether the widget or any of its descendents can accept
75 /// the input focus.
76 ///
77 /// This property is meant to be set by widget implementations,
78 /// typically in their instance init function.
79 ///
80 /// Readable | Writeable
81 ///
82 ///
83 /// #### `can-target`
84 /// Whether the widget can receive pointer events.
85 ///
86 /// Readable | Writeable
87 ///
88 ///
89 /// #### `css-classes`
90 /// A list of css classes applied to this widget.
91 ///
92 /// Readable | Writeable
93 ///
94 ///
95 /// #### `css-name`
96 /// The name of this widget in the CSS tree.
97 ///
98 /// This property is meant to be set by widget implementations,
99 /// typically in their instance init function.
100 ///
101 /// Readable | Writeable | Construct Only
102 ///
103 ///
104 /// #### `cursor`
105 /// The cursor used by @widget.
106 ///
107 /// Readable | Writeable
108 ///
109 ///
110 /// #### `focus-on-click`
111 /// Whether the widget should grab focus when it is clicked with the mouse.
112 ///
113 /// This property is only relevant for widgets that can take focus.
114 ///
115 /// Readable | Writeable
116 ///
117 ///
118 /// #### `focusable`
119 /// Whether this widget itself will accept the input focus.
120 ///
121 /// Readable | Writeable
122 ///
123 ///
124 /// #### `halign`
125 /// How to distribute horizontal space if widget gets extra space.
126 ///
127 /// Readable | Writeable
128 ///
129 ///
130 /// #### `has-default`
131 /// Whether the widget is the default widget.
132 ///
133 /// Readable
134 ///
135 ///
136 /// #### `has-focus`
137 /// Whether the widget has the input focus.
138 ///
139 /// Readable
140 ///
141 ///
142 /// #### `has-tooltip`
143 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
144 /// signal on @widget.
145 ///
146 /// A true value indicates that @widget can have a tooltip, in this case
147 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
148 /// determine whether it will provide a tooltip or not.
149 ///
150 /// Readable | Writeable
151 ///
152 ///
153 /// #### `height-request`
154 /// Overrides for height request of the widget.
155 ///
156 /// If this is -1, the natural request will be used.
157 ///
158 /// Readable | Writeable
159 ///
160 ///
161 /// #### `hexpand`
162 /// Whether to expand horizontally.
163 ///
164 /// Readable | Writeable
165 ///
166 ///
167 /// #### `hexpand-set`
168 /// Whether to use the `hexpand` property.
169 ///
170 /// Readable | Writeable
171 ///
172 ///
173 /// #### `layout-manager`
174 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
175 /// the preferred size of the widget, and allocate its children.
176 ///
177 /// This property is meant to be set by widget implementations,
178 /// typically in their instance init function.
179 ///
180 /// Readable | Writeable
181 ///
182 ///
183 /// #### `limit-events`
184 /// Makes this widget act like a modal dialog, with respect to
185 /// event delivery.
186 ///
187 /// Global event controllers will not handle events with targets
188 /// inside the widget, unless they are set up to ignore propagation
189 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
190 ///
191 /// Readable | Writeable
192 ///
193 ///
194 /// #### `margin-bottom`
195 /// Margin on bottom side of widget.
196 ///
197 /// This property adds margin outside of the widget's normal size
198 /// request, the margin will be added in addition to the size from
199 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
200 ///
201 /// Readable | Writeable
202 ///
203 ///
204 /// #### `margin-end`
205 /// Margin on end of widget, horizontally.
206 ///
207 /// This property supports left-to-right and right-to-left text
208 /// directions.
209 ///
210 /// This property adds margin outside of the widget's normal size
211 /// request, the margin will be added in addition to the size from
212 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
213 ///
214 /// Readable | Writeable
215 ///
216 ///
217 /// #### `margin-start`
218 /// Margin on start of widget, horizontally.
219 ///
220 /// This property supports left-to-right and right-to-left text
221 /// directions.
222 ///
223 /// This property adds margin outside of the widget's normal size
224 /// request, the margin will be added in addition to the size from
225 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
226 ///
227 /// Readable | Writeable
228 ///
229 ///
230 /// #### `margin-top`
231 /// Margin on top side of widget.
232 ///
233 /// This property adds margin outside of the widget's normal size
234 /// request, the margin will be added in addition to the size from
235 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
236 ///
237 /// Readable | Writeable
238 ///
239 ///
240 /// #### `name`
241 /// The name of the widget.
242 ///
243 /// Readable | Writeable
244 ///
245 ///
246 /// #### `opacity`
247 /// The requested opacity of the widget.
248 ///
249 /// Readable | Writeable
250 ///
251 ///
252 /// #### `overflow`
253 /// How content outside the widget's content area is treated.
254 ///
255 /// This property is meant to be set by widget implementations,
256 /// typically in their instance init function.
257 ///
258 /// Readable | Writeable
259 ///
260 ///
261 /// #### `parent`
262 /// The parent widget of this widget.
263 ///
264 /// Readable
265 ///
266 ///
267 /// #### `receives-default`
268 /// Whether the widget will receive the default action when it is focused.
269 ///
270 /// Readable | Writeable
271 ///
272 ///
273 /// #### `root`
274 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
275 ///
276 /// This will be `NULL` if the widget is not contained in a root widget.
277 ///
278 /// Readable
279 ///
280 ///
281 /// #### `scale-factor`
282 /// The scale factor of the widget.
283 ///
284 /// Readable
285 ///
286 ///
287 /// #### `sensitive`
288 /// Whether the widget responds to input.
289 ///
290 /// Readable | Writeable
291 ///
292 ///
293 /// #### `tooltip-markup`
294 /// Sets the text of tooltip to be the given string, which is marked up
295 /// with Pango markup.
296 ///
297 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
298 ///
299 /// This is a convenience property which will take care of getting the
300 /// tooltip shown if the given string is not `NULL`:
301 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
302 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
303 /// the default signal handler.
304 ///
305 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
306 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
307 ///
308 /// Readable | Writeable
309 ///
310 ///
311 /// #### `tooltip-text`
312 /// Sets the text of tooltip to be the given string.
313 ///
314 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
315 ///
316 /// This is a convenience property which will take care of getting the
317 /// tooltip shown if the given string is not `NULL`:
318 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
319 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
320 /// the default signal handler.
321 ///
322 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
323 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
324 ///
325 /// Readable | Writeable
326 ///
327 ///
328 /// #### `valign`
329 /// How to distribute vertical space if widget gets extra space.
330 ///
331 /// Readable | Writeable
332 ///
333 ///
334 /// #### `vexpand`
335 /// Whether to expand vertically.
336 ///
337 /// Readable | Writeable
338 ///
339 ///
340 /// #### `vexpand-set`
341 /// Whether to use the `vexpand` property.
342 ///
343 /// Readable | Writeable
344 ///
345 ///
346 /// #### `visible`
347 /// Whether the widget is visible.
348 ///
349 /// Readable | Writeable
350 ///
351 ///
352 /// #### `width-request`
353 /// Overrides for width request of the widget.
354 ///
355 /// If this is -1, the natural request will be used.
356 ///
357 /// Readable | Writeable
358 /// </details>
359 /// <details><summary><h4>Accessible</h4></summary>
360 ///
361 ///
362 /// #### `accessible-role`
363 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
364 ///
365 /// The accessible role cannot be changed once set.
366 ///
367 /// Readable | Writeable
368 /// </details>
369 /// <details><summary><h4>FileChooser</h4></summary>
370 ///
371 ///
372 /// #### `action`
373 /// The type of operation that the file chooser is performing.
374 ///
375 /// Readable | Writeable
376 ///
377 ///
378 /// #### `create-folders`
379 /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
380 /// will offer the user to create new folders.
381 ///
382 /// Readable | Writeable
383 ///
384 ///
385 /// #### `filter`
386 /// The current filter for selecting files that are displayed.
387 ///
388 /// Readable | Writeable
389 ///
390 ///
391 /// #### `filters`
392 /// A `GListModel` containing the filters that have been
393 /// added with gtk_file_chooser_add_filter().
394 ///
395 /// The returned object should not be modified. It may
396 /// or may not be updated for later changes.
397 ///
398 /// Readable
399 ///
400 ///
401 /// #### `select-multiple`
402 /// Whether to allow multiple files to be selected.
403 ///
404 /// Readable | Writeable
405 ///
406 ///
407 /// #### `shortcut-folders`
408 /// A `GListModel` containing the shortcut folders that have been
409 /// added with gtk_file_chooser_add_shortcut_folder().
410 ///
411 /// The returned object should not be modified. It may
412 /// or may not be updated for later changes.
413 ///
414 /// Readable
415 /// </details>
416 ///
417 /// ## Signals
418 ///
419 ///
420 /// #### `desktop-folder`
421 /// Emitted when the user asks for it.
422 ///
423 /// This is a [keybinding signal](class.SignalAction.html).
424 ///
425 /// This is used to make the file chooser show the user's Desktop
426 /// folder in the file list.
427 ///
428 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>D</kbd>.
429 ///
430 /// Action
431 ///
432 ///
433 /// #### `down-folder`
434 /// Emitted when the user asks for it.
435 ///
436 /// This is a [keybinding signal](class.SignalAction.html).
437 ///
438 /// This is used to make the file chooser go to a child of the
439 /// current folder in the file hierarchy. The subfolder that will
440 /// be used is displayed in the path bar widget of the file chooser.
441 /// For example, if the path bar is showing "/foo/bar/baz", with bar
442 /// currently displayed, then this will cause the file chooser to
443 /// switch to the "baz" subfolder.
444 ///
445 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Down</kbd>.
446 ///
447 /// Action
448 ///
449 ///
450 /// #### `home-folder`
451 /// Emitted when the user asks for it.
452 ///
453 /// This is a [keybinding signal](class.SignalAction.html).
454 ///
455 /// This is used to make the file chooser show the user's home
456 /// folder in the file list.
457 ///
458 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Home</kbd>.
459 ///
460 /// Action
461 ///
462 ///
463 /// #### `location-popup`
464 /// Emitted when the user asks for it.
465 ///
466 /// This is a [keybinding signal](class.SignalAction.html).
467 ///
468 /// This is used to make the file chooser show a "Location" prompt which
469 /// the user can use to manually type the name of the file he wishes to select.
470 ///
471 /// The default bindings for this signal are <kbd>Control</kbd>-<kbd>L</kbd>
472 /// with a @path string of "" (the empty string). It is also bound to
473 /// <kbd>/</kbd> with a @path string of "`/`" (a slash): this lets you
474 /// type `/` and immediately type a path name. On Unix systems, this is
475 /// bound to <kbd>~</kbd> (tilde) with a @path string of "~" itself for
476 /// access to home directories.
477 ///
478 /// Action
479 ///
480 ///
481 /// #### `location-popup-on-paste`
482 /// Emitted when the user asks for it.
483 ///
484 /// This is a [keybinding signal](class.SignalAction.html).
485 ///
486 /// This is used to make the file chooser show a "Location" prompt
487 /// when the user pastes into a [`FileChooserWidget`][crate::FileChooserWidget].
488 ///
489 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>V</kbd>.
490 ///
491 /// Action
492 ///
493 ///
494 /// #### `location-toggle-popup`
495 /// Emitted when the user asks for it.
496 ///
497 /// This is a [keybinding signal](class.SignalAction.html).
498 ///
499 /// This is used to toggle the visibility of a "Location" prompt
500 /// which the user can use to manually type the name of the file
501 /// he wishes to select.
502 ///
503 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>L</kbd>.
504 ///
505 /// Action
506 ///
507 ///
508 /// #### `places-shortcut`
509 /// Emitted when the user asks for it.
510 ///
511 /// This is a [keybinding signal](class.SignalAction.html).
512 ///
513 /// This is used to move the focus to the places sidebar.
514 ///
515 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>P</kbd>.
516 ///
517 /// Action
518 ///
519 ///
520 /// #### `quick-bookmark`
521 /// Emitted when the user asks for it.
522 ///
523 /// This is a [keybinding signal](class.SignalAction.html).
524 ///
525 /// This is used to make the file chooser switch to the bookmark
526 /// specified in the @bookmark_index parameter. For example, if
527 /// you have three bookmarks, you can pass 0, 1, 2 to this signal
528 /// to switch to each of them, respectively.
529 ///
530 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>1</kbd>,
531 /// <kbd>Alt</kbd>-<kbd>2</kbd>, etc. until <kbd>Alt</kbd>-<kbd>0</kbd>.
532 /// Note that in the default binding, that <kbd>Alt</kbd>-<kbd>1</kbd> is
533 /// actually defined to switch to the bookmark at index 0, and so on
534 /// successively.
535 ///
536 /// Action
537 ///
538 ///
539 /// #### `recent-shortcut`
540 /// Emitted when the user asks for it.
541 ///
542 /// This is a [keybinding signal](class.SignalAction.html).
543 ///
544 /// This is used to make the file chooser show the Recent location.
545 ///
546 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>R</kbd>.
547 ///
548 /// Action
549 ///
550 ///
551 /// #### `search-shortcut`
552 /// Emitted when the user asks for it.
553 ///
554 /// This is a [keybinding signal](class.SignalAction.html).
555 ///
556 /// This is used to make the file chooser show the search entry.
557 ///
558 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>S</kbd>.
559 ///
560 /// Action
561 ///
562 ///
563 /// #### `show-hidden`
564 /// Emitted when the user asks for it.
565 ///
566 /// This is a [keybinding signal](class.SignalAction.html).
567 ///
568 /// This is used to make the file chooser display hidden files.
569 ///
570 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>H</kbd>.
571 ///
572 /// Action
573 ///
574 ///
575 /// #### `up-folder`
576 /// Emitted when the user asks for it.
577 ///
578 /// This is a [keybinding signal](class.SignalAction.html).
579 ///
580 /// This is used to make the file chooser go to the parent
581 /// of the current folder in the file hierarchy.
582 ///
583 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Up</kbd>.
584 ///
585 /// Action
586 /// <details><summary><h4>Widget</h4></summary>
587 ///
588 ///
589 /// #### `destroy`
590 /// Signals that all holders of a reference to the widget should release
591 /// the reference that they hold.
592 ///
593 /// May result in finalization of the widget if all references are released.
594 ///
595 /// This signal is not suitable for saving widget state.
596 ///
597 ///
598 ///
599 ///
600 /// #### `direction-changed`
601 /// Emitted when the text direction of a widget changes.
602 ///
603 ///
604 ///
605 ///
606 /// #### `hide`
607 /// Emitted when @widget is hidden.
608 ///
609 ///
610 ///
611 ///
612 /// #### `keynav-failed`
613 /// Emitted if keyboard navigation fails.
614 ///
615 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
616 ///
617 ///
618 ///
619 ///
620 /// #### `map`
621 /// Emitted when @widget is going to be mapped.
622 ///
623 /// A widget is mapped when the widget is visible (which is controlled with
624 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
625 /// are also visible.
626 ///
627 /// The `::map` signal can be used to determine whether a widget will be drawn,
628 /// for instance it can resume an animation that was stopped during the
629 /// emission of [`unmap`][struct@crate::Widget#unmap].
630 ///
631 ///
632 ///
633 ///
634 /// #### `mnemonic-activate`
635 /// Emitted when a widget is activated via a mnemonic.
636 ///
637 /// The default handler for this signal activates @widget if @group_cycling
638 /// is false, or just makes @widget grab focus if @group_cycling is true.
639 ///
640 ///
641 ///
642 ///
643 /// #### `move-focus`
644 /// Emitted when the focus is moved.
645 ///
646 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
647 ///
648 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
649 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
650 ///
651 /// Action
652 ///
653 ///
654 /// #### `query-tooltip`
655 /// Emitted when the widget’s tooltip is about to be shown.
656 ///
657 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
658 /// is true and the hover timeout has expired with the cursor hovering
659 /// above @widget; or emitted when @widget got focus in keyboard mode.
660 ///
661 /// Using the given coordinates, the signal handler should determine
662 /// whether a tooltip should be shown for @widget. If this is the case
663 /// true should be returned, false otherwise. Note that if @keyboard_mode
664 /// is true, the values of @x and @y are undefined and should not be used.
665 ///
666 /// The signal handler is free to manipulate @tooltip with the therefore
667 /// destined function calls.
668 ///
669 ///
670 ///
671 ///
672 /// #### `realize`
673 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
674 ///
675 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
676 /// or the widget has been mapped (that is, it is going to be drawn).
677 ///
678 ///
679 ///
680 ///
681 /// #### `show`
682 /// Emitted when @widget is shown.
683 ///
684 ///
685 ///
686 ///
687 /// #### `state-flags-changed`
688 /// Emitted when the widget state changes.
689 ///
690 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
691 ///
692 ///
693 ///
694 ///
695 /// #### `unmap`
696 /// Emitted when @widget is going to be unmapped.
697 ///
698 /// A widget is unmapped when either it or any of its parents up to the
699 /// toplevel widget have been set as hidden.
700 ///
701 /// As `::unmap` indicates that a widget will not be shown any longer,
702 /// it can be used to, for example, stop an animation on the widget.
703 ///
704 ///
705 ///
706 ///
707 /// #### `unrealize`
708 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
709 ///
710 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
711 /// or the widget has been unmapped (that is, it is going to be hidden).
712 ///
713 ///
714 /// </details>
715 ///
716 /// # Implements
717 ///
718 /// [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`FileChooserExt`][trait@crate::prelude::FileChooserExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`FileChooserExtManual`][trait@crate::prelude::FileChooserExtManual]
719 #[doc(alias = "GtkFileChooserWidget")]
720 pub struct FileChooserWidget(Object<ffi::GtkFileChooserWidget>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, FileChooser;
721
722 match fn {
723 type_ => || ffi::gtk_file_chooser_widget_get_type(),
724 }
725}
726
727impl FileChooserWidget {
728 /// Creates a new [`FileChooserWidget`][crate::FileChooserWidget].
729 ///
730 /// This is a file chooser widget that can be embedded in custom
731 /// windows, and it is the same widget that is used by
732 /// [`FileChooserDialog`][crate::FileChooserDialog].
733 ///
734 /// # Deprecated since 4.10
735 ///
736 /// Direct use of [`FileChooserWidget`][crate::FileChooserWidget] is deprecated
737 /// ## `action`
738 /// Open or save mode for the widget
739 ///
740 /// # Returns
741 ///
742 /// a new [`FileChooserWidget`][crate::FileChooserWidget]
743 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
744 #[allow(deprecated)]
745 #[doc(alias = "gtk_file_chooser_widget_new")]
746 pub fn new(action: FileChooserAction) -> FileChooserWidget {
747 assert_initialized_main_thread!();
748 unsafe {
749 Widget::from_glib_none(ffi::gtk_file_chooser_widget_new(action.into_glib()))
750 .unsafe_cast()
751 }
752 }
753
754 // rustdoc-stripper-ignore-next
755 /// Creates a new builder-pattern struct instance to construct [`FileChooserWidget`] objects.
756 ///
757 /// This method returns an instance of [`FileChooserWidgetBuilder`](crate::builders::FileChooserWidgetBuilder) which can be used to create [`FileChooserWidget`] objects.
758 pub fn builder() -> FileChooserWidgetBuilder {
759 FileChooserWidgetBuilder::new()
760 }
761
762 /// Whether search mode is enabled.
763 #[doc(alias = "search-mode")]
764 pub fn is_search_mode(&self) -> bool {
765 ObjectExt::property(self, "search-mode")
766 }
767
768 /// Whether search mode is enabled.
769 #[doc(alias = "search-mode")]
770 pub fn set_search_mode(&self, search_mode: bool) {
771 ObjectExt::set_property(self, "search-mode", search_mode)
772 }
773
774 /// Whether to show the time.
775 #[cfg(feature = "v4_10")]
776 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
777 #[doc(alias = "show-time")]
778 pub fn shows_time(&self) -> bool {
779 ObjectExt::property(self, "show-time")
780 }
781
782 /// The subtitle of the file chooser widget.
783 pub fn subtitle(&self) -> Option<glib::GString> {
784 ObjectExt::property(self, "subtitle")
785 }
786
787 /// Emitted when the user asks for it.
788 ///
789 /// This is a [keybinding signal](class.SignalAction.html).
790 ///
791 /// This is used to make the file chooser show the user's Desktop
792 /// folder in the file list.
793 ///
794 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>D</kbd>.
795 #[doc(alias = "desktop-folder")]
796 pub fn connect_desktop_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
797 unsafe extern "C" fn desktop_folder_trampoline<F: Fn(&FileChooserWidget) + 'static>(
798 this: *mut ffi::GtkFileChooserWidget,
799 f: glib::ffi::gpointer,
800 ) {
801 let f: &F = &*(f as *const F);
802 f(&from_glib_borrow(this))
803 }
804 unsafe {
805 let f: Box_<F> = Box_::new(f);
806 connect_raw(
807 self.as_ptr() as *mut _,
808 b"desktop-folder\0".as_ptr() as *const _,
809 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
810 desktop_folder_trampoline::<F> as *const (),
811 )),
812 Box_::into_raw(f),
813 )
814 }
815 }
816
817 pub fn emit_desktop_folder(&self) {
818 self.emit_by_name::<()>("desktop-folder", &[]);
819 }
820
821 /// Emitted when the user asks for it.
822 ///
823 /// This is a [keybinding signal](class.SignalAction.html).
824 ///
825 /// This is used to make the file chooser go to a child of the
826 /// current folder in the file hierarchy. The subfolder that will
827 /// be used is displayed in the path bar widget of the file chooser.
828 /// For example, if the path bar is showing "/foo/bar/baz", with bar
829 /// currently displayed, then this will cause the file chooser to
830 /// switch to the "baz" subfolder.
831 ///
832 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Down</kbd>.
833 #[doc(alias = "down-folder")]
834 pub fn connect_down_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
835 unsafe extern "C" fn down_folder_trampoline<F: Fn(&FileChooserWidget) + 'static>(
836 this: *mut ffi::GtkFileChooserWidget,
837 f: glib::ffi::gpointer,
838 ) {
839 let f: &F = &*(f as *const F);
840 f(&from_glib_borrow(this))
841 }
842 unsafe {
843 let f: Box_<F> = Box_::new(f);
844 connect_raw(
845 self.as_ptr() as *mut _,
846 b"down-folder\0".as_ptr() as *const _,
847 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
848 down_folder_trampoline::<F> as *const (),
849 )),
850 Box_::into_raw(f),
851 )
852 }
853 }
854
855 pub fn emit_down_folder(&self) {
856 self.emit_by_name::<()>("down-folder", &[]);
857 }
858
859 /// Emitted when the user asks for it.
860 ///
861 /// This is a [keybinding signal](class.SignalAction.html).
862 ///
863 /// This is used to make the file chooser show the user's home
864 /// folder in the file list.
865 ///
866 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Home</kbd>.
867 #[doc(alias = "home-folder")]
868 pub fn connect_home_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
869 unsafe extern "C" fn home_folder_trampoline<F: Fn(&FileChooserWidget) + 'static>(
870 this: *mut ffi::GtkFileChooserWidget,
871 f: glib::ffi::gpointer,
872 ) {
873 let f: &F = &*(f as *const F);
874 f(&from_glib_borrow(this))
875 }
876 unsafe {
877 let f: Box_<F> = Box_::new(f);
878 connect_raw(
879 self.as_ptr() as *mut _,
880 b"home-folder\0".as_ptr() as *const _,
881 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
882 home_folder_trampoline::<F> as *const (),
883 )),
884 Box_::into_raw(f),
885 )
886 }
887 }
888
889 pub fn emit_home_folder(&self) {
890 self.emit_by_name::<()>("home-folder", &[]);
891 }
892
893 /// Emitted when the user asks for it.
894 ///
895 /// This is a [keybinding signal](class.SignalAction.html).
896 ///
897 /// This is used to make the file chooser show a "Location" prompt which
898 /// the user can use to manually type the name of the file he wishes to select.
899 ///
900 /// The default bindings for this signal are <kbd>Control</kbd>-<kbd>L</kbd>
901 /// with a @path string of "" (the empty string). It is also bound to
902 /// <kbd>/</kbd> with a @path string of "`/`" (a slash): this lets you
903 /// type `/` and immediately type a path name. On Unix systems, this is
904 /// bound to <kbd>~</kbd> (tilde) with a @path string of "~" itself for
905 /// access to home directories.
906 /// ## `path`
907 /// a string that gets put in the text entry for the file name
908 #[doc(alias = "location-popup")]
909 pub fn connect_location_popup<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
910 unsafe extern "C" fn location_popup_trampoline<
911 F: Fn(&FileChooserWidget, &str) + 'static,
912 >(
913 this: *mut ffi::GtkFileChooserWidget,
914 path: *mut std::ffi::c_char,
915 f: glib::ffi::gpointer,
916 ) {
917 let f: &F = &*(f as *const F);
918 f(
919 &from_glib_borrow(this),
920 &glib::GString::from_glib_borrow(path),
921 )
922 }
923 unsafe {
924 let f: Box_<F> = Box_::new(f);
925 connect_raw(
926 self.as_ptr() as *mut _,
927 b"location-popup\0".as_ptr() as *const _,
928 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
929 location_popup_trampoline::<F> as *const (),
930 )),
931 Box_::into_raw(f),
932 )
933 }
934 }
935
936 pub fn emit_location_popup(&self, path: &str) {
937 self.emit_by_name::<()>("location-popup", &[&path]);
938 }
939
940 /// Emitted when the user asks for it.
941 ///
942 /// This is a [keybinding signal](class.SignalAction.html).
943 ///
944 /// This is used to make the file chooser show a "Location" prompt
945 /// when the user pastes into a [`FileChooserWidget`][crate::FileChooserWidget].
946 ///
947 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>V</kbd>.
948 #[doc(alias = "location-popup-on-paste")]
949 pub fn connect_location_popup_on_paste<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
950 unsafe extern "C" fn location_popup_on_paste_trampoline<
951 F: Fn(&FileChooserWidget) + 'static,
952 >(
953 this: *mut ffi::GtkFileChooserWidget,
954 f: glib::ffi::gpointer,
955 ) {
956 let f: &F = &*(f as *const F);
957 f(&from_glib_borrow(this))
958 }
959 unsafe {
960 let f: Box_<F> = Box_::new(f);
961 connect_raw(
962 self.as_ptr() as *mut _,
963 b"location-popup-on-paste\0".as_ptr() as *const _,
964 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
965 location_popup_on_paste_trampoline::<F> as *const (),
966 )),
967 Box_::into_raw(f),
968 )
969 }
970 }
971
972 pub fn emit_location_popup_on_paste(&self) {
973 self.emit_by_name::<()>("location-popup-on-paste", &[]);
974 }
975
976 /// Emitted when the user asks for it.
977 ///
978 /// This is a [keybinding signal](class.SignalAction.html).
979 ///
980 /// This is used to toggle the visibility of a "Location" prompt
981 /// which the user can use to manually type the name of the file
982 /// he wishes to select.
983 ///
984 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>L</kbd>.
985 #[doc(alias = "location-toggle-popup")]
986 pub fn connect_location_toggle_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
987 unsafe extern "C" fn location_toggle_popup_trampoline<
988 F: Fn(&FileChooserWidget) + 'static,
989 >(
990 this: *mut ffi::GtkFileChooserWidget,
991 f: glib::ffi::gpointer,
992 ) {
993 let f: &F = &*(f as *const F);
994 f(&from_glib_borrow(this))
995 }
996 unsafe {
997 let f: Box_<F> = Box_::new(f);
998 connect_raw(
999 self.as_ptr() as *mut _,
1000 b"location-toggle-popup\0".as_ptr() as *const _,
1001 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1002 location_toggle_popup_trampoline::<F> as *const (),
1003 )),
1004 Box_::into_raw(f),
1005 )
1006 }
1007 }
1008
1009 pub fn emit_location_toggle_popup(&self) {
1010 self.emit_by_name::<()>("location-toggle-popup", &[]);
1011 }
1012
1013 /// Emitted when the user asks for it.
1014 ///
1015 /// This is a [keybinding signal](class.SignalAction.html).
1016 ///
1017 /// This is used to move the focus to the places sidebar.
1018 ///
1019 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>P</kbd>.
1020 #[doc(alias = "places-shortcut")]
1021 pub fn connect_places_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1022 unsafe extern "C" fn places_shortcut_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1023 this: *mut ffi::GtkFileChooserWidget,
1024 f: glib::ffi::gpointer,
1025 ) {
1026 let f: &F = &*(f as *const F);
1027 f(&from_glib_borrow(this))
1028 }
1029 unsafe {
1030 let f: Box_<F> = Box_::new(f);
1031 connect_raw(
1032 self.as_ptr() as *mut _,
1033 b"places-shortcut\0".as_ptr() as *const _,
1034 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1035 places_shortcut_trampoline::<F> as *const (),
1036 )),
1037 Box_::into_raw(f),
1038 )
1039 }
1040 }
1041
1042 pub fn emit_places_shortcut(&self) {
1043 self.emit_by_name::<()>("places-shortcut", &[]);
1044 }
1045
1046 /// Emitted when the user asks for it.
1047 ///
1048 /// This is a [keybinding signal](class.SignalAction.html).
1049 ///
1050 /// This is used to make the file chooser switch to the bookmark
1051 /// specified in the @bookmark_index parameter. For example, if
1052 /// you have three bookmarks, you can pass 0, 1, 2 to this signal
1053 /// to switch to each of them, respectively.
1054 ///
1055 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>1</kbd>,
1056 /// <kbd>Alt</kbd>-<kbd>2</kbd>, etc. until <kbd>Alt</kbd>-<kbd>0</kbd>.
1057 /// Note that in the default binding, that <kbd>Alt</kbd>-<kbd>1</kbd> is
1058 /// actually defined to switch to the bookmark at index 0, and so on
1059 /// successively.
1060 /// ## `bookmark_index`
1061 /// the number of the bookmark to switch to
1062 #[doc(alias = "quick-bookmark")]
1063 pub fn connect_quick_bookmark<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
1064 unsafe extern "C" fn quick_bookmark_trampoline<F: Fn(&FileChooserWidget, i32) + 'static>(
1065 this: *mut ffi::GtkFileChooserWidget,
1066 bookmark_index: std::ffi::c_int,
1067 f: glib::ffi::gpointer,
1068 ) {
1069 let f: &F = &*(f as *const F);
1070 f(&from_glib_borrow(this), bookmark_index)
1071 }
1072 unsafe {
1073 let f: Box_<F> = Box_::new(f);
1074 connect_raw(
1075 self.as_ptr() as *mut _,
1076 b"quick-bookmark\0".as_ptr() as *const _,
1077 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1078 quick_bookmark_trampoline::<F> as *const (),
1079 )),
1080 Box_::into_raw(f),
1081 )
1082 }
1083 }
1084
1085 pub fn emit_quick_bookmark(&self, bookmark_index: i32) {
1086 self.emit_by_name::<()>("quick-bookmark", &[&bookmark_index]);
1087 }
1088
1089 /// Emitted when the user asks for it.
1090 ///
1091 /// This is a [keybinding signal](class.SignalAction.html).
1092 ///
1093 /// This is used to make the file chooser show the Recent location.
1094 ///
1095 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>R</kbd>.
1096 #[doc(alias = "recent-shortcut")]
1097 pub fn connect_recent_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1098 unsafe extern "C" fn recent_shortcut_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1099 this: *mut ffi::GtkFileChooserWidget,
1100 f: glib::ffi::gpointer,
1101 ) {
1102 let f: &F = &*(f as *const F);
1103 f(&from_glib_borrow(this))
1104 }
1105 unsafe {
1106 let f: Box_<F> = Box_::new(f);
1107 connect_raw(
1108 self.as_ptr() as *mut _,
1109 b"recent-shortcut\0".as_ptr() as *const _,
1110 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1111 recent_shortcut_trampoline::<F> as *const (),
1112 )),
1113 Box_::into_raw(f),
1114 )
1115 }
1116 }
1117
1118 pub fn emit_recent_shortcut(&self) {
1119 self.emit_by_name::<()>("recent-shortcut", &[]);
1120 }
1121
1122 /// Emitted when the user asks for it.
1123 ///
1124 /// This is a [keybinding signal](class.SignalAction.html).
1125 ///
1126 /// This is used to make the file chooser show the search entry.
1127 ///
1128 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>S</kbd>.
1129 #[doc(alias = "search-shortcut")]
1130 pub fn connect_search_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1131 unsafe extern "C" fn search_shortcut_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1132 this: *mut ffi::GtkFileChooserWidget,
1133 f: glib::ffi::gpointer,
1134 ) {
1135 let f: &F = &*(f as *const F);
1136 f(&from_glib_borrow(this))
1137 }
1138 unsafe {
1139 let f: Box_<F> = Box_::new(f);
1140 connect_raw(
1141 self.as_ptr() as *mut _,
1142 b"search-shortcut\0".as_ptr() as *const _,
1143 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1144 search_shortcut_trampoline::<F> as *const (),
1145 )),
1146 Box_::into_raw(f),
1147 )
1148 }
1149 }
1150
1151 pub fn emit_search_shortcut(&self) {
1152 self.emit_by_name::<()>("search-shortcut", &[]);
1153 }
1154
1155 /// Emitted when the user asks for it.
1156 ///
1157 /// This is a [keybinding signal](class.SignalAction.html).
1158 ///
1159 /// This is used to make the file chooser display hidden files.
1160 ///
1161 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>H</kbd>.
1162 #[doc(alias = "show-hidden")]
1163 pub fn connect_show_hidden<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1164 unsafe extern "C" fn show_hidden_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1165 this: *mut ffi::GtkFileChooserWidget,
1166 f: glib::ffi::gpointer,
1167 ) {
1168 let f: &F = &*(f as *const F);
1169 f(&from_glib_borrow(this))
1170 }
1171 unsafe {
1172 let f: Box_<F> = Box_::new(f);
1173 connect_raw(
1174 self.as_ptr() as *mut _,
1175 b"show-hidden\0".as_ptr() as *const _,
1176 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1177 show_hidden_trampoline::<F> as *const (),
1178 )),
1179 Box_::into_raw(f),
1180 )
1181 }
1182 }
1183
1184 pub fn emit_show_hidden(&self) {
1185 self.emit_by_name::<()>("show-hidden", &[]);
1186 }
1187
1188 /// Emitted when the user asks for it.
1189 ///
1190 /// This is a [keybinding signal](class.SignalAction.html).
1191 ///
1192 /// This is used to make the file chooser go to the parent
1193 /// of the current folder in the file hierarchy.
1194 ///
1195 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Up</kbd>.
1196 #[doc(alias = "up-folder")]
1197 pub fn connect_up_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1198 unsafe extern "C" fn up_folder_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1199 this: *mut ffi::GtkFileChooserWidget,
1200 f: glib::ffi::gpointer,
1201 ) {
1202 let f: &F = &*(f as *const F);
1203 f(&from_glib_borrow(this))
1204 }
1205 unsafe {
1206 let f: Box_<F> = Box_::new(f);
1207 connect_raw(
1208 self.as_ptr() as *mut _,
1209 b"up-folder\0".as_ptr() as *const _,
1210 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1211 up_folder_trampoline::<F> as *const (),
1212 )),
1213 Box_::into_raw(f),
1214 )
1215 }
1216 }
1217
1218 pub fn emit_up_folder(&self) {
1219 self.emit_by_name::<()>("up-folder", &[]);
1220 }
1221
1222 #[doc(alias = "search-mode")]
1223 pub fn connect_search_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1224 unsafe extern "C" fn notify_search_mode_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1225 this: *mut ffi::GtkFileChooserWidget,
1226 _param_spec: glib::ffi::gpointer,
1227 f: glib::ffi::gpointer,
1228 ) {
1229 let f: &F = &*(f as *const F);
1230 f(&from_glib_borrow(this))
1231 }
1232 unsafe {
1233 let f: Box_<F> = Box_::new(f);
1234 connect_raw(
1235 self.as_ptr() as *mut _,
1236 b"notify::search-mode\0".as_ptr() as *const _,
1237 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1238 notify_search_mode_trampoline::<F> as *const (),
1239 )),
1240 Box_::into_raw(f),
1241 )
1242 }
1243 }
1244
1245 #[cfg(feature = "v4_10")]
1246 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
1247 #[doc(alias = "show-time")]
1248 pub fn connect_show_time_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1249 unsafe extern "C" fn notify_show_time_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1250 this: *mut ffi::GtkFileChooserWidget,
1251 _param_spec: glib::ffi::gpointer,
1252 f: glib::ffi::gpointer,
1253 ) {
1254 let f: &F = &*(f as *const F);
1255 f(&from_glib_borrow(this))
1256 }
1257 unsafe {
1258 let f: Box_<F> = Box_::new(f);
1259 connect_raw(
1260 self.as_ptr() as *mut _,
1261 b"notify::show-time\0".as_ptr() as *const _,
1262 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1263 notify_show_time_trampoline::<F> as *const (),
1264 )),
1265 Box_::into_raw(f),
1266 )
1267 }
1268 }
1269
1270 #[doc(alias = "subtitle")]
1271 pub fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1272 unsafe extern "C" fn notify_subtitle_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1273 this: *mut ffi::GtkFileChooserWidget,
1274 _param_spec: glib::ffi::gpointer,
1275 f: glib::ffi::gpointer,
1276 ) {
1277 let f: &F = &*(f as *const F);
1278 f(&from_glib_borrow(this))
1279 }
1280 unsafe {
1281 let f: Box_<F> = Box_::new(f);
1282 connect_raw(
1283 self.as_ptr() as *mut _,
1284 b"notify::subtitle\0".as_ptr() as *const _,
1285 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1286 notify_subtitle_trampoline::<F> as *const (),
1287 )),
1288 Box_::into_raw(f),
1289 )
1290 }
1291 }
1292}
1293
1294impl Default for FileChooserWidget {
1295 fn default() -> Self {
1296 glib::object::Object::new::<Self>()
1297 }
1298}
1299
1300// rustdoc-stripper-ignore-next
1301/// A [builder-pattern] type to construct [`FileChooserWidget`] objects.
1302///
1303/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1304#[must_use = "The builder must be built to be used"]
1305pub struct FileChooserWidgetBuilder {
1306 builder: glib::object::ObjectBuilder<'static, FileChooserWidget>,
1307}
1308
1309impl FileChooserWidgetBuilder {
1310 fn new() -> Self {
1311 Self {
1312 builder: glib::object::Object::builder(),
1313 }
1314 }
1315
1316 /// Whether search mode is enabled.
1317 pub fn search_mode(self, search_mode: bool) -> Self {
1318 Self {
1319 builder: self.builder.property("search-mode", search_mode),
1320 }
1321 }
1322
1323 /// Whether the widget or any of its descendents can accept
1324 /// the input focus.
1325 ///
1326 /// This property is meant to be set by widget implementations,
1327 /// typically in their instance init function.
1328 pub fn can_focus(self, can_focus: bool) -> Self {
1329 Self {
1330 builder: self.builder.property("can-focus", can_focus),
1331 }
1332 }
1333
1334 /// Whether the widget can receive pointer events.
1335 pub fn can_target(self, can_target: bool) -> Self {
1336 Self {
1337 builder: self.builder.property("can-target", can_target),
1338 }
1339 }
1340
1341 /// A list of css classes applied to this widget.
1342 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1343 Self {
1344 builder: self.builder.property("css-classes", css_classes.into()),
1345 }
1346 }
1347
1348 /// The name of this widget in the CSS tree.
1349 ///
1350 /// This property is meant to be set by widget implementations,
1351 /// typically in their instance init function.
1352 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1353 Self {
1354 builder: self.builder.property("css-name", css_name.into()),
1355 }
1356 }
1357
1358 /// The cursor used by @widget.
1359 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1360 Self {
1361 builder: self.builder.property("cursor", cursor.clone()),
1362 }
1363 }
1364
1365 /// Whether the widget should grab focus when it is clicked with the mouse.
1366 ///
1367 /// This property is only relevant for widgets that can take focus.
1368 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1369 Self {
1370 builder: self.builder.property("focus-on-click", focus_on_click),
1371 }
1372 }
1373
1374 /// Whether this widget itself will accept the input focus.
1375 pub fn focusable(self, focusable: bool) -> Self {
1376 Self {
1377 builder: self.builder.property("focusable", focusable),
1378 }
1379 }
1380
1381 /// How to distribute horizontal space if widget gets extra space.
1382 pub fn halign(self, halign: Align) -> Self {
1383 Self {
1384 builder: self.builder.property("halign", halign),
1385 }
1386 }
1387
1388 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1389 /// signal on @widget.
1390 ///
1391 /// A true value indicates that @widget can have a tooltip, in this case
1392 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1393 /// determine whether it will provide a tooltip or not.
1394 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1395 Self {
1396 builder: self.builder.property("has-tooltip", has_tooltip),
1397 }
1398 }
1399
1400 /// Overrides for height request of the widget.
1401 ///
1402 /// If this is -1, the natural request will be used.
1403 pub fn height_request(self, height_request: i32) -> Self {
1404 Self {
1405 builder: self.builder.property("height-request", height_request),
1406 }
1407 }
1408
1409 /// Whether to expand horizontally.
1410 pub fn hexpand(self, hexpand: bool) -> Self {
1411 Self {
1412 builder: self.builder.property("hexpand", hexpand),
1413 }
1414 }
1415
1416 /// Whether to use the `hexpand` property.
1417 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1418 Self {
1419 builder: self.builder.property("hexpand-set", hexpand_set),
1420 }
1421 }
1422
1423 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1424 /// the preferred size of the widget, and allocate its children.
1425 ///
1426 /// This property is meant to be set by widget implementations,
1427 /// typically in their instance init function.
1428 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1429 Self {
1430 builder: self
1431 .builder
1432 .property("layout-manager", layout_manager.clone().upcast()),
1433 }
1434 }
1435
1436 /// Makes this widget act like a modal dialog, with respect to
1437 /// event delivery.
1438 ///
1439 /// Global event controllers will not handle events with targets
1440 /// inside the widget, unless they are set up to ignore propagation
1441 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1442 #[cfg(feature = "v4_18")]
1443 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1444 pub fn limit_events(self, limit_events: bool) -> Self {
1445 Self {
1446 builder: self.builder.property("limit-events", limit_events),
1447 }
1448 }
1449
1450 /// Margin on bottom side of widget.
1451 ///
1452 /// This property adds margin outside of the widget's normal size
1453 /// request, the margin will be added in addition to the size from
1454 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1455 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1456 Self {
1457 builder: self.builder.property("margin-bottom", margin_bottom),
1458 }
1459 }
1460
1461 /// Margin on end of widget, horizontally.
1462 ///
1463 /// This property supports left-to-right and right-to-left text
1464 /// directions.
1465 ///
1466 /// This property adds margin outside of the widget's normal size
1467 /// request, the margin will be added in addition to the size from
1468 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1469 pub fn margin_end(self, margin_end: i32) -> Self {
1470 Self {
1471 builder: self.builder.property("margin-end", margin_end),
1472 }
1473 }
1474
1475 /// Margin on start of widget, horizontally.
1476 ///
1477 /// This property supports left-to-right and right-to-left text
1478 /// directions.
1479 ///
1480 /// This property adds margin outside of the widget's normal size
1481 /// request, the margin will be added in addition to the size from
1482 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1483 pub fn margin_start(self, margin_start: i32) -> Self {
1484 Self {
1485 builder: self.builder.property("margin-start", margin_start),
1486 }
1487 }
1488
1489 /// Margin on top side of widget.
1490 ///
1491 /// This property adds margin outside of the widget's normal size
1492 /// request, the margin will be added in addition to the size from
1493 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1494 pub fn margin_top(self, margin_top: i32) -> Self {
1495 Self {
1496 builder: self.builder.property("margin-top", margin_top),
1497 }
1498 }
1499
1500 /// The name of the widget.
1501 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1502 Self {
1503 builder: self.builder.property("name", name.into()),
1504 }
1505 }
1506
1507 /// The requested opacity of the widget.
1508 pub fn opacity(self, opacity: f64) -> Self {
1509 Self {
1510 builder: self.builder.property("opacity", opacity),
1511 }
1512 }
1513
1514 /// How content outside the widget's content area is treated.
1515 ///
1516 /// This property is meant to be set by widget implementations,
1517 /// typically in their instance init function.
1518 pub fn overflow(self, overflow: Overflow) -> Self {
1519 Self {
1520 builder: self.builder.property("overflow", overflow),
1521 }
1522 }
1523
1524 /// Whether the widget will receive the default action when it is focused.
1525 pub fn receives_default(self, receives_default: bool) -> Self {
1526 Self {
1527 builder: self.builder.property("receives-default", receives_default),
1528 }
1529 }
1530
1531 /// Whether the widget responds to input.
1532 pub fn sensitive(self, sensitive: bool) -> Self {
1533 Self {
1534 builder: self.builder.property("sensitive", sensitive),
1535 }
1536 }
1537
1538 /// Sets the text of tooltip to be the given string, which is marked up
1539 /// with Pango markup.
1540 ///
1541 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1542 ///
1543 /// This is a convenience property which will take care of getting the
1544 /// tooltip shown if the given string is not `NULL`:
1545 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1546 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1547 /// the default signal handler.
1548 ///
1549 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1550 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1551 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1552 Self {
1553 builder: self
1554 .builder
1555 .property("tooltip-markup", tooltip_markup.into()),
1556 }
1557 }
1558
1559 /// Sets the text of tooltip to be the given string.
1560 ///
1561 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1562 ///
1563 /// This is a convenience property which will take care of getting the
1564 /// tooltip shown if the given string is not `NULL`:
1565 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1566 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1567 /// the default signal handler.
1568 ///
1569 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1570 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1571 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1572 Self {
1573 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1574 }
1575 }
1576
1577 /// How to distribute vertical space if widget gets extra space.
1578 pub fn valign(self, valign: Align) -> Self {
1579 Self {
1580 builder: self.builder.property("valign", valign),
1581 }
1582 }
1583
1584 /// Whether to expand vertically.
1585 pub fn vexpand(self, vexpand: bool) -> Self {
1586 Self {
1587 builder: self.builder.property("vexpand", vexpand),
1588 }
1589 }
1590
1591 /// Whether to use the `vexpand` property.
1592 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1593 Self {
1594 builder: self.builder.property("vexpand-set", vexpand_set),
1595 }
1596 }
1597
1598 /// Whether the widget is visible.
1599 pub fn visible(self, visible: bool) -> Self {
1600 Self {
1601 builder: self.builder.property("visible", visible),
1602 }
1603 }
1604
1605 /// Overrides for width request of the widget.
1606 ///
1607 /// If this is -1, the natural request will be used.
1608 pub fn width_request(self, width_request: i32) -> Self {
1609 Self {
1610 builder: self.builder.property("width-request", width_request),
1611 }
1612 }
1613
1614 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1615 ///
1616 /// The accessible role cannot be changed once set.
1617 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1618 Self {
1619 builder: self.builder.property("accessible-role", accessible_role),
1620 }
1621 }
1622
1623 /// The type of operation that the file chooser is performing.
1624 /// Use [`FileDialog`][crate::FileDialog] instead
1625 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1626 pub fn action(self, action: FileChooserAction) -> Self {
1627 Self {
1628 builder: self.builder.property("action", action),
1629 }
1630 }
1631
1632 /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
1633 /// will offer the user to create new folders.
1634 /// Use [`FileDialog`][crate::FileDialog] instead
1635 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1636 pub fn create_folders(self, create_folders: bool) -> Self {
1637 Self {
1638 builder: self.builder.property("create-folders", create_folders),
1639 }
1640 }
1641
1642 /// The current filter for selecting files that are displayed.
1643 /// Use [`FileDialog`][crate::FileDialog] instead
1644 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1645 pub fn filter(self, filter: &FileFilter) -> Self {
1646 Self {
1647 builder: self.builder.property("filter", filter.clone()),
1648 }
1649 }
1650
1651 /// Whether to allow multiple files to be selected.
1652 /// Use [`FileDialog`][crate::FileDialog] instead
1653 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1654 pub fn select_multiple(self, select_multiple: bool) -> Self {
1655 Self {
1656 builder: self.builder.property("select-multiple", select_multiple),
1657 }
1658 }
1659
1660 // rustdoc-stripper-ignore-next
1661 /// Build the [`FileChooserWidget`].
1662 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1663 pub fn build(self) -> FileChooserWidget {
1664 assert_initialized_main_thread!();
1665 self.builder.build()
1666 }
1667}