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