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