gtk4/auto/
file_chooser_dialog.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
6#[cfg(feature = "v4_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
8use crate::WindowGravity;
9use crate::{
10    ffi, Accessible, AccessibleRole, Align, Application, Buildable, ConstraintTarget, Dialog,
11    FileChooser, FileChooserAction, FileFilter, LayoutManager, Native, Overflow, Root,
12    ShortcutManager, Widget, Window,
13};
14use glib::prelude::*;
15
16glib::wrapper! {
17    /// Use [`FileDialog`][crate::FileDialog] instead
18    /// [`FileChooserDialog`][crate::FileChooserDialog] is a dialog suitable for use with
19    /// “File Open” or “File Save” commands.
20    ///
21    /// ![An example GtkFileChooserDialog](filechooser.png)
22    ///
23    /// This widget works by putting a [`FileChooserWidget`][crate::FileChooserWidget]
24    /// inside a [`Dialog`][crate::Dialog]. It exposes the [`FileChooser`][crate::FileChooser]
25    /// interface, so you can use all of the [`FileChooser`][crate::FileChooser] functions
26    /// on the file chooser dialog as well as those for [`Dialog`][crate::Dialog].
27    ///
28    /// Note that [`FileChooserDialog`][crate::FileChooserDialog] does not have any methods of its
29    /// own. Instead, you should use the functions that work on a
30    /// [`FileChooser`][crate::FileChooser].
31    ///
32    /// If you want to integrate well with the platform you should use the
33    /// [`FileChooserNative`][crate::FileChooserNative] API, which will use a platform-specific
34    /// dialog if available and fall back to [`FileChooserDialog`][crate::FileChooserDialog]
35    /// otherwise.
36    ///
37    /// ## Typical usage
38    ///
39    /// In the simplest of cases, you can the following code to use
40    /// [`FileChooserDialog`][crate::FileChooserDialog] to select a file for opening:
41    ///
42    /// **⚠️ The following code is in c ⚠️**
43    ///
44    /// ```c
45    /// static void
46    /// on_open_response (GtkDialog *dialog,
47    ///                   int        response)
48    /// {
49    ///   if (response == GTK_RESPONSE_ACCEPT)
50    ///     {
51    ///       GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
52    ///
53    ///       g_autoptr(GFile) file = gtk_file_chooser_get_file (chooser);
54    ///
55    ///       open_file (file);
56    ///     }
57    ///
58    ///   gtk_window_destroy (GTK_WINDOW (dialog));
59    /// }
60    ///
61    ///   // ...
62    ///   GtkWidget *dialog;
63    ///   GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
64    ///
65    ///   dialog = gtk_file_chooser_dialog_new ("Open File",
66    ///                                         parent_window,
67    ///                                         action,
68    ///                                         _("_Cancel"),
69    ///                                         GTK_RESPONSE_CANCEL,
70    ///                                         _("_Open"),
71    ///                                         GTK_RESPONSE_ACCEPT,
72    ///                                         NULL);
73    ///
74    ///   gtk_window_present (GTK_WINDOW (dialog));
75    ///
76    ///   g_signal_connect (dialog, "response",
77    ///                     G_CALLBACK (on_open_response),
78    ///                     NULL);
79    /// ```
80    ///
81    /// To use a dialog for saving, you can use this:
82    ///
83    /// **⚠️ The following code is in c ⚠️**
84    ///
85    /// ```c
86    /// static void
87    /// on_save_response (GtkDialog *dialog,
88    ///                   int        response)
89    /// {
90    ///   if (response == GTK_RESPONSE_ACCEPT)
91    ///     {
92    ///       GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
93    ///
94    ///       g_autoptr(GFile) file = gtk_file_chooser_get_file (chooser);
95    ///
96    ///       save_to_file (file);
97    ///     }
98    ///
99    ///   gtk_window_destroy (GTK_WINDOW (dialog));
100    /// }
101    ///
102    ///   // ...
103    ///   GtkWidget *dialog;
104    ///   GtkFileChooser *chooser;
105    ///   GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
106    ///
107    ///   dialog = gtk_file_chooser_dialog_new ("Save File",
108    ///                                         parent_window,
109    ///                                         action,
110    ///                                         _("_Cancel"),
111    ///                                         GTK_RESPONSE_CANCEL,
112    ///                                         _("_Save"),
113    ///                                         GTK_RESPONSE_ACCEPT,
114    ///                                         NULL);
115    ///   chooser = GTK_FILE_CHOOSER (dialog);
116    ///
117    ///   if (user_edited_a_new_document)
118    ///     gtk_file_chooser_set_current_name (chooser, _("Untitled document"));
119    ///   else
120    ///     gtk_file_chooser_set_file (chooser, existing_filename);
121    ///
122    ///   gtk_window_present (GTK_WINDOW (dialog));
123    ///
124    ///   g_signal_connect (dialog, "response",
125    ///                     G_CALLBACK (on_save_response),
126    ///                     NULL);
127    /// ```
128    ///
129    /// ## Setting up a file chooser dialog
130    ///
131    /// There are various cases in which you may need to use a [`FileChooserDialog`][crate::FileChooserDialog]:
132    ///
133    /// - To select a file for opening, use [`FileChooserAction::Open`][crate::FileChooserAction::Open].
134    ///
135    /// - To save a file for the first time, use [`FileChooserAction::Save`][crate::FileChooserAction::Save],
136    ///   and suggest a name such as “Untitled” with
137    ///   [`FileChooserExt::set_current_name()`][crate::prelude::FileChooserExt::set_current_name()].
138    ///
139    /// - To save a file under a different name, use [`FileChooserAction::Save`][crate::FileChooserAction::Save],
140    ///   and set the existing file with [`FileChooserExt::set_file()`][crate::prelude::FileChooserExt::set_file()].
141    ///
142    /// - To choose a folder instead of a filem use [`FileChooserAction::SelectFolder`][crate::FileChooserAction::SelectFolder].
143    ///
144    /// In general, you should only cause the file chooser to show a specific
145    /// folder when it is appropriate to use [`FileChooserExt::set_file()`][crate::prelude::FileChooserExt::set_file()],
146    /// i.e. when you are doing a “Save As” command and you already have a file
147    /// saved somewhere.
148    ///
149    /// ## Response Codes
150    ///
151    /// [`FileChooserDialog`][crate::FileChooserDialog] inherits from [`Dialog`][crate::Dialog], so buttons that
152    /// go in its action area have response codes such as [`ResponseType::Accept`][crate::ResponseType::Accept] and
153    /// [`ResponseType::Cancel`][crate::ResponseType::Cancel]. For example, you could call
154    /// [`new()`][Self::new()] as follows:
155    ///
156    /// **⚠️ The following code is in c ⚠️**
157    ///
158    /// ```c
159    /// GtkWidget *dialog;
160    /// GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
161    ///
162    /// dialog = gtk_file_chooser_dialog_new ("Open File",
163    ///                                       parent_window,
164    ///                                       action,
165    ///                                       _("_Cancel"),
166    ///                                       GTK_RESPONSE_CANCEL,
167    ///                                       _("_Open"),
168    ///                                       GTK_RESPONSE_ACCEPT,
169    ///                                       NULL);
170    /// ```
171    ///
172    /// This will create buttons for “Cancel” and “Open” that use predefined
173    /// response identifiers from [`ResponseType`][crate::ResponseType].  For most dialog
174    /// boxes you can use your own custom response codes rather than the
175    /// ones in [`ResponseType`][crate::ResponseType], but [`FileChooserDialog`][crate::FileChooserDialog] assumes that
176    /// its “accept”-type action, e.g. an “Open” or “Save” button,
177    /// will have one of the following response codes:
178    ///
179    /// - [`ResponseType::Accept`][crate::ResponseType::Accept]
180    /// - [`ResponseType::Ok`][crate::ResponseType::Ok]
181    /// - [`ResponseType::Yes`][crate::ResponseType::Yes]
182    /// - [`ResponseType::Apply`][crate::ResponseType::Apply]
183    ///
184    /// This is because [`FileChooserDialog`][crate::FileChooserDialog] must intercept responses and switch
185    /// to folders if appropriate, rather than letting the dialog terminate — the
186    /// implementation uses these known response codes to know which responses can
187    /// be blocked if appropriate.
188    ///
189    /// To summarize, make sure you use a predefined response code
190    /// when you use [`FileChooserDialog`][crate::FileChooserDialog] to ensure proper operation.
191    ///
192    /// ## CSS nodes
193    ///
194    /// [`FileChooserDialog`][crate::FileChooserDialog] has a single CSS node with the name `window` and style
195    /// class `.filechooser`.
196    ///
197    /// # Implements
198    ///
199    /// [`DialogExt`][trait@crate::prelude::DialogExt], [`GtkWindowExt`][trait@crate::prelude::GtkWindowExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`NativeExt`][trait@crate::prelude::NativeExt], [`RootExt`][trait@crate::prelude::RootExt], [`ShortcutManagerExt`][trait@crate::prelude::ShortcutManagerExt], [`FileChooserExt`][trait@crate::prelude::FileChooserExt], [`DialogExtManual`][trait@crate::prelude::DialogExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual], [`FileChooserExtManual`][trait@crate::prelude::FileChooserExtManual]
200    #[doc(alias = "GtkFileChooserDialog")]
201    pub struct FileChooserDialog(Object<ffi::GtkFileChooserDialog>) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, FileChooser;
202
203    match fn {
204        type_ => || ffi::gtk_file_chooser_dialog_get_type(),
205    }
206}
207
208impl FileChooserDialog {
209    // rustdoc-stripper-ignore-next
210    /// Creates a new builder-pattern struct instance to construct [`FileChooserDialog`] objects.
211    ///
212    /// This method returns an instance of [`FileChooserDialogBuilder`](crate::builders::FileChooserDialogBuilder) which can be used to create [`FileChooserDialog`] objects.
213    pub fn builder() -> FileChooserDialogBuilder {
214        FileChooserDialogBuilder::new()
215    }
216}
217
218// rustdoc-stripper-ignore-next
219/// A [builder-pattern] type to construct [`FileChooserDialog`] objects.
220///
221/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
222#[must_use = "The builder must be built to be used"]
223pub struct FileChooserDialogBuilder {
224    builder: glib::object::ObjectBuilder<'static, FileChooserDialog>,
225}
226
227impl FileChooserDialogBuilder {
228    fn new() -> Self {
229        Self {
230            builder: glib::object::Object::builder(),
231        }
232    }
233
234    /// [`true`] if the dialog uses a headerbar for action buttons
235    /// instead of the action-area.
236    ///
237    /// For technical reasons, this property is declared as an integer
238    /// property, but you should only set it to [`true`] or [`false`].
239    ///
240    /// ## Creating a dialog with headerbar
241    ///
242    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
243    /// set this property according to platform conventions (using the
244    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
245    ///
246    /// Here is how you can achieve the same:
247    ///
248    /// **⚠️ The following code is in c ⚠️**
249    ///
250    /// ```c
251    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
252    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
253    /// ```
254    /// Use [`Window`][crate::Window] instead
255    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
256    pub fn use_header_bar(self, use_header_bar: i32) -> Self {
257        Self {
258            builder: self.builder.property("use-header-bar", use_header_bar),
259        }
260    }
261
262    /// The [`Application`][crate::Application] associated with the window.
263    ///
264    /// The application will be kept alive for at least as long as it
265    /// has any windows associated with it (see g_application_hold()
266    /// for a way to keep it alive without windows).
267    ///
268    /// Normally, the connection between the application and the window
269    /// will remain until the window is destroyed, but you can explicitly
270    /// remove it by setting the this property to `NULL`.
271    pub fn application(self, application: &impl IsA<Application>) -> Self {
272        Self {
273            builder: self
274                .builder
275                .property("application", application.clone().upcast()),
276        }
277    }
278
279    /// The child widget.
280    pub fn child(self, child: &impl IsA<Widget>) -> Self {
281        Self {
282            builder: self.builder.property("child", child.clone().upcast()),
283        }
284    }
285
286    /// Whether the window should have a frame (also known as *decorations*).
287    pub fn decorated(self, decorated: bool) -> Self {
288        Self {
289            builder: self.builder.property("decorated", decorated),
290        }
291    }
292
293    /// The default height of the window.
294    pub fn default_height(self, default_height: i32) -> Self {
295        Self {
296            builder: self.builder.property("default-height", default_height),
297        }
298    }
299
300    /// The default widget.
301    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
302        Self {
303            builder: self
304                .builder
305                .property("default-widget", default_widget.clone().upcast()),
306        }
307    }
308
309    /// The default width of the window.
310    pub fn default_width(self, default_width: i32) -> Self {
311        Self {
312            builder: self.builder.property("default-width", default_width),
313        }
314    }
315
316    /// Whether the window frame should have a close button.
317    pub fn deletable(self, deletable: bool) -> Self {
318        Self {
319            builder: self.builder.property("deletable", deletable),
320        }
321    }
322
323    /// If this window should be destroyed when the parent is destroyed.
324    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
325        Self {
326            builder: self
327                .builder
328                .property("destroy-with-parent", destroy_with_parent),
329        }
330    }
331
332    /// The display that will display this window.
333    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
334        Self {
335            builder: self.builder.property("display", display.clone().upcast()),
336        }
337    }
338
339    /// Whether 'focus rectangles' are currently visible in this window.
340    ///
341    /// This property is maintained by GTK based on user input
342    /// and should not be set by applications.
343    pub fn focus_visible(self, focus_visible: bool) -> Self {
344        Self {
345            builder: self.builder.property("focus-visible", focus_visible),
346        }
347    }
348
349    /// The focus widget.
350    pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
351        Self {
352            builder: self
353                .builder
354                .property("focus-widget", focus_widget.clone().upcast()),
355        }
356    }
357
358    /// Whether the window is fullscreen.
359    ///
360    /// Setting this property is the equivalent of calling
361    /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
362    /// either operation is asynchronous, which means you will need to
363    /// connect to the ::notify signal in order to know whether the
364    /// operation was successful.
365    pub fn fullscreened(self, fullscreened: bool) -> Self {
366        Self {
367            builder: self.builder.property("fullscreened", fullscreened),
368        }
369    }
370
371    /// The gravity to use when resizing the window programmatically.
372    ///
373    /// Gravity describes which point of the window we want to keep
374    /// fixed (meaning that the window will grow in the opposite direction).
375    /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
376    /// want the to fix top right corner of the window.
377    #[cfg(feature = "v4_20")]
378    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
379    pub fn gravity(self, gravity: WindowGravity) -> Self {
380        Self {
381            builder: self.builder.property("gravity", gravity),
382        }
383    }
384
385    /// Whether the window frame should handle <kbd>F10</kbd> for activating
386    /// menubars.
387    #[cfg(feature = "v4_2")]
388    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
389    pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
390        Self {
391            builder: self
392                .builder
393                .property("handle-menubar-accel", handle_menubar_accel),
394        }
395    }
396
397    /// If this window should be hidden instead of destroyed when the user clicks
398    /// the close button.
399    pub fn hide_on_close(self, hide_on_close: bool) -> Self {
400        Self {
401            builder: self.builder.property("hide-on-close", hide_on_close),
402        }
403    }
404
405    /// Specifies the name of the themed icon to use as the window icon.
406    ///
407    /// See [`IconTheme`][crate::IconTheme] for more details.
408    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
409        Self {
410            builder: self.builder.property("icon-name", icon_name.into()),
411        }
412    }
413
414    /// Whether the window is maximized.
415    ///
416    /// Setting this property is the equivalent of calling
417    /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
418    /// either operation is asynchronous, which means you will need to
419    /// connect to the ::notify signal in order to know whether the
420    /// operation was successful.
421    pub fn maximized(self, maximized: bool) -> Self {
422        Self {
423            builder: self.builder.property("maximized", maximized),
424        }
425    }
426
427    /// Whether mnemonics are currently visible in this window.
428    ///
429    /// This property is maintained by GTK based on user input,
430    /// and should not be set by applications.
431    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
432        Self {
433            builder: self
434                .builder
435                .property("mnemonics-visible", mnemonics_visible),
436        }
437    }
438
439    /// If true, the window is modal.
440    pub fn modal(self, modal: bool) -> Self {
441        Self {
442            builder: self.builder.property("modal", modal),
443        }
444    }
445
446    /// If true, users can resize the window.
447    pub fn resizable(self, resizable: bool) -> Self {
448        Self {
449            builder: self.builder.property("resizable", resizable),
450        }
451    }
452
453    /// A write-only property for setting window's startup notification identifier.
454    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
455        Self {
456            builder: self.builder.property("startup-id", startup_id.into()),
457        }
458    }
459
460    /// The title of the window.
461    pub fn title(self, title: impl Into<glib::GString>) -> Self {
462        Self {
463            builder: self.builder.property("title", title.into()),
464        }
465    }
466
467    /// The titlebar widget.
468    #[cfg(feature = "v4_6")]
469    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
470    pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
471        Self {
472            builder: self.builder.property("titlebar", titlebar.clone().upcast()),
473        }
474    }
475
476    /// The transient parent of the window.
477    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
478        Self {
479            builder: self
480                .builder
481                .property("transient-for", transient_for.clone().upcast()),
482        }
483    }
484
485    /// Whether the widget or any of its descendents can accept
486    /// the input focus.
487    ///
488    /// This property is meant to be set by widget implementations,
489    /// typically in their instance init function.
490    pub fn can_focus(self, can_focus: bool) -> Self {
491        Self {
492            builder: self.builder.property("can-focus", can_focus),
493        }
494    }
495
496    /// Whether the widget can receive pointer events.
497    pub fn can_target(self, can_target: bool) -> Self {
498        Self {
499            builder: self.builder.property("can-target", can_target),
500        }
501    }
502
503    /// A list of css classes applied to this widget.
504    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
505        Self {
506            builder: self.builder.property("css-classes", css_classes.into()),
507        }
508    }
509
510    /// The name of this widget in the CSS tree.
511    ///
512    /// This property is meant to be set by widget implementations,
513    /// typically in their instance init function.
514    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
515        Self {
516            builder: self.builder.property("css-name", css_name.into()),
517        }
518    }
519
520    /// The cursor used by @widget.
521    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
522        Self {
523            builder: self.builder.property("cursor", cursor.clone()),
524        }
525    }
526
527    /// Whether the widget should grab focus when it is clicked with the mouse.
528    ///
529    /// This property is only relevant for widgets that can take focus.
530    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
531        Self {
532            builder: self.builder.property("focus-on-click", focus_on_click),
533        }
534    }
535
536    /// Whether this widget itself will accept the input focus.
537    pub fn focusable(self, focusable: bool) -> Self {
538        Self {
539            builder: self.builder.property("focusable", focusable),
540        }
541    }
542
543    /// How to distribute horizontal space if widget gets extra space.
544    pub fn halign(self, halign: Align) -> Self {
545        Self {
546            builder: self.builder.property("halign", halign),
547        }
548    }
549
550    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
551    /// signal on @widget.
552    ///
553    /// A true value indicates that @widget can have a tooltip, in this case
554    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
555    /// determine whether it will provide a tooltip or not.
556    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
557        Self {
558            builder: self.builder.property("has-tooltip", has_tooltip),
559        }
560    }
561
562    /// Overrides for height request of the widget.
563    ///
564    /// If this is -1, the natural request will be used.
565    pub fn height_request(self, height_request: i32) -> Self {
566        Self {
567            builder: self.builder.property("height-request", height_request),
568        }
569    }
570
571    /// Whether to expand horizontally.
572    pub fn hexpand(self, hexpand: bool) -> Self {
573        Self {
574            builder: self.builder.property("hexpand", hexpand),
575        }
576    }
577
578    /// Whether to use the `hexpand` property.
579    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
580        Self {
581            builder: self.builder.property("hexpand-set", hexpand_set),
582        }
583    }
584
585    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
586    /// the preferred size of the widget, and allocate its children.
587    ///
588    /// This property is meant to be set by widget implementations,
589    /// typically in their instance init function.
590    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
591        Self {
592            builder: self
593                .builder
594                .property("layout-manager", layout_manager.clone().upcast()),
595        }
596    }
597
598    /// Makes this widget act like a modal dialog, with respect to
599    /// event delivery.
600    ///
601    /// Global event controllers will not handle events with targets
602    /// inside the widget, unless they are set up to ignore propagation
603    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
604    #[cfg(feature = "v4_18")]
605    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
606    pub fn limit_events(self, limit_events: bool) -> Self {
607        Self {
608            builder: self.builder.property("limit-events", limit_events),
609        }
610    }
611
612    /// Margin on bottom side of widget.
613    ///
614    /// This property adds margin outside of the widget's normal size
615    /// request, the margin will be added in addition to the size from
616    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
617    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
618        Self {
619            builder: self.builder.property("margin-bottom", margin_bottom),
620        }
621    }
622
623    /// Margin on end of widget, horizontally.
624    ///
625    /// This property supports left-to-right and right-to-left text
626    /// directions.
627    ///
628    /// This property adds margin outside of the widget's normal size
629    /// request, the margin will be added in addition to the size from
630    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
631    pub fn margin_end(self, margin_end: i32) -> Self {
632        Self {
633            builder: self.builder.property("margin-end", margin_end),
634        }
635    }
636
637    /// Margin on start of widget, horizontally.
638    ///
639    /// This property supports left-to-right and right-to-left text
640    /// directions.
641    ///
642    /// This property adds margin outside of the widget's normal size
643    /// request, the margin will be added in addition to the size from
644    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
645    pub fn margin_start(self, margin_start: i32) -> Self {
646        Self {
647            builder: self.builder.property("margin-start", margin_start),
648        }
649    }
650
651    /// Margin on top side of widget.
652    ///
653    /// This property adds margin outside of the widget's normal size
654    /// request, the margin will be added in addition to the size from
655    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
656    pub fn margin_top(self, margin_top: i32) -> Self {
657        Self {
658            builder: self.builder.property("margin-top", margin_top),
659        }
660    }
661
662    /// The name of the widget.
663    pub fn name(self, name: impl Into<glib::GString>) -> Self {
664        Self {
665            builder: self.builder.property("name", name.into()),
666        }
667    }
668
669    /// The requested opacity of the widget.
670    pub fn opacity(self, opacity: f64) -> Self {
671        Self {
672            builder: self.builder.property("opacity", opacity),
673        }
674    }
675
676    /// How content outside the widget's content area is treated.
677    ///
678    /// This property is meant to be set by widget implementations,
679    /// typically in their instance init function.
680    pub fn overflow(self, overflow: Overflow) -> Self {
681        Self {
682            builder: self.builder.property("overflow", overflow),
683        }
684    }
685
686    /// Whether the widget will receive the default action when it is focused.
687    pub fn receives_default(self, receives_default: bool) -> Self {
688        Self {
689            builder: self.builder.property("receives-default", receives_default),
690        }
691    }
692
693    /// Whether the widget responds to input.
694    pub fn sensitive(self, sensitive: bool) -> Self {
695        Self {
696            builder: self.builder.property("sensitive", sensitive),
697        }
698    }
699
700    /// Sets the text of tooltip to be the given string, which is marked up
701    /// with Pango markup.
702    ///
703    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
704    ///
705    /// This is a convenience property which will take care of getting the
706    /// tooltip shown if the given string is not `NULL`:
707    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
708    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
709    /// the default signal handler.
710    ///
711    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
712    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
713    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
714        Self {
715            builder: self
716                .builder
717                .property("tooltip-markup", tooltip_markup.into()),
718        }
719    }
720
721    /// Sets the text of tooltip to be the given string.
722    ///
723    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
724    ///
725    /// This is a convenience property which will take care of getting the
726    /// tooltip shown if the given string is not `NULL`:
727    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
728    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
729    /// the default signal handler.
730    ///
731    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
732    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
733    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
734        Self {
735            builder: self.builder.property("tooltip-text", tooltip_text.into()),
736        }
737    }
738
739    /// How to distribute vertical space if widget gets extra space.
740    pub fn valign(self, valign: Align) -> Self {
741        Self {
742            builder: self.builder.property("valign", valign),
743        }
744    }
745
746    /// Whether to expand vertically.
747    pub fn vexpand(self, vexpand: bool) -> Self {
748        Self {
749            builder: self.builder.property("vexpand", vexpand),
750        }
751    }
752
753    /// Whether to use the `vexpand` property.
754    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
755        Self {
756            builder: self.builder.property("vexpand-set", vexpand_set),
757        }
758    }
759
760    /// Whether the widget is visible.
761    pub fn visible(self, visible: bool) -> Self {
762        Self {
763            builder: self.builder.property("visible", visible),
764        }
765    }
766
767    /// Overrides for width request of the widget.
768    ///
769    /// If this is -1, the natural request will be used.
770    pub fn width_request(self, width_request: i32) -> Self {
771        Self {
772            builder: self.builder.property("width-request", width_request),
773        }
774    }
775
776    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
777    ///
778    /// The accessible role cannot be changed once set.
779    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
780        Self {
781            builder: self.builder.property("accessible-role", accessible_role),
782        }
783    }
784
785    /// The type of operation that the file chooser is performing.
786    /// Use [`FileDialog`][crate::FileDialog] instead
787    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
788    pub fn action(self, action: FileChooserAction) -> Self {
789        Self {
790            builder: self.builder.property("action", action),
791        }
792    }
793
794    /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
795    /// will offer the user to create new folders.
796    /// Use [`FileDialog`][crate::FileDialog] instead
797    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
798    pub fn create_folders(self, create_folders: bool) -> Self {
799        Self {
800            builder: self.builder.property("create-folders", create_folders),
801        }
802    }
803
804    /// The current filter for selecting files that are displayed.
805    /// Use [`FileDialog`][crate::FileDialog] instead
806    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
807    pub fn filter(self, filter: &FileFilter) -> Self {
808        Self {
809            builder: self.builder.property("filter", filter.clone()),
810        }
811    }
812
813    /// Whether to allow multiple files to be selected.
814    /// Use [`FileDialog`][crate::FileDialog] instead
815    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
816    pub fn select_multiple(self, select_multiple: bool) -> Self {
817        Self {
818            builder: self.builder.property("select-multiple", select_multiple),
819        }
820    }
821
822    // rustdoc-stripper-ignore-next
823    /// Build the [`FileChooserDialog`].
824    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
825    pub fn build(self) -> FileChooserDialog {
826        assert_initialized_main_thread!();
827        self.builder.build()
828    }
829}