Skip to main content

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