gtk/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
5use crate::{
6 Align, Application, Bin, Buildable, Container, Dialog, FileChooser, FileChooserAction,
7 FileFilter, ResizeMode, Widget, Window, WindowPosition, WindowType,
8};
9use glib::prelude::*;
10use std::fmt;
11
12glib::wrapper! {
13 /// [`FileChooserDialog`][crate::FileChooserDialog] is a dialog box suitable for use with
14 /// “File/Open” or “File/Save as” commands. This widget works by
15 /// putting a [`FileChooserWidget`][crate::FileChooserWidget] inside a [`Dialog`][crate::Dialog]. It exposes
16 /// the [`FileChooser`][crate::FileChooser] interface, so you can use all of the
17 /// [`FileChooser`][crate::FileChooser] functions on the file chooser dialog as well as
18 /// those for [`Dialog`][crate::Dialog].
19 ///
20 /// Note that [`FileChooserDialog`][crate::FileChooserDialog] does not have any methods of its
21 /// own. Instead, you should use the functions that work on a
22 /// [`FileChooser`][crate::FileChooser].
23 ///
24 /// If you want to integrate well with the platform you should use the
25 /// [`FileChooserNative`][crate::FileChooserNative] API, which will use a platform-specific
26 /// dialog if available and fall back to GtkFileChooserDialog
27 /// otherwise.
28 ///
29 /// ## Typical usage ## {`gtkfilechooser`-typical-usage}
30 ///
31 /// In the simplest of cases, you can the following code to use
32 /// [`FileChooserDialog`][crate::FileChooserDialog] to select a file for opening:
33 ///
34 ///
35 /// ```text
36 /// GtkWidget *dialog;
37 /// GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
38 /// gint res;
39 ///
40 /// dialog = gtk_file_chooser_dialog_new ("Open File",
41 /// parent_window,
42 /// action,
43 /// _("_Cancel"),
44 /// GTK_RESPONSE_CANCEL,
45 /// _("_Open"),
46 /// GTK_RESPONSE_ACCEPT,
47 /// NULL);
48 ///
49 /// res = gtk_dialog_run (GTK_DIALOG (dialog));
50 /// if (res == GTK_RESPONSE_ACCEPT)
51 /// {
52 /// char *filename;
53 /// GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
54 /// filename = gtk_file_chooser_get_filename (chooser);
55 /// open_file (filename);
56 /// g_free (filename);
57 /// }
58 ///
59 /// gtk_widget_destroy (dialog);
60 /// ```
61 ///
62 /// To use a dialog for saving, you can use this:
63 ///
64 ///
65 /// ```text
66 /// GtkWidget *dialog;
67 /// GtkFileChooser *chooser;
68 /// GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_SAVE;
69 /// gint res;
70 ///
71 /// dialog = gtk_file_chooser_dialog_new ("Save File",
72 /// parent_window,
73 /// action,
74 /// _("_Cancel"),
75 /// GTK_RESPONSE_CANCEL,
76 /// _("_Save"),
77 /// GTK_RESPONSE_ACCEPT,
78 /// NULL);
79 /// chooser = GTK_FILE_CHOOSER (dialog);
80 ///
81 /// gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
82 ///
83 /// if (user_edited_a_new_document)
84 /// gtk_file_chooser_set_current_name (chooser,
85 /// _("Untitled document"));
86 /// else
87 /// gtk_file_chooser_set_filename (chooser,
88 /// existing_filename);
89 ///
90 /// res = gtk_dialog_run (GTK_DIALOG (dialog));
91 /// if (res == GTK_RESPONSE_ACCEPT)
92 /// {
93 /// char *filename;
94 ///
95 /// filename = gtk_file_chooser_get_filename (chooser);
96 /// save_to_file (filename);
97 /// g_free (filename);
98 /// }
99 ///
100 /// gtk_widget_destroy (dialog);
101 /// ```
102 ///
103 /// ## Setting up a file chooser dialog ## {`gtkfilechooserdialog`-setting-up}
104 ///
105 /// There are various cases in which you may need to use a [`FileChooserDialog`][crate::FileChooserDialog]:
106 ///
107 /// - To select a file for opening. Use [`FileChooserAction::Open`][crate::FileChooserAction::Open].
108 ///
109 /// - To save a file for the first time. Use [`FileChooserAction::Save`][crate::FileChooserAction::Save],
110 /// and suggest a name such as “Untitled” with [`FileChooserExt::set_current_name()`][crate::prelude::FileChooserExt::set_current_name()].
111 ///
112 /// - To save a file under a different name. Use [`FileChooserAction::Save`][crate::FileChooserAction::Save],
113 /// and set the existing filename with [`FileChooserExt::set_filename()`][crate::prelude::FileChooserExt::set_filename()].
114 ///
115 /// - To choose a folder instead of a file. Use [`FileChooserAction::SelectFolder`][crate::FileChooserAction::SelectFolder].
116 ///
117 /// Note that old versions of the file chooser’s documentation suggested
118 /// using [`FileChooserExt::set_current_folder()`][crate::prelude::FileChooserExt::set_current_folder()] in various
119 /// situations, with the intention of letting the application
120 /// suggest a reasonable default folder. This is no longer
121 /// considered to be a good policy, as now the file chooser is
122 /// able to make good suggestions on its own. In general, you
123 /// should only cause the file chooser to show a specific folder
124 /// when it is appropriate to use [`FileChooserExt::set_filename()`][crate::prelude::FileChooserExt::set_filename()],
125 /// i.e. when you are doing a Save As command and you already
126 /// have a file saved somewhere.
127 ///
128 /// ## Response Codes ## {`gtkfilechooserdialog`-responses}
129 ///
130 /// [`FileChooserDialog`][crate::FileChooserDialog] inherits from [`Dialog`][crate::Dialog], so buttons that
131 /// go in its action area have response codes such as
132 /// [`ResponseType::Accept`][crate::ResponseType::Accept] and [`ResponseType::Cancel`][crate::ResponseType::Cancel]. For example, you
133 /// could call `gtk_file_chooser_dialog_new()` as follows:
134 ///
135 ///
136 /// ```text
137 /// GtkWidget *dialog;
138 /// GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
139 ///
140 /// dialog = gtk_file_chooser_dialog_new ("Open File",
141 /// parent_window,
142 /// action,
143 /// _("_Cancel"),
144 /// GTK_RESPONSE_CANCEL,
145 /// _("_Open"),
146 /// GTK_RESPONSE_ACCEPT,
147 /// NULL);
148 /// ```
149 ///
150 /// This will create buttons for “Cancel” and “Open” that use stock
151 /// response identifiers from [`ResponseType`][crate::ResponseType]. For most dialog
152 /// boxes you can use your own custom response codes rather than the
153 /// ones in [`ResponseType`][crate::ResponseType], but [`FileChooserDialog`][crate::FileChooserDialog] assumes that
154 /// its “accept”-type action, e.g. an “Open” or “Save” button,
155 /// will have one of the following response codes:
156 ///
157 /// - [`ResponseType::Accept`][crate::ResponseType::Accept]
158 /// - [`ResponseType::Ok`][crate::ResponseType::Ok]
159 /// - [`ResponseType::Yes`][crate::ResponseType::Yes]
160 /// - [`ResponseType::Apply`][crate::ResponseType::Apply]
161 ///
162 /// This is because [`FileChooserDialog`][crate::FileChooserDialog] must intercept responses
163 /// and switch to folders if appropriate, rather than letting the
164 /// dialog terminate — the implementation uses these known
165 /// response codes to know which responses can be blocked if
166 /// appropriate.
167 ///
168 /// To summarize, make sure you use a
169 /// [stock response code][gtkfilechooserdialog-responses]
170 /// when you use [`FileChooserDialog`][crate::FileChooserDialog] to ensure proper operation.
171 ///
172 /// # Implements
173 ///
174 /// [`DialogExt`][trait@crate::prelude::DialogExt], [`GtkWindowExt`][trait@crate::prelude::GtkWindowExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`FileChooserExt`][trait@crate::prelude::FileChooserExt], [`DialogExtManual`][trait@crate::prelude::DialogExtManual], [`GtkWindowExtManual`][trait@crate::prelude::GtkWindowExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual], [`FileChooserExtManual`][trait@crate::prelude::FileChooserExtManual]
175 #[doc(alias = "GtkFileChooserDialog")]
176 pub struct FileChooserDialog(Object<ffi::GtkFileChooserDialog, ffi::GtkFileChooserDialogClass>) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, FileChooser;
177
178 match fn {
179 type_ => || ffi::gtk_file_chooser_dialog_get_type(),
180 }
181}
182
183impl FileChooserDialog {
184 pub const NONE: Option<&'static FileChooserDialog> = None;
185
186 //#[doc(alias = "gtk_file_chooser_dialog_new")]
187 //pub fn new(title: Option<&str>, parent: Option<&impl IsA<Window>>, action: FileChooserAction, first_button_text: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> FileChooserDialog {
188 // unsafe { TODO: call ffi:gtk_file_chooser_dialog_new() }
189 //}
190
191 // rustdoc-stripper-ignore-next
192 /// Creates a new builder-pattern struct instance to construct [`FileChooserDialog`] objects.
193 ///
194 /// This method returns an instance of [`FileChooserDialogBuilder`](crate::builders::FileChooserDialogBuilder) which can be used to create [`FileChooserDialog`] objects.
195 pub fn builder() -> FileChooserDialogBuilder {
196 FileChooserDialogBuilder::new()
197 }
198}
199
200impl Default for FileChooserDialog {
201 fn default() -> Self {
202 glib::object::Object::new::<Self>()
203 }
204}
205
206// rustdoc-stripper-ignore-next
207/// A [builder-pattern] type to construct [`FileChooserDialog`] objects.
208///
209/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
210#[must_use = "The builder must be built to be used"]
211pub struct FileChooserDialogBuilder {
212 builder: glib::object::ObjectBuilder<'static, FileChooserDialog>,
213}
214
215impl FileChooserDialogBuilder {
216 fn new() -> Self {
217 Self {
218 builder: glib::object::Object::builder(),
219 }
220 }
221
222 /// [`true`] if the dialog uses a [`HeaderBar`][crate::HeaderBar] for action buttons
223 /// instead of the action-area.
224 ///
225 /// For technical reasons, this property is declared as an integer
226 /// property, but you should only set it to [`true`] or [`false`].
227 pub fn use_header_bar(self, use_header_bar: i32) -> Self {
228 Self {
229 builder: self.builder.property("use-header-bar", use_header_bar),
230 }
231 }
232
233 /// Whether the window should receive the input focus.
234 pub fn accept_focus(self, accept_focus: bool) -> Self {
235 Self {
236 builder: self.builder.property("accept-focus", accept_focus),
237 }
238 }
239
240 /// The [`Application`][crate::Application] associated with the window.
241 ///
242 /// The application will be kept alive for at least as long as it
243 /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
244 /// for a way to keep it alive without windows).
245 ///
246 /// Normally, the connection between the application and the window
247 /// will remain until the window is destroyed, but you can explicitly
248 /// remove it by setting the :application property to [`None`].
249 pub fn application(self, application: &impl IsA<Application>) -> Self {
250 Self {
251 builder: self
252 .builder
253 .property("application", application.clone().upcast()),
254 }
255 }
256
257 /// The widget to which this window is attached.
258 /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
259 ///
260 /// Examples of places where specifying this relation is useful are
261 /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
262 /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
263 /// created by [`TreeView`][crate::TreeView].
264 pub fn attached_to(self, attached_to: &impl IsA<Widget>) -> Self {
265 Self {
266 builder: self
267 .builder
268 .property("attached-to", attached_to.clone().upcast()),
269 }
270 }
271
272 /// Whether the window should be decorated by the window manager.
273 pub fn decorated(self, decorated: bool) -> Self {
274 Self {
275 builder: self.builder.property("decorated", decorated),
276 }
277 }
278
279 pub fn default_height(self, default_height: i32) -> Self {
280 Self {
281 builder: self.builder.property("default-height", default_height),
282 }
283 }
284
285 pub fn default_width(self, default_width: i32) -> Self {
286 Self {
287 builder: self.builder.property("default-width", default_width),
288 }
289 }
290
291 /// Whether the window frame should have a close button.
292 pub fn deletable(self, deletable: bool) -> Self {
293 Self {
294 builder: self.builder.property("deletable", deletable),
295 }
296 }
297
298 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
299 Self {
300 builder: self
301 .builder
302 .property("destroy-with-parent", destroy_with_parent),
303 }
304 }
305
306 /// Whether the window should receive the input focus when mapped.
307 pub fn focus_on_map(self, focus_on_map: bool) -> Self {
308 Self {
309 builder: self.builder.property("focus-on-map", focus_on_map),
310 }
311 }
312
313 /// Whether 'focus rectangles' are currently visible in this window.
314 ///
315 /// This property is maintained by GTK+ based on user input
316 /// and should not be set by applications.
317 pub fn focus_visible(self, focus_visible: bool) -> Self {
318 Self {
319 builder: self.builder.property("focus-visible", focus_visible),
320 }
321 }
322
323 /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
324 /// more details about window gravity.
325 pub fn gravity(self, gravity: gdk::Gravity) -> Self {
326 Self {
327 builder: self.builder.property("gravity", gravity),
328 }
329 }
330
331 /// Whether the titlebar should be hidden during maximization.
332 pub fn hide_titlebar_when_maximized(self, hide_titlebar_when_maximized: bool) -> Self {
333 Self {
334 builder: self
335 .builder
336 .property("hide-titlebar-when-maximized", hide_titlebar_when_maximized),
337 }
338 }
339
340 pub fn icon(self, icon: &gdk_pixbuf::Pixbuf) -> Self {
341 Self {
342 builder: self.builder.property("icon", icon.clone()),
343 }
344 }
345
346 /// The :icon-name property specifies the name of the themed icon to
347 /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
348 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
349 Self {
350 builder: self.builder.property("icon-name", icon_name.into()),
351 }
352 }
353
354 /// Whether mnemonics 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 mnemonics_visible(self, mnemonics_visible: bool) -> Self {
359 Self {
360 builder: self
361 .builder
362 .property("mnemonics-visible", mnemonics_visible),
363 }
364 }
365
366 pub fn modal(self, modal: bool) -> Self {
367 Self {
368 builder: self.builder.property("modal", modal),
369 }
370 }
371
372 pub fn resizable(self, resizable: bool) -> Self {
373 Self {
374 builder: self.builder.property("resizable", resizable),
375 }
376 }
377
378 pub fn role(self, role: impl Into<glib::GString>) -> Self {
379 Self {
380 builder: self.builder.property("role", role.into()),
381 }
382 }
383
384 pub fn screen(self, screen: &gdk::Screen) -> Self {
385 Self {
386 builder: self.builder.property("screen", screen.clone()),
387 }
388 }
389
390 pub fn skip_pager_hint(self, skip_pager_hint: bool) -> Self {
391 Self {
392 builder: self.builder.property("skip-pager-hint", skip_pager_hint),
393 }
394 }
395
396 pub fn skip_taskbar_hint(self, skip_taskbar_hint: bool) -> Self {
397 Self {
398 builder: self
399 .builder
400 .property("skip-taskbar-hint", skip_taskbar_hint),
401 }
402 }
403
404 /// The :startup-id is a write-only property for setting window's
405 /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
406 /// for more details.
407 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
408 Self {
409 builder: self.builder.property("startup-id", startup_id.into()),
410 }
411 }
412
413 pub fn title(self, title: impl Into<glib::GString>) -> Self {
414 Self {
415 builder: self.builder.property("title", title.into()),
416 }
417 }
418
419 /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
420 /// more details about transient windows.
421 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
422 Self {
423 builder: self
424 .builder
425 .property("transient-for", transient_for.clone().upcast()),
426 }
427 }
428
429 pub fn type_(self, type_: WindowType) -> Self {
430 Self {
431 builder: self.builder.property("type", type_),
432 }
433 }
434
435 pub fn type_hint(self, type_hint: gdk::WindowTypeHint) -> Self {
436 Self {
437 builder: self.builder.property("type-hint", type_hint),
438 }
439 }
440
441 pub fn urgency_hint(self, urgency_hint: bool) -> Self {
442 Self {
443 builder: self.builder.property("urgency-hint", urgency_hint),
444 }
445 }
446
447 pub fn window_position(self, window_position: WindowPosition) -> Self {
448 Self {
449 builder: self.builder.property("window-position", window_position),
450 }
451 }
452
453 pub fn border_width(self, border_width: u32) -> Self {
454 Self {
455 builder: self.builder.property("border-width", border_width),
456 }
457 }
458
459 pub fn child(self, child: &impl IsA<Widget>) -> Self {
460 Self {
461 builder: self.builder.property("child", child.clone().upcast()),
462 }
463 }
464
465 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
466 Self {
467 builder: self.builder.property("resize-mode", resize_mode),
468 }
469 }
470
471 pub fn app_paintable(self, app_paintable: bool) -> Self {
472 Self {
473 builder: self.builder.property("app-paintable", app_paintable),
474 }
475 }
476
477 pub fn can_default(self, can_default: bool) -> Self {
478 Self {
479 builder: self.builder.property("can-default", can_default),
480 }
481 }
482
483 pub fn can_focus(self, can_focus: bool) -> Self {
484 Self {
485 builder: self.builder.property("can-focus", can_focus),
486 }
487 }
488
489 pub fn events(self, events: gdk::EventMask) -> Self {
490 Self {
491 builder: self.builder.property("events", events),
492 }
493 }
494
495 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
496 pub fn expand(self, expand: bool) -> Self {
497 Self {
498 builder: self.builder.property("expand", expand),
499 }
500 }
501
502 /// Whether the widget should grab focus when it is clicked with the mouse.
503 ///
504 /// This property is only relevant for widgets that can take focus.
505 ///
506 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
507 /// GtkComboBox) implemented this property individually.
508 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
509 Self {
510 builder: self.builder.property("focus-on-click", focus_on_click),
511 }
512 }
513
514 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
515 pub fn halign(self, halign: Align) -> Self {
516 Self {
517 builder: self.builder.property("halign", halign),
518 }
519 }
520
521 pub fn has_default(self, has_default: bool) -> Self {
522 Self {
523 builder: self.builder.property("has-default", has_default),
524 }
525 }
526
527 pub fn has_focus(self, has_focus: bool) -> Self {
528 Self {
529 builder: self.builder.property("has-focus", has_focus),
530 }
531 }
532
533 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
534 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
535 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
536 /// whether it will provide a tooltip or not.
537 ///
538 /// Note that setting this property to [`true`] for the first time will change
539 /// the event masks of the GdkWindows of this widget to include leave-notify
540 /// and motion-notify events. This cannot and will not be undone when the
541 /// property is set to [`false`] again.
542 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
543 Self {
544 builder: self.builder.property("has-tooltip", has_tooltip),
545 }
546 }
547
548 pub fn height_request(self, height_request: i32) -> Self {
549 Self {
550 builder: self.builder.property("height-request", height_request),
551 }
552 }
553
554 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
555 pub fn hexpand(self, hexpand: bool) -> Self {
556 Self {
557 builder: self.builder.property("hexpand", hexpand),
558 }
559 }
560
561 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
562 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
563 Self {
564 builder: self.builder.property("hexpand-set", hexpand_set),
565 }
566 }
567
568 pub fn is_focus(self, is_focus: bool) -> Self {
569 Self {
570 builder: self.builder.property("is-focus", is_focus),
571 }
572 }
573
574 /// Sets all four sides' margin at once. If read, returns max
575 /// margin on any side.
576 pub fn margin(self, margin: i32) -> Self {
577 Self {
578 builder: self.builder.property("margin", margin),
579 }
580 }
581
582 /// Margin on bottom side of widget.
583 ///
584 /// This property adds margin outside of the widget's normal size
585 /// request, the margin will be added in addition to the size from
586 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
587 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
588 Self {
589 builder: self.builder.property("margin-bottom", margin_bottom),
590 }
591 }
592
593 /// Margin on end of widget, horizontally. This property supports
594 /// left-to-right and right-to-left text directions.
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_end(self, margin_end: i32) -> Self {
600 Self {
601 builder: self.builder.property("margin-end", margin_end),
602 }
603 }
604
605 /// Margin on start of widget, horizontally. This property supports
606 /// left-to-right and right-to-left text directions.
607 ///
608 /// This property adds margin outside of the widget's normal size
609 /// request, the margin will be added in addition to the size from
610 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
611 pub fn margin_start(self, margin_start: i32) -> Self {
612 Self {
613 builder: self.builder.property("margin-start", margin_start),
614 }
615 }
616
617 /// Margin on top side of widget.
618 ///
619 /// This property adds margin outside of the widget's normal size
620 /// request, the margin will be added in addition to the size from
621 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
622 pub fn margin_top(self, margin_top: i32) -> Self {
623 Self {
624 builder: self.builder.property("margin-top", margin_top),
625 }
626 }
627
628 pub fn name(self, name: impl Into<glib::GString>) -> Self {
629 Self {
630 builder: self.builder.property("name", name.into()),
631 }
632 }
633
634 pub fn no_show_all(self, no_show_all: bool) -> Self {
635 Self {
636 builder: self.builder.property("no-show-all", no_show_all),
637 }
638 }
639
640 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
641 /// more details about window opacity.
642 ///
643 /// Before 3.8 this was only available in GtkWindow
644 pub fn opacity(self, opacity: f64) -> Self {
645 Self {
646 builder: self.builder.property("opacity", opacity),
647 }
648 }
649
650 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
651 Self {
652 builder: self.builder.property("parent", parent.clone().upcast()),
653 }
654 }
655
656 pub fn receives_default(self, receives_default: bool) -> Self {
657 Self {
658 builder: self.builder.property("receives-default", receives_default),
659 }
660 }
661
662 pub fn sensitive(self, sensitive: bool) -> Self {
663 Self {
664 builder: self.builder.property("sensitive", sensitive),
665 }
666 }
667
668 /// Sets the text of tooltip to be the given string, which is marked up
669 /// with the [Pango text markup language][PangoMarkupFormat].
670 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
671 ///
672 /// This is a convenience property which will take care of getting the
673 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
674 /// will automatically be set to [`true`] and there will be taken care of
675 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
676 ///
677 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
678 /// are set, the last one wins.
679 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
680 Self {
681 builder: self
682 .builder
683 .property("tooltip-markup", tooltip_markup.into()),
684 }
685 }
686
687 /// Sets the text of tooltip to be the given string.
688 ///
689 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
690 ///
691 /// This is a convenience property which will take care of getting the
692 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
693 /// will automatically be set to [`true`] and there will be taken care of
694 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
695 ///
696 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
697 /// are set, the last one wins.
698 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
699 Self {
700 builder: self.builder.property("tooltip-text", tooltip_text.into()),
701 }
702 }
703
704 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
705 pub fn valign(self, valign: Align) -> Self {
706 Self {
707 builder: self.builder.property("valign", valign),
708 }
709 }
710
711 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
712 pub fn vexpand(self, vexpand: bool) -> Self {
713 Self {
714 builder: self.builder.property("vexpand", vexpand),
715 }
716 }
717
718 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
719 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
720 Self {
721 builder: self.builder.property("vexpand-set", vexpand_set),
722 }
723 }
724
725 pub fn visible(self, visible: bool) -> Self {
726 Self {
727 builder: self.builder.property("visible", visible),
728 }
729 }
730
731 pub fn width_request(self, width_request: i32) -> Self {
732 Self {
733 builder: self.builder.property("width-request", width_request),
734 }
735 }
736
737 pub fn action(self, action: FileChooserAction) -> Self {
738 Self {
739 builder: self.builder.property("action", action),
740 }
741 }
742
743 /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
744 /// will offer the user to create new folders.
745 pub fn create_folders(self, create_folders: bool) -> Self {
746 Self {
747 builder: self.builder.property("create-folders", create_folders),
748 }
749 }
750
751 /// Whether a file chooser in [`FileChooserAction::Save`][crate::FileChooserAction::Save] mode
752 /// will present an overwrite confirmation dialog if the user
753 /// selects a file name that already exists.
754 pub fn do_overwrite_confirmation(self, do_overwrite_confirmation: bool) -> Self {
755 Self {
756 builder: self
757 .builder
758 .property("do-overwrite-confirmation", do_overwrite_confirmation),
759 }
760 }
761
762 pub fn extra_widget(self, extra_widget: &impl IsA<Widget>) -> Self {
763 Self {
764 builder: self
765 .builder
766 .property("extra-widget", extra_widget.clone().upcast()),
767 }
768 }
769
770 pub fn filter(self, filter: &FileFilter) -> Self {
771 Self {
772 builder: self.builder.property("filter", filter.clone()),
773 }
774 }
775
776 pub fn local_only(self, local_only: bool) -> Self {
777 Self {
778 builder: self.builder.property("local-only", local_only),
779 }
780 }
781
782 pub fn preview_widget(self, preview_widget: &impl IsA<Widget>) -> Self {
783 Self {
784 builder: self
785 .builder
786 .property("preview-widget", preview_widget.clone().upcast()),
787 }
788 }
789
790 pub fn preview_widget_active(self, preview_widget_active: bool) -> Self {
791 Self {
792 builder: self
793 .builder
794 .property("preview-widget-active", preview_widget_active),
795 }
796 }
797
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 pub fn show_hidden(self, show_hidden: bool) -> Self {
805 Self {
806 builder: self.builder.property("show-hidden", show_hidden),
807 }
808 }
809
810 pub fn use_preview_label(self, use_preview_label: bool) -> Self {
811 Self {
812 builder: self
813 .builder
814 .property("use-preview-label", use_preview_label),
815 }
816 }
817
818 // rustdoc-stripper-ignore-next
819 /// Build the [`FileChooserDialog`].
820 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
821 pub fn build(self) -> FileChooserDialog {
822 self.builder.build()
823 }
824}
825
826impl fmt::Display for FileChooserDialog {
827 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
828 f.write_str("FileChooserDialog")
829 }
830}