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