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 Accessible, AccessibleRole, Align, Buildable, ConstraintTarget, FileChooser, FileChooserAction,
8 FileFilter, LayoutManager, Overflow, Widget, ffi,
9};
10use glib::{
11 object::ObjectType as _,
12 prelude::*,
13 signal::{SignalHandlerId, connect_raw},
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 unsafe {
802 let f: &F = &*(f as *const F);
803 f(&from_glib_borrow(this))
804 }
805 }
806 unsafe {
807 let f: Box_<F> = Box_::new(f);
808 connect_raw(
809 self.as_ptr() as *mut _,
810 c"desktop-folder".as_ptr() as *const _,
811 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
812 desktop_folder_trampoline::<F> as *const (),
813 )),
814 Box_::into_raw(f),
815 )
816 }
817 }
818
819 pub fn emit_desktop_folder(&self) {
820 self.emit_by_name::<()>("desktop-folder", &[]);
821 }
822
823 /// Emitted when the user asks for it.
824 ///
825 /// This is a [keybinding signal](class.SignalAction.html).
826 ///
827 /// This is used to make the file chooser go to a child of the
828 /// current folder in the file hierarchy. The subfolder that will
829 /// be used is displayed in the path bar widget of the file chooser.
830 /// For example, if the path bar is showing "/foo/bar/baz", with bar
831 /// currently displayed, then this will cause the file chooser to
832 /// switch to the "baz" subfolder.
833 ///
834 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Down</kbd>.
835 #[doc(alias = "down-folder")]
836 pub fn connect_down_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
837 unsafe extern "C" fn down_folder_trampoline<F: Fn(&FileChooserWidget) + 'static>(
838 this: *mut ffi::GtkFileChooserWidget,
839 f: glib::ffi::gpointer,
840 ) {
841 unsafe {
842 let f: &F = &*(f as *const F);
843 f(&from_glib_borrow(this))
844 }
845 }
846 unsafe {
847 let f: Box_<F> = Box_::new(f);
848 connect_raw(
849 self.as_ptr() as *mut _,
850 c"down-folder".as_ptr() as *const _,
851 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
852 down_folder_trampoline::<F> as *const (),
853 )),
854 Box_::into_raw(f),
855 )
856 }
857 }
858
859 pub fn emit_down_folder(&self) {
860 self.emit_by_name::<()>("down-folder", &[]);
861 }
862
863 /// Emitted when the user asks for it.
864 ///
865 /// This is a [keybinding signal](class.SignalAction.html).
866 ///
867 /// This is used to make the file chooser show the user's home
868 /// folder in the file list.
869 ///
870 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Home</kbd>.
871 #[doc(alias = "home-folder")]
872 pub fn connect_home_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
873 unsafe extern "C" fn home_folder_trampoline<F: Fn(&FileChooserWidget) + 'static>(
874 this: *mut ffi::GtkFileChooserWidget,
875 f: glib::ffi::gpointer,
876 ) {
877 unsafe {
878 let f: &F = &*(f as *const F);
879 f(&from_glib_borrow(this))
880 }
881 }
882 unsafe {
883 let f: Box_<F> = Box_::new(f);
884 connect_raw(
885 self.as_ptr() as *mut _,
886 c"home-folder".as_ptr() as *const _,
887 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
888 home_folder_trampoline::<F> as *const (),
889 )),
890 Box_::into_raw(f),
891 )
892 }
893 }
894
895 pub fn emit_home_folder(&self) {
896 self.emit_by_name::<()>("home-folder", &[]);
897 }
898
899 /// Emitted when the user asks for it.
900 ///
901 /// This is a [keybinding signal](class.SignalAction.html).
902 ///
903 /// This is used to make the file chooser show a "Location" prompt which
904 /// the user can use to manually type the name of the file he wishes to select.
905 ///
906 /// The default bindings for this signal are <kbd>Control</kbd>-<kbd>L</kbd>
907 /// with a @path string of "" (the empty string). It is also bound to
908 /// <kbd>/</kbd> with a @path string of "`/`" (a slash): this lets you
909 /// type `/` and immediately type a path name. On Unix systems, this is
910 /// bound to <kbd>~</kbd> (tilde) with a @path string of "~" itself for
911 /// access to home directories.
912 /// ## `path`
913 /// a string that gets put in the text entry for the file name
914 #[doc(alias = "location-popup")]
915 pub fn connect_location_popup<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
916 unsafe extern "C" fn location_popup_trampoline<
917 F: Fn(&FileChooserWidget, &str) + 'static,
918 >(
919 this: *mut ffi::GtkFileChooserWidget,
920 path: *mut std::ffi::c_char,
921 f: glib::ffi::gpointer,
922 ) {
923 unsafe {
924 let f: &F = &*(f as *const F);
925 f(
926 &from_glib_borrow(this),
927 &glib::GString::from_glib_borrow(path),
928 )
929 }
930 }
931 unsafe {
932 let f: Box_<F> = Box_::new(f);
933 connect_raw(
934 self.as_ptr() as *mut _,
935 c"location-popup".as_ptr() as *const _,
936 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
937 location_popup_trampoline::<F> as *const (),
938 )),
939 Box_::into_raw(f),
940 )
941 }
942 }
943
944 pub fn emit_location_popup(&self, path: &str) {
945 self.emit_by_name::<()>("location-popup", &[&path]);
946 }
947
948 /// Emitted when the user asks for it.
949 ///
950 /// This is a [keybinding signal](class.SignalAction.html).
951 ///
952 /// This is used to make the file chooser show a "Location" prompt
953 /// when the user pastes into a [`FileChooserWidget`][crate::FileChooserWidget].
954 ///
955 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>V</kbd>.
956 #[doc(alias = "location-popup-on-paste")]
957 pub fn connect_location_popup_on_paste<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
958 unsafe extern "C" fn location_popup_on_paste_trampoline<
959 F: Fn(&FileChooserWidget) + 'static,
960 >(
961 this: *mut ffi::GtkFileChooserWidget,
962 f: glib::ffi::gpointer,
963 ) {
964 unsafe {
965 let f: &F = &*(f as *const F);
966 f(&from_glib_borrow(this))
967 }
968 }
969 unsafe {
970 let f: Box_<F> = Box_::new(f);
971 connect_raw(
972 self.as_ptr() as *mut _,
973 c"location-popup-on-paste".as_ptr() as *const _,
974 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
975 location_popup_on_paste_trampoline::<F> as *const (),
976 )),
977 Box_::into_raw(f),
978 )
979 }
980 }
981
982 pub fn emit_location_popup_on_paste(&self) {
983 self.emit_by_name::<()>("location-popup-on-paste", &[]);
984 }
985
986 /// Emitted when the user asks for it.
987 ///
988 /// This is a [keybinding signal](class.SignalAction.html).
989 ///
990 /// This is used to toggle the visibility of a "Location" prompt
991 /// which the user can use to manually type the name of the file
992 /// he wishes to select.
993 ///
994 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>L</kbd>.
995 #[doc(alias = "location-toggle-popup")]
996 pub fn connect_location_toggle_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
997 unsafe extern "C" fn location_toggle_popup_trampoline<
998 F: Fn(&FileChooserWidget) + 'static,
999 >(
1000 this: *mut ffi::GtkFileChooserWidget,
1001 f: glib::ffi::gpointer,
1002 ) {
1003 unsafe {
1004 let f: &F = &*(f as *const F);
1005 f(&from_glib_borrow(this))
1006 }
1007 }
1008 unsafe {
1009 let f: Box_<F> = Box_::new(f);
1010 connect_raw(
1011 self.as_ptr() as *mut _,
1012 c"location-toggle-popup".as_ptr() as *const _,
1013 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1014 location_toggle_popup_trampoline::<F> as *const (),
1015 )),
1016 Box_::into_raw(f),
1017 )
1018 }
1019 }
1020
1021 pub fn emit_location_toggle_popup(&self) {
1022 self.emit_by_name::<()>("location-toggle-popup", &[]);
1023 }
1024
1025 /// Emitted when the user asks for it.
1026 ///
1027 /// This is a [keybinding signal](class.SignalAction.html).
1028 ///
1029 /// This is used to move the focus to the places sidebar.
1030 ///
1031 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>P</kbd>.
1032 #[doc(alias = "places-shortcut")]
1033 pub fn connect_places_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1034 unsafe extern "C" fn places_shortcut_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1035 this: *mut ffi::GtkFileChooserWidget,
1036 f: glib::ffi::gpointer,
1037 ) {
1038 unsafe {
1039 let f: &F = &*(f as *const F);
1040 f(&from_glib_borrow(this))
1041 }
1042 }
1043 unsafe {
1044 let f: Box_<F> = Box_::new(f);
1045 connect_raw(
1046 self.as_ptr() as *mut _,
1047 c"places-shortcut".as_ptr() as *const _,
1048 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1049 places_shortcut_trampoline::<F> as *const (),
1050 )),
1051 Box_::into_raw(f),
1052 )
1053 }
1054 }
1055
1056 pub fn emit_places_shortcut(&self) {
1057 self.emit_by_name::<()>("places-shortcut", &[]);
1058 }
1059
1060 /// Emitted when the user asks for it.
1061 ///
1062 /// This is a [keybinding signal](class.SignalAction.html).
1063 ///
1064 /// This is used to make the file chooser switch to the bookmark
1065 /// specified in the @bookmark_index parameter. For example, if
1066 /// you have three bookmarks, you can pass 0, 1, 2 to this signal
1067 /// to switch to each of them, respectively.
1068 ///
1069 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>1</kbd>,
1070 /// <kbd>Alt</kbd>-<kbd>2</kbd>, etc. until <kbd>Alt</kbd>-<kbd>0</kbd>.
1071 /// Note that in the default binding, that <kbd>Alt</kbd>-<kbd>1</kbd> is
1072 /// actually defined to switch to the bookmark at index 0, and so on
1073 /// successively.
1074 /// ## `bookmark_index`
1075 /// the number of the bookmark to switch to
1076 #[doc(alias = "quick-bookmark")]
1077 pub fn connect_quick_bookmark<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
1078 unsafe extern "C" fn quick_bookmark_trampoline<F: Fn(&FileChooserWidget, i32) + 'static>(
1079 this: *mut ffi::GtkFileChooserWidget,
1080 bookmark_index: std::ffi::c_int,
1081 f: glib::ffi::gpointer,
1082 ) {
1083 unsafe {
1084 let f: &F = &*(f as *const F);
1085 f(&from_glib_borrow(this), bookmark_index)
1086 }
1087 }
1088 unsafe {
1089 let f: Box_<F> = Box_::new(f);
1090 connect_raw(
1091 self.as_ptr() as *mut _,
1092 c"quick-bookmark".as_ptr() as *const _,
1093 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1094 quick_bookmark_trampoline::<F> as *const (),
1095 )),
1096 Box_::into_raw(f),
1097 )
1098 }
1099 }
1100
1101 pub fn emit_quick_bookmark(&self, bookmark_index: i32) {
1102 self.emit_by_name::<()>("quick-bookmark", &[&bookmark_index]);
1103 }
1104
1105 /// Emitted when the user asks for it.
1106 ///
1107 /// This is a [keybinding signal](class.SignalAction.html).
1108 ///
1109 /// This is used to make the file chooser show the Recent location.
1110 ///
1111 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>R</kbd>.
1112 #[doc(alias = "recent-shortcut")]
1113 pub fn connect_recent_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1114 unsafe extern "C" fn recent_shortcut_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1115 this: *mut ffi::GtkFileChooserWidget,
1116 f: glib::ffi::gpointer,
1117 ) {
1118 unsafe {
1119 let f: &F = &*(f as *const F);
1120 f(&from_glib_borrow(this))
1121 }
1122 }
1123 unsafe {
1124 let f: Box_<F> = Box_::new(f);
1125 connect_raw(
1126 self.as_ptr() as *mut _,
1127 c"recent-shortcut".as_ptr() as *const _,
1128 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1129 recent_shortcut_trampoline::<F> as *const (),
1130 )),
1131 Box_::into_raw(f),
1132 )
1133 }
1134 }
1135
1136 pub fn emit_recent_shortcut(&self) {
1137 self.emit_by_name::<()>("recent-shortcut", &[]);
1138 }
1139
1140 /// Emitted when the user asks for it.
1141 ///
1142 /// This is a [keybinding signal](class.SignalAction.html).
1143 ///
1144 /// This is used to make the file chooser show the search entry.
1145 ///
1146 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>S</kbd>.
1147 #[doc(alias = "search-shortcut")]
1148 pub fn connect_search_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1149 unsafe extern "C" fn search_shortcut_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1150 this: *mut ffi::GtkFileChooserWidget,
1151 f: glib::ffi::gpointer,
1152 ) {
1153 unsafe {
1154 let f: &F = &*(f as *const F);
1155 f(&from_glib_borrow(this))
1156 }
1157 }
1158 unsafe {
1159 let f: Box_<F> = Box_::new(f);
1160 connect_raw(
1161 self.as_ptr() as *mut _,
1162 c"search-shortcut".as_ptr() as *const _,
1163 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1164 search_shortcut_trampoline::<F> as *const (),
1165 )),
1166 Box_::into_raw(f),
1167 )
1168 }
1169 }
1170
1171 pub fn emit_search_shortcut(&self) {
1172 self.emit_by_name::<()>("search-shortcut", &[]);
1173 }
1174
1175 /// Emitted when the user asks for it.
1176 ///
1177 /// This is a [keybinding signal](class.SignalAction.html).
1178 ///
1179 /// This is used to make the file chooser display hidden files.
1180 ///
1181 /// The default binding for this signal is <kbd>Control</kbd>-<kbd>H</kbd>.
1182 #[doc(alias = "show-hidden")]
1183 pub fn connect_show_hidden<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1184 unsafe extern "C" fn show_hidden_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1185 this: *mut ffi::GtkFileChooserWidget,
1186 f: glib::ffi::gpointer,
1187 ) {
1188 unsafe {
1189 let f: &F = &*(f as *const F);
1190 f(&from_glib_borrow(this))
1191 }
1192 }
1193 unsafe {
1194 let f: Box_<F> = Box_::new(f);
1195 connect_raw(
1196 self.as_ptr() as *mut _,
1197 c"show-hidden".as_ptr() as *const _,
1198 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1199 show_hidden_trampoline::<F> as *const (),
1200 )),
1201 Box_::into_raw(f),
1202 )
1203 }
1204 }
1205
1206 pub fn emit_show_hidden(&self) {
1207 self.emit_by_name::<()>("show-hidden", &[]);
1208 }
1209
1210 /// Emitted when the user asks for it.
1211 ///
1212 /// This is a [keybinding signal](class.SignalAction.html).
1213 ///
1214 /// This is used to make the file chooser go to the parent
1215 /// of the current folder in the file hierarchy.
1216 ///
1217 /// The default binding for this signal is <kbd>Alt</kbd>-<kbd>Up</kbd>.
1218 #[doc(alias = "up-folder")]
1219 pub fn connect_up_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1220 unsafe extern "C" fn up_folder_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1221 this: *mut ffi::GtkFileChooserWidget,
1222 f: glib::ffi::gpointer,
1223 ) {
1224 unsafe {
1225 let f: &F = &*(f as *const F);
1226 f(&from_glib_borrow(this))
1227 }
1228 }
1229 unsafe {
1230 let f: Box_<F> = Box_::new(f);
1231 connect_raw(
1232 self.as_ptr() as *mut _,
1233 c"up-folder".as_ptr() as *const _,
1234 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1235 up_folder_trampoline::<F> as *const (),
1236 )),
1237 Box_::into_raw(f),
1238 )
1239 }
1240 }
1241
1242 pub fn emit_up_folder(&self) {
1243 self.emit_by_name::<()>("up-folder", &[]);
1244 }
1245
1246 #[doc(alias = "search-mode")]
1247 pub fn connect_search_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1248 unsafe extern "C" fn notify_search_mode_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1249 this: *mut ffi::GtkFileChooserWidget,
1250 _param_spec: glib::ffi::gpointer,
1251 f: glib::ffi::gpointer,
1252 ) {
1253 unsafe {
1254 let f: &F = &*(f as *const F);
1255 f(&from_glib_borrow(this))
1256 }
1257 }
1258 unsafe {
1259 let f: Box_<F> = Box_::new(f);
1260 connect_raw(
1261 self.as_ptr() as *mut _,
1262 c"notify::search-mode".as_ptr() as *const _,
1263 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1264 notify_search_mode_trampoline::<F> as *const (),
1265 )),
1266 Box_::into_raw(f),
1267 )
1268 }
1269 }
1270
1271 #[cfg(feature = "v4_10")]
1272 #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
1273 #[doc(alias = "show-time")]
1274 pub fn connect_show_time_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1275 unsafe extern "C" fn notify_show_time_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1276 this: *mut ffi::GtkFileChooserWidget,
1277 _param_spec: glib::ffi::gpointer,
1278 f: glib::ffi::gpointer,
1279 ) {
1280 unsafe {
1281 let f: &F = &*(f as *const F);
1282 f(&from_glib_borrow(this))
1283 }
1284 }
1285 unsafe {
1286 let f: Box_<F> = Box_::new(f);
1287 connect_raw(
1288 self.as_ptr() as *mut _,
1289 c"notify::show-time".as_ptr() as *const _,
1290 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1291 notify_show_time_trampoline::<F> as *const (),
1292 )),
1293 Box_::into_raw(f),
1294 )
1295 }
1296 }
1297
1298 #[doc(alias = "subtitle")]
1299 pub fn connect_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1300 unsafe extern "C" fn notify_subtitle_trampoline<F: Fn(&FileChooserWidget) + 'static>(
1301 this: *mut ffi::GtkFileChooserWidget,
1302 _param_spec: glib::ffi::gpointer,
1303 f: glib::ffi::gpointer,
1304 ) {
1305 unsafe {
1306 let f: &F = &*(f as *const F);
1307 f(&from_glib_borrow(this))
1308 }
1309 }
1310 unsafe {
1311 let f: Box_<F> = Box_::new(f);
1312 connect_raw(
1313 self.as_ptr() as *mut _,
1314 c"notify::subtitle".as_ptr() as *const _,
1315 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1316 notify_subtitle_trampoline::<F> as *const (),
1317 )),
1318 Box_::into_raw(f),
1319 )
1320 }
1321 }
1322}
1323
1324impl Default for FileChooserWidget {
1325 fn default() -> Self {
1326 glib::object::Object::new::<Self>()
1327 }
1328}
1329
1330// rustdoc-stripper-ignore-next
1331/// A [builder-pattern] type to construct [`FileChooserWidget`] objects.
1332///
1333/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1334#[must_use = "The builder must be built to be used"]
1335pub struct FileChooserWidgetBuilder {
1336 builder: glib::object::ObjectBuilder<'static, FileChooserWidget>,
1337}
1338
1339impl FileChooserWidgetBuilder {
1340 fn new() -> Self {
1341 Self {
1342 builder: glib::object::Object::builder(),
1343 }
1344 }
1345
1346 /// Whether search mode is enabled.
1347 pub fn search_mode(self, search_mode: bool) -> Self {
1348 Self {
1349 builder: self.builder.property("search-mode", search_mode),
1350 }
1351 }
1352
1353 /// Whether the widget or any of its descendents can accept
1354 /// the input focus.
1355 ///
1356 /// This property is meant to be set by widget implementations,
1357 /// typically in their instance init function.
1358 pub fn can_focus(self, can_focus: bool) -> Self {
1359 Self {
1360 builder: self.builder.property("can-focus", can_focus),
1361 }
1362 }
1363
1364 /// Whether the widget can receive pointer events.
1365 pub fn can_target(self, can_target: bool) -> Self {
1366 Self {
1367 builder: self.builder.property("can-target", can_target),
1368 }
1369 }
1370
1371 /// A list of css classes applied to this widget.
1372 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1373 Self {
1374 builder: self.builder.property("css-classes", css_classes.into()),
1375 }
1376 }
1377
1378 /// The name of this widget in the CSS tree.
1379 ///
1380 /// This property is meant to be set by widget implementations,
1381 /// typically in their instance init function.
1382 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1383 Self {
1384 builder: self.builder.property("css-name", css_name.into()),
1385 }
1386 }
1387
1388 /// The cursor used by @widget.
1389 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1390 Self {
1391 builder: self.builder.property("cursor", cursor.clone()),
1392 }
1393 }
1394
1395 /// Whether the widget should grab focus when it is clicked with the mouse.
1396 ///
1397 /// This property is only relevant for widgets that can take focus.
1398 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1399 Self {
1400 builder: self.builder.property("focus-on-click", focus_on_click),
1401 }
1402 }
1403
1404 /// Whether this widget itself will accept the input focus.
1405 pub fn focusable(self, focusable: bool) -> Self {
1406 Self {
1407 builder: self.builder.property("focusable", focusable),
1408 }
1409 }
1410
1411 /// How to distribute horizontal space if widget gets extra space.
1412 pub fn halign(self, halign: Align) -> Self {
1413 Self {
1414 builder: self.builder.property("halign", halign),
1415 }
1416 }
1417
1418 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1419 /// signal on @widget.
1420 ///
1421 /// A true value indicates that @widget can have a tooltip, in this case
1422 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1423 /// determine whether it will provide a tooltip or not.
1424 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1425 Self {
1426 builder: self.builder.property("has-tooltip", has_tooltip),
1427 }
1428 }
1429
1430 /// Overrides for height request of the widget.
1431 ///
1432 /// If this is -1, the natural request will be used.
1433 pub fn height_request(self, height_request: i32) -> Self {
1434 Self {
1435 builder: self.builder.property("height-request", height_request),
1436 }
1437 }
1438
1439 /// Whether to expand horizontally.
1440 pub fn hexpand(self, hexpand: bool) -> Self {
1441 Self {
1442 builder: self.builder.property("hexpand", hexpand),
1443 }
1444 }
1445
1446 /// Whether to use the `hexpand` property.
1447 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1448 Self {
1449 builder: self.builder.property("hexpand-set", hexpand_set),
1450 }
1451 }
1452
1453 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1454 /// the preferred size of the widget, and allocate its children.
1455 ///
1456 /// This property is meant to be set by widget implementations,
1457 /// typically in their instance init function.
1458 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1459 Self {
1460 builder: self
1461 .builder
1462 .property("layout-manager", layout_manager.clone().upcast()),
1463 }
1464 }
1465
1466 /// Makes this widget act like a modal dialog, with respect to
1467 /// event delivery.
1468 ///
1469 /// Global event controllers will not handle events with targets
1470 /// inside the widget, unless they are set up to ignore propagation
1471 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1472 #[cfg(feature = "v4_18")]
1473 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1474 pub fn limit_events(self, limit_events: bool) -> Self {
1475 Self {
1476 builder: self.builder.property("limit-events", limit_events),
1477 }
1478 }
1479
1480 /// Margin on bottom side of widget.
1481 ///
1482 /// This property adds margin outside of the widget's normal size
1483 /// request, the margin will be added in addition to the size from
1484 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1485 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1486 Self {
1487 builder: self.builder.property("margin-bottom", margin_bottom),
1488 }
1489 }
1490
1491 /// Margin on end of widget, horizontally.
1492 ///
1493 /// This property supports left-to-right and right-to-left text
1494 /// directions.
1495 ///
1496 /// This property adds margin outside of the widget's normal size
1497 /// request, the margin will be added in addition to the size from
1498 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1499 pub fn margin_end(self, margin_end: i32) -> Self {
1500 Self {
1501 builder: self.builder.property("margin-end", margin_end),
1502 }
1503 }
1504
1505 /// Margin on start of widget, horizontally.
1506 ///
1507 /// This property supports left-to-right and right-to-left text
1508 /// directions.
1509 ///
1510 /// This property adds margin outside of the widget's normal size
1511 /// request, the margin will be added in addition to the size from
1512 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1513 pub fn margin_start(self, margin_start: i32) -> Self {
1514 Self {
1515 builder: self.builder.property("margin-start", margin_start),
1516 }
1517 }
1518
1519 /// Margin on top side of widget.
1520 ///
1521 /// This property adds margin outside of the widget's normal size
1522 /// request, the margin will be added in addition to the size from
1523 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1524 pub fn margin_top(self, margin_top: i32) -> Self {
1525 Self {
1526 builder: self.builder.property("margin-top", margin_top),
1527 }
1528 }
1529
1530 /// The name of the widget.
1531 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1532 Self {
1533 builder: self.builder.property("name", name.into()),
1534 }
1535 }
1536
1537 /// The requested opacity of the widget.
1538 pub fn opacity(self, opacity: f64) -> Self {
1539 Self {
1540 builder: self.builder.property("opacity", opacity),
1541 }
1542 }
1543
1544 /// How content outside the widget's content area is treated.
1545 ///
1546 /// This property is meant to be set by widget implementations,
1547 /// typically in their instance init function.
1548 pub fn overflow(self, overflow: Overflow) -> Self {
1549 Self {
1550 builder: self.builder.property("overflow", overflow),
1551 }
1552 }
1553
1554 /// Whether the widget will receive the default action when it is focused.
1555 pub fn receives_default(self, receives_default: bool) -> Self {
1556 Self {
1557 builder: self.builder.property("receives-default", receives_default),
1558 }
1559 }
1560
1561 /// Whether the widget responds to input.
1562 pub fn sensitive(self, sensitive: bool) -> Self {
1563 Self {
1564 builder: self.builder.property("sensitive", sensitive),
1565 }
1566 }
1567
1568 /// Sets the text of tooltip to be the given string, which is marked up
1569 /// with Pango markup.
1570 ///
1571 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1572 ///
1573 /// This is a convenience property which will take care of getting the
1574 /// tooltip shown if the given string is not `NULL`:
1575 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1576 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1577 /// the default signal handler.
1578 ///
1579 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1580 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1581 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1582 Self {
1583 builder: self
1584 .builder
1585 .property("tooltip-markup", tooltip_markup.into()),
1586 }
1587 }
1588
1589 /// Sets the text of tooltip to be the given string.
1590 ///
1591 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1592 ///
1593 /// This is a convenience property which will take care of getting the
1594 /// tooltip shown if the given string is not `NULL`:
1595 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1596 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1597 /// the default signal handler.
1598 ///
1599 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1600 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1601 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1602 Self {
1603 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1604 }
1605 }
1606
1607 /// How to distribute vertical space if widget gets extra space.
1608 pub fn valign(self, valign: Align) -> Self {
1609 Self {
1610 builder: self.builder.property("valign", valign),
1611 }
1612 }
1613
1614 /// Whether to expand vertically.
1615 pub fn vexpand(self, vexpand: bool) -> Self {
1616 Self {
1617 builder: self.builder.property("vexpand", vexpand),
1618 }
1619 }
1620
1621 /// Whether to use the `vexpand` property.
1622 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1623 Self {
1624 builder: self.builder.property("vexpand-set", vexpand_set),
1625 }
1626 }
1627
1628 /// Whether the widget is visible.
1629 pub fn visible(self, visible: bool) -> Self {
1630 Self {
1631 builder: self.builder.property("visible", visible),
1632 }
1633 }
1634
1635 /// Overrides for width request of the widget.
1636 ///
1637 /// If this is -1, the natural request will be used.
1638 pub fn width_request(self, width_request: i32) -> Self {
1639 Self {
1640 builder: self.builder.property("width-request", width_request),
1641 }
1642 }
1643
1644 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1645 ///
1646 /// The accessible role cannot be changed once set.
1647 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1648 Self {
1649 builder: self.builder.property("accessible-role", accessible_role),
1650 }
1651 }
1652
1653 /// The type of operation that the file chooser is performing.
1654 /// Use [`FileDialog`][crate::FileDialog] instead
1655 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1656 pub fn action(self, action: FileChooserAction) -> Self {
1657 Self {
1658 builder: self.builder.property("action", action),
1659 }
1660 }
1661
1662 /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
1663 /// will offer the user to create new folders.
1664 /// Use [`FileDialog`][crate::FileDialog] instead
1665 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1666 pub fn create_folders(self, create_folders: bool) -> Self {
1667 Self {
1668 builder: self.builder.property("create-folders", create_folders),
1669 }
1670 }
1671
1672 /// The current filter for selecting files that are displayed.
1673 /// Use [`FileDialog`][crate::FileDialog] instead
1674 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1675 pub fn filter(self, filter: &FileFilter) -> Self {
1676 Self {
1677 builder: self.builder.property("filter", filter.clone()),
1678 }
1679 }
1680
1681 /// Whether to allow multiple files to be selected.
1682 /// Use [`FileDialog`][crate::FileDialog] instead
1683 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1684 pub fn select_multiple(self, select_multiple: bool) -> Self {
1685 Self {
1686 builder: self.builder.property("select-multiple", select_multiple),
1687 }
1688 }
1689
1690 // rustdoc-stripper-ignore-next
1691 /// Build the [`FileChooserWidget`].
1692 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1693 pub fn build(self) -> FileChooserWidget {
1694 assert_initialized_main_thread!();
1695 self.builder.build()
1696 }
1697}