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    /// [`true`] if the dialog uses a headerbar for action buttons
250    /// instead of the action-area.
251    ///
252    /// For technical reasons, this property is declared as an integer
253    /// property, but you should only set it to [`true`] or [`false`].
254    ///
255    /// ## Creating a dialog with headerbar
256    ///
257    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
258    /// set this property according to platform conventions (using the
259    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
260    ///
261    /// Here is how you can achieve the same:
262    ///
263    /// **⚠️ The following code is in c ⚠️**
264    ///
265    /// ```c
266    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
267    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
268    /// ```
269    /// Use [`Window`][crate::Window] instead
270    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
271    pub fn use_header_bar(self, use_header_bar: i32) -> Self {
272        Self {
273            builder: self.builder.property("use-header-bar", use_header_bar),
274        }
275    }
276
277    /// The [`Application`][crate::Application] associated with the window.
278    ///
279    /// The application will be kept alive for at least as long as it
280    /// has any windows associated with it (see g_application_hold()
281    /// for a way to keep it alive without windows).
282    ///
283    /// Normally, the connection between the application and the window
284    /// will remain until the window is destroyed, but you can explicitly
285    /// remove it by setting the this property to `NULL`.
286    pub fn application(self, application: &impl IsA<Application>) -> Self {
287        Self {
288            builder: self
289                .builder
290                .property("application", application.clone().upcast()),
291        }
292    }
293
294    /// The child widget.
295    pub fn child(self, child: &impl IsA<Widget>) -> Self {
296        Self {
297            builder: self.builder.property("child", child.clone().upcast()),
298        }
299    }
300
301    /// Whether the window should have a frame (also known as *decorations*).
302    pub fn decorated(self, decorated: bool) -> Self {
303        Self {
304            builder: self.builder.property("decorated", decorated),
305        }
306    }
307
308    /// The default height of the window.
309    pub fn default_height(self, default_height: i32) -> Self {
310        Self {
311            builder: self.builder.property("default-height", default_height),
312        }
313    }
314
315    /// The default widget.
316    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
317        Self {
318            builder: self
319                .builder
320                .property("default-widget", default_widget.clone().upcast()),
321        }
322    }
323
324    /// The default width of the window.
325    pub fn default_width(self, default_width: i32) -> Self {
326        Self {
327            builder: self.builder.property("default-width", default_width),
328        }
329    }
330
331    /// Whether the window frame should have a close button.
332    pub fn deletable(self, deletable: bool) -> Self {
333        Self {
334            builder: self.builder.property("deletable", deletable),
335        }
336    }
337
338    /// If this window should be destroyed when the parent is destroyed.
339    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
340        Self {
341            builder: self
342                .builder
343                .property("destroy-with-parent", destroy_with_parent),
344        }
345    }
346
347    /// The display that will display this window.
348    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
349        Self {
350            builder: self.builder.property("display", display.clone().upcast()),
351        }
352    }
353
354    /// Whether 'focus rectangles' are currently visible in this window.
355    ///
356    /// This property is maintained by GTK based on user input
357    /// and should not be set by applications.
358    pub fn focus_visible(self, focus_visible: bool) -> Self {
359        Self {
360            builder: self.builder.property("focus-visible", focus_visible),
361        }
362    }
363
364    /// The focus widget.
365    pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
366        Self {
367            builder: self
368                .builder
369                .property("focus-widget", focus_widget.clone().upcast()),
370        }
371    }
372
373    /// Whether the window is fullscreen.
374    ///
375    /// Setting this property is the equivalent of calling
376    /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
377    /// either operation is asynchronous, which means you will need to
378    /// connect to the ::notify signal in order to know whether the
379    /// operation was successful.
380    pub fn fullscreened(self, fullscreened: bool) -> Self {
381        Self {
382            builder: self.builder.property("fullscreened", fullscreened),
383        }
384    }
385
386    /// The gravity to use when resizing the window programmatically.
387    ///
388    /// Gravity describes which point of the window we want to keep
389    /// fixed (meaning that the window will grow in the opposite direction).
390    /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
391    /// want the to fix top right corner of the window.
392    #[cfg(feature = "v4_20")]
393    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
394    pub fn gravity(self, gravity: WindowGravity) -> Self {
395        Self {
396            builder: self.builder.property("gravity", gravity),
397        }
398    }
399
400    /// Whether the window frame should handle <kbd>F10</kbd> for activating
401    /// menubars.
402    #[cfg(feature = "v4_2")]
403    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
404    pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
405        Self {
406            builder: self
407                .builder
408                .property("handle-menubar-accel", handle_menubar_accel),
409        }
410    }
411
412    /// If this window should be hidden instead of destroyed when the user clicks
413    /// the close button.
414    pub fn hide_on_close(self, hide_on_close: bool) -> Self {
415        Self {
416            builder: self.builder.property("hide-on-close", hide_on_close),
417        }
418    }
419
420    /// Specifies the name of the themed icon to use as the window icon.
421    ///
422    /// See [`IconTheme`][crate::IconTheme] for more details.
423    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
424        Self {
425            builder: self.builder.property("icon-name", icon_name.into()),
426        }
427    }
428
429    /// Whether the window is maximized.
430    ///
431    /// Setting this property is the equivalent of calling
432    /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
433    /// either operation is asynchronous, which means you will need to
434    /// connect to the ::notify signal in order to know whether the
435    /// operation was successful.
436    pub fn maximized(self, maximized: bool) -> Self {
437        Self {
438            builder: self.builder.property("maximized", maximized),
439        }
440    }
441
442    /// Whether mnemonics are currently visible in this window.
443    ///
444    /// This property is maintained by GTK based on user input,
445    /// and should not be set by applications.
446    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
447        Self {
448            builder: self
449                .builder
450                .property("mnemonics-visible", mnemonics_visible),
451        }
452    }
453
454    /// If true, the window is modal.
455    pub fn modal(self, modal: bool) -> Self {
456        Self {
457            builder: self.builder.property("modal", modal),
458        }
459    }
460
461    /// If true, users can resize the window.
462    pub fn resizable(self, resizable: bool) -> Self {
463        Self {
464            builder: self.builder.property("resizable", resizable),
465        }
466    }
467
468    /// A write-only property for setting window's startup notification identifier.
469    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
470        Self {
471            builder: self.builder.property("startup-id", startup_id.into()),
472        }
473    }
474
475    /// The title of the window.
476    pub fn title(self, title: impl Into<glib::GString>) -> Self {
477        Self {
478            builder: self.builder.property("title", title.into()),
479        }
480    }
481
482    /// The titlebar widget.
483    #[cfg(feature = "v4_6")]
484    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
485    pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
486        Self {
487            builder: self.builder.property("titlebar", titlebar.clone().upcast()),
488        }
489    }
490
491    /// The transient parent of the window.
492    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
493        Self {
494            builder: self
495                .builder
496                .property("transient-for", transient_for.clone().upcast()),
497        }
498    }
499
500    /// Whether the widget or any of its descendents can accept
501    /// the input focus.
502    ///
503    /// This property is meant to be set by widget implementations,
504    /// typically in their instance init function.
505    pub fn can_focus(self, can_focus: bool) -> Self {
506        Self {
507            builder: self.builder.property("can-focus", can_focus),
508        }
509    }
510
511    /// Whether the widget can receive pointer events.
512    pub fn can_target(self, can_target: bool) -> Self {
513        Self {
514            builder: self.builder.property("can-target", can_target),
515        }
516    }
517
518    /// A list of css classes applied to this widget.
519    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
520        Self {
521            builder: self.builder.property("css-classes", css_classes.into()),
522        }
523    }
524
525    /// The name of this widget in the CSS tree.
526    ///
527    /// This property is meant to be set by widget implementations,
528    /// typically in their instance init function.
529    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
530        Self {
531            builder: self.builder.property("css-name", css_name.into()),
532        }
533    }
534
535    /// The cursor used by @widget.
536    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
537        Self {
538            builder: self.builder.property("cursor", cursor.clone()),
539        }
540    }
541
542    /// Whether the widget should grab focus when it is clicked with the mouse.
543    ///
544    /// This property is only relevant for widgets that can take focus.
545    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
546        Self {
547            builder: self.builder.property("focus-on-click", focus_on_click),
548        }
549    }
550
551    /// Whether this widget itself will accept the input focus.
552    pub fn focusable(self, focusable: bool) -> Self {
553        Self {
554            builder: self.builder.property("focusable", focusable),
555        }
556    }
557
558    /// How to distribute horizontal space if widget gets extra space.
559    pub fn halign(self, halign: Align) -> Self {
560        Self {
561            builder: self.builder.property("halign", halign),
562        }
563    }
564
565    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
566    /// signal on @widget.
567    ///
568    /// A true value indicates that @widget can have a tooltip, in this case
569    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
570    /// determine whether it will provide a tooltip or not.
571    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
572        Self {
573            builder: self.builder.property("has-tooltip", has_tooltip),
574        }
575    }
576
577    /// Overrides for height request of the widget.
578    ///
579    /// If this is -1, the natural request will be used.
580    pub fn height_request(self, height_request: i32) -> Self {
581        Self {
582            builder: self.builder.property("height-request", height_request),
583        }
584    }
585
586    /// Whether to expand horizontally.
587    pub fn hexpand(self, hexpand: bool) -> Self {
588        Self {
589            builder: self.builder.property("hexpand", hexpand),
590        }
591    }
592
593    /// Whether to use the `hexpand` property.
594    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
595        Self {
596            builder: self.builder.property("hexpand-set", hexpand_set),
597        }
598    }
599
600    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
601    /// the preferred size of the widget, and allocate its children.
602    ///
603    /// This property is meant to be set by widget implementations,
604    /// typically in their instance init function.
605    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
606        Self {
607            builder: self
608                .builder
609                .property("layout-manager", layout_manager.clone().upcast()),
610        }
611    }
612
613    /// Makes this widget act like a modal dialog, with respect to
614    /// event delivery.
615    ///
616    /// Global event controllers will not handle events with targets
617    /// inside the widget, unless they are set up to ignore propagation
618    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
619    #[cfg(feature = "v4_18")]
620    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
621    pub fn limit_events(self, limit_events: bool) -> Self {
622        Self {
623            builder: self.builder.property("limit-events", limit_events),
624        }
625    }
626
627    /// Margin on bottom side of widget.
628    ///
629    /// This property adds margin outside of the widget's normal size
630    /// request, the margin will be added in addition to the size from
631    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
632    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
633        Self {
634            builder: self.builder.property("margin-bottom", margin_bottom),
635        }
636    }
637
638    /// Margin on end of widget, horizontally.
639    ///
640    /// This property supports left-to-right and right-to-left text
641    /// directions.
642    ///
643    /// This property adds margin outside of the widget's normal size
644    /// request, the margin will be added in addition to the size from
645    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
646    pub fn margin_end(self, margin_end: i32) -> Self {
647        Self {
648            builder: self.builder.property("margin-end", margin_end),
649        }
650    }
651
652    /// Margin on start of widget, horizontally.
653    ///
654    /// This property supports left-to-right and right-to-left text
655    /// directions.
656    ///
657    /// This property adds margin outside of the widget's normal size
658    /// request, the margin will be added in addition to the size from
659    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
660    pub fn margin_start(self, margin_start: i32) -> Self {
661        Self {
662            builder: self.builder.property("margin-start", margin_start),
663        }
664    }
665
666    /// Margin on top side of widget.
667    ///
668    /// This property adds margin outside of the widget's normal size
669    /// request, the margin will be added in addition to the size from
670    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
671    pub fn margin_top(self, margin_top: i32) -> Self {
672        Self {
673            builder: self.builder.property("margin-top", margin_top),
674        }
675    }
676
677    /// The name of the widget.
678    pub fn name(self, name: impl Into<glib::GString>) -> Self {
679        Self {
680            builder: self.builder.property("name", name.into()),
681        }
682    }
683
684    /// The requested opacity of the widget.
685    pub fn opacity(self, opacity: f64) -> Self {
686        Self {
687            builder: self.builder.property("opacity", opacity),
688        }
689    }
690
691    /// How content outside the widget's content area is treated.
692    ///
693    /// This property is meant to be set by widget implementations,
694    /// typically in their instance init function.
695    pub fn overflow(self, overflow: Overflow) -> Self {
696        Self {
697            builder: self.builder.property("overflow", overflow),
698        }
699    }
700
701    /// Whether the widget will receive the default action when it is focused.
702    pub fn receives_default(self, receives_default: bool) -> Self {
703        Self {
704            builder: self.builder.property("receives-default", receives_default),
705        }
706    }
707
708    /// Whether the widget responds to input.
709    pub fn sensitive(self, sensitive: bool) -> Self {
710        Self {
711            builder: self.builder.property("sensitive", sensitive),
712        }
713    }
714
715    /// Sets the text of tooltip to be the given string, which is marked up
716    /// with Pango markup.
717    ///
718    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
719    ///
720    /// This is a convenience property which will take care of getting the
721    /// tooltip shown if the given string is not `NULL`:
722    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
723    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
724    /// the default signal handler.
725    ///
726    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
727    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
728    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
729        Self {
730            builder: self
731                .builder
732                .property("tooltip-markup", tooltip_markup.into()),
733        }
734    }
735
736    /// Sets the text of tooltip to be the given string.
737    ///
738    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
739    ///
740    /// This is a convenience property which will take care of getting the
741    /// tooltip shown if the given string is not `NULL`:
742    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
743    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
744    /// the default signal handler.
745    ///
746    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
747    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
748    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
749        Self {
750            builder: self.builder.property("tooltip-text", tooltip_text.into()),
751        }
752    }
753
754    /// How to distribute vertical space if widget gets extra space.
755    pub fn valign(self, valign: Align) -> Self {
756        Self {
757            builder: self.builder.property("valign", valign),
758        }
759    }
760
761    /// Whether to expand vertically.
762    pub fn vexpand(self, vexpand: bool) -> Self {
763        Self {
764            builder: self.builder.property("vexpand", vexpand),
765        }
766    }
767
768    /// Whether to use the `vexpand` property.
769    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
770        Self {
771            builder: self.builder.property("vexpand-set", vexpand_set),
772        }
773    }
774
775    /// Whether the widget is visible.
776    pub fn visible(self, visible: bool) -> Self {
777        Self {
778            builder: self.builder.property("visible", visible),
779        }
780    }
781
782    /// Overrides for width request of the widget.
783    ///
784    /// If this is -1, the natural request will be used.
785    pub fn width_request(self, width_request: i32) -> Self {
786        Self {
787            builder: self.builder.property("width-request", width_request),
788        }
789    }
790
791    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
792    ///
793    /// The accessible role cannot be changed once set.
794    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
795        Self {
796            builder: self.builder.property("accessible-role", accessible_role),
797        }
798    }
799
800    /// The type of operation that the file chooser is performing.
801    /// Use [`FileDialog`][crate::FileDialog] instead
802    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
803    pub fn action(self, action: FileChooserAction) -> Self {
804        Self {
805            builder: self.builder.property("action", action),
806        }
807    }
808
809    /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
810    /// will offer the user to create new folders.
811    /// Use [`FileDialog`][crate::FileDialog] instead
812    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
813    pub fn create_folders(self, create_folders: bool) -> Self {
814        Self {
815            builder: self.builder.property("create-folders", create_folders),
816        }
817    }
818
819    /// The current filter for selecting files that are displayed.
820    /// Use [`FileDialog`][crate::FileDialog] instead
821    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
822    pub fn filter(self, filter: &FileFilter) -> Self {
823        Self {
824            builder: self.builder.property("filter", filter.clone()),
825        }
826    }
827
828    /// Whether to allow multiple files to be selected.
829    /// Use [`FileDialog`][crate::FileDialog] instead
830    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
831    pub fn select_multiple(self, select_multiple: bool) -> Self {
832        Self {
833            builder: self.builder.property("select-multiple", select_multiple),
834        }
835    }
836
837    // rustdoc-stripper-ignore-next
838    /// Build the [`FileChooserDialog`].
839    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
840    pub fn build(self) -> FileChooserDialog {
841        assert_initialized_main_thread!();
842        self.builder.build()
843    }
844}