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 /// the
24 /// implementation uses these known response codes to know which responses can
25 /// be blocked if appropriate.
26 ///
27 /// To summarize, make sure you use a predefined response code
28 /// when you use [`FileChooserDialog`][crate::FileChooserDialog] to ensure proper operation.
29 ///
30 /// ## CSS nodes
31 ///
32 /// [`FileChooserDialog`][crate::FileChooserDialog] has a single CSS node with the name `window` and style
33 /// class `.filechooser`.
34 ///
35 /// # Implements
36 ///
37 /// [`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]
38 #[doc(alias = "GtkFileChooserDialog")]
39 pub struct FileChooserDialog(Object<ffi::GtkFileChooserDialog>) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, FileChooser;
40
41 match fn {
42 type_ => || ffi::gtk_file_chooser_dialog_get_type(),
43 }
44}
45
46#[cfg(not(feature = "v4_10"))]
47glib::wrapper! {
48 #[doc(alias = "GtkFileChooserDialog")]
49 pub struct FileChooserDialog(Object<ffi::GtkFileChooserDialog>) @extends Dialog, Window, Widget, @implements Buildable, ConstraintTarget, Native, Root, ShortcutManager, FileChooser;
50
51 match fn {
52 type_ => || ffi::gtk_file_chooser_dialog_get_type(),
53 }
54}
55
56impl FileChooserDialog {
57 // rustdoc-stripper-ignore-next
58 /// Creates a new builder-pattern struct instance to construct [`FileChooserDialog`] objects.
59 ///
60 /// This method returns an instance of [`FileChooserDialogBuilder`](crate::builders::FileChooserDialogBuilder) which can be used to create [`FileChooserDialog`] objects.
61 pub fn builder() -> FileChooserDialogBuilder {
62 FileChooserDialogBuilder::new()
63 }
64}
65
66// rustdoc-stripper-ignore-next
67/// A [builder-pattern] type to construct [`FileChooserDialog`] objects.
68///
69/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
70#[must_use = "The builder must be built to be used"]
71pub struct FileChooserDialogBuilder {
72 builder: glib::object::ObjectBuilder<'static, FileChooserDialog>,
73}
74
75impl FileChooserDialogBuilder {
76 fn new() -> Self {
77 Self {
78 builder: glib::object::Object::builder(),
79 }
80 }
81
82 /// header, NULL);
83 /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
84 /// ```text
85 ///
86 /// Use [`Window`][crate::Window] instead
87 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
88 pub fn use_header_bar(self, use_header_bar: i32) -> Self {
89 Self {
90 builder: self.builder.property("use-header-bar", use_header_bar),
91 }
92 }
93
94 /// The [`Application`][crate::Application] associated with the window.
95 ///
96 /// The application will be kept alive for at least as long as it
97 /// has any windows associated with it (see g_application_hold()
98 /// for a way to keep it alive without windows).
99 ///
100 /// Normally, the connection between the application and the window
101 /// will remain until the window is destroyed, but you can explicitly
102 /// remove it by setting the this property to `NULL`.
103 pub fn application(self, application: &impl IsA<Application>) -> Self {
104 Self {
105 builder: self
106 .builder
107 .property("application", application.clone().upcast()),
108 }
109 }
110
111 /// The child widget.
112 pub fn child(self, child: &impl IsA<Widget>) -> Self {
113 Self {
114 builder: self.builder.property("child", child.clone().upcast()),
115 }
116 }
117
118 /// Whether the window should have a frame (also known as *decorations*).
119 pub fn decorated(self, decorated: bool) -> Self {
120 Self {
121 builder: self.builder.property("decorated", decorated),
122 }
123 }
124
125 /// The default height of the window.
126 pub fn default_height(self, default_height: i32) -> Self {
127 Self {
128 builder: self.builder.property("default-height", default_height),
129 }
130 }
131
132 /// The default widget.
133 pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
134 Self {
135 builder: self
136 .builder
137 .property("default-widget", default_widget.clone().upcast()),
138 }
139 }
140
141 /// The default width of the window.
142 pub fn default_width(self, default_width: i32) -> Self {
143 Self {
144 builder: self.builder.property("default-width", default_width),
145 }
146 }
147
148 /// Whether the window frame should have a close button.
149 pub fn deletable(self, deletable: bool) -> Self {
150 Self {
151 builder: self.builder.property("deletable", deletable),
152 }
153 }
154
155 /// If this window should be destroyed when the parent is destroyed.
156 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
157 Self {
158 builder: self
159 .builder
160 .property("destroy-with-parent", destroy_with_parent),
161 }
162 }
163
164 /// The display that will display this window.
165 pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
166 Self {
167 builder: self.builder.property("display", display.clone().upcast()),
168 }
169 }
170
171 /// Whether 'focus rectangles' are currently visible in this window.
172 ///
173 /// This property is maintained by GTK based on user input
174 /// and should not be set by applications.
175 pub fn focus_visible(self, focus_visible: bool) -> Self {
176 Self {
177 builder: self.builder.property("focus-visible", focus_visible),
178 }
179 }
180
181 /// The focus widget.
182 pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
183 Self {
184 builder: self
185 .builder
186 .property("focus-widget", focus_widget.clone().upcast()),
187 }
188 }
189
190 /// Whether the window is fullscreen.
191 ///
192 /// Setting this property is the equivalent of calling
193 /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
194 /// either operation is asynchronous, which means you will need to
195 /// connect to the ::notify signal in order to know whether the
196 /// operation was successful.
197 pub fn fullscreened(self, fullscreened: bool) -> Self {
198 Self {
199 builder: self.builder.property("fullscreened", fullscreened),
200 }
201 }
202
203 /// The gravity to use when resizing the window programmatically.
204 ///
205 /// Gravity describes which point of the window we want to keep
206 /// fixed (meaning that the window will grow in the opposite direction).
207 /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
208 /// want the to fix top right corner of the window.
209 #[cfg(feature = "v4_20")]
210 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
211 pub fn gravity(self, gravity: WindowGravity) -> Self {
212 Self {
213 builder: self.builder.property("gravity", gravity),
214 }
215 }
216
217 /// for activating
218 /// menubars.
219 #[cfg(feature = "v4_2")]
220 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
221 pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
222 Self {
223 builder: self
224 .builder
225 .property("handle-menubar-accel", handle_menubar_accel),
226 }
227 }
228
229 /// If this window should be hidden instead of destroyed when the user clicks
230 /// the close button.
231 pub fn hide_on_close(self, hide_on_close: bool) -> Self {
232 Self {
233 builder: self.builder.property("hide-on-close", hide_on_close),
234 }
235 }
236
237 /// Specifies the name of the themed icon to use as the window icon.
238 ///
239 /// See [`IconTheme`][crate::IconTheme] for more details.
240 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
241 Self {
242 builder: self.builder.property("icon-name", icon_name.into()),
243 }
244 }
245
246 /// Whether the window is maximized.
247 ///
248 /// Setting this property is the equivalent of calling
249 /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
250 /// either operation is asynchronous, which means you will need to
251 /// connect to the ::notify signal in order to know whether the
252 /// operation was successful.
253 pub fn maximized(self, maximized: bool) -> Self {
254 Self {
255 builder: self.builder.property("maximized", maximized),
256 }
257 }
258
259 /// Whether mnemonics are currently visible in this window.
260 ///
261 /// This property is maintained by GTK based on user input,
262 /// and should not be set by applications.
263 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
264 Self {
265 builder: self
266 .builder
267 .property("mnemonics-visible", mnemonics_visible),
268 }
269 }
270
271 /// If true, the window is modal.
272 pub fn modal(self, modal: bool) -> Self {
273 Self {
274 builder: self.builder.property("modal", modal),
275 }
276 }
277
278 /// If true, users can resize the window.
279 pub fn resizable(self, resizable: bool) -> Self {
280 Self {
281 builder: self.builder.property("resizable", resizable),
282 }
283 }
284
285 /// A write-only property for setting window's startup notification identifier.
286 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
287 Self {
288 builder: self.builder.property("startup-id", startup_id.into()),
289 }
290 }
291
292 /// The title of the window.
293 pub fn title(self, title: impl Into<glib::GString>) -> Self {
294 Self {
295 builder: self.builder.property("title", title.into()),
296 }
297 }
298
299 /// The titlebar widget.
300 #[cfg(feature = "v4_6")]
301 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
302 pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
303 Self {
304 builder: self.builder.property("titlebar", titlebar.clone().upcast()),
305 }
306 }
307
308 /// The transient parent of the window.
309 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
310 Self {
311 builder: self
312 .builder
313 .property("transient-for", transient_for.clone().upcast()),
314 }
315 }
316
317 /// Whether the widget or any of its descendents can accept
318 /// the input focus.
319 ///
320 /// This property is meant to be set by widget implementations,
321 /// typically in their instance init function.
322 pub fn can_focus(self, can_focus: bool) -> Self {
323 Self {
324 builder: self.builder.property("can-focus", can_focus),
325 }
326 }
327
328 /// Whether the widget can receive pointer events.
329 pub fn can_target(self, can_target: bool) -> Self {
330 Self {
331 builder: self.builder.property("can-target", can_target),
332 }
333 }
334
335 /// A list of css classes applied to this widget.
336 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
337 Self {
338 builder: self.builder.property("css-classes", css_classes.into()),
339 }
340 }
341
342 /// The name of this widget in the CSS tree.
343 ///
344 /// This property is meant to be set by widget implementations,
345 /// typically in their instance init function.
346 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
347 Self {
348 builder: self.builder.property("css-name", css_name.into()),
349 }
350 }
351
352 /// The cursor used by @widget.
353 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
354 Self {
355 builder: self.builder.property("cursor", cursor.clone()),
356 }
357 }
358
359 /// Whether the widget should grab focus when it is clicked with the mouse.
360 ///
361 /// This property is only relevant for widgets that can take focus.
362 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
363 Self {
364 builder: self.builder.property("focus-on-click", focus_on_click),
365 }
366 }
367
368 /// Whether this widget itself will accept the input focus.
369 pub fn focusable(self, focusable: bool) -> Self {
370 Self {
371 builder: self.builder.property("focusable", focusable),
372 }
373 }
374
375 /// How to distribute horizontal space if widget gets extra space.
376 pub fn halign(self, halign: Align) -> Self {
377 Self {
378 builder: self.builder.property("halign", halign),
379 }
380 }
381
382 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
383 /// signal on @widget.
384 ///
385 /// A true value indicates that @widget can have a tooltip, in this case
386 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
387 /// determine whether it will provide a tooltip or not.
388 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
389 Self {
390 builder: self.builder.property("has-tooltip", has_tooltip),
391 }
392 }
393
394 /// Overrides for height request of the widget.
395 ///
396 /// If this is -1, the natural request will be used.
397 pub fn height_request(self, height_request: i32) -> Self {
398 Self {
399 builder: self.builder.property("height-request", height_request),
400 }
401 }
402
403 /// Whether to expand horizontally.
404 pub fn hexpand(self, hexpand: bool) -> Self {
405 Self {
406 builder: self.builder.property("hexpand", hexpand),
407 }
408 }
409
410 /// Whether to use the `hexpand` property.
411 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
412 Self {
413 builder: self.builder.property("hexpand-set", hexpand_set),
414 }
415 }
416
417 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
418 /// the preferred size of the widget, and allocate its children.
419 ///
420 /// This property is meant to be set by widget implementations,
421 /// typically in their instance init function.
422 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
423 Self {
424 builder: self
425 .builder
426 .property("layout-manager", layout_manager.clone().upcast()),
427 }
428 }
429
430 /// Makes this widget act like a modal dialog, with respect to
431 /// event delivery.
432 ///
433 /// Global event controllers will not handle events with targets
434 /// inside the widget, unless they are set up to ignore propagation
435 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
436 #[cfg(feature = "v4_18")]
437 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
438 pub fn limit_events(self, limit_events: bool) -> Self {
439 Self {
440 builder: self.builder.property("limit-events", limit_events),
441 }
442 }
443
444 /// Margin on bottom side of widget.
445 ///
446 /// This property adds margin outside of the widget's normal size
447 /// request, the margin will be added in addition to the size from
448 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
449 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
450 Self {
451 builder: self.builder.property("margin-bottom", margin_bottom),
452 }
453 }
454
455 /// Margin on end of widget, horizontally.
456 ///
457 /// This property supports left-to-right and right-to-left text
458 /// directions.
459 ///
460 /// This property adds margin outside of the widget's normal size
461 /// request, the margin will be added in addition to the size from
462 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
463 pub fn margin_end(self, margin_end: i32) -> Self {
464 Self {
465 builder: self.builder.property("margin-end", margin_end),
466 }
467 }
468
469 /// Margin on start of widget, horizontally.
470 ///
471 /// This property supports left-to-right and right-to-left text
472 /// directions.
473 ///
474 /// This property adds margin outside of the widget's normal size
475 /// request, the margin will be added in addition to the size from
476 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
477 pub fn margin_start(self, margin_start: i32) -> Self {
478 Self {
479 builder: self.builder.property("margin-start", margin_start),
480 }
481 }
482
483 /// Margin on top side of widget.
484 ///
485 /// This property adds margin outside of the widget's normal size
486 /// request, the margin will be added in addition to the size from
487 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
488 pub fn margin_top(self, margin_top: i32) -> Self {
489 Self {
490 builder: self.builder.property("margin-top", margin_top),
491 }
492 }
493
494 /// The name of the widget.
495 pub fn name(self, name: impl Into<glib::GString>) -> Self {
496 Self {
497 builder: self.builder.property("name", name.into()),
498 }
499 }
500
501 /// The requested opacity of the widget.
502 pub fn opacity(self, opacity: f64) -> Self {
503 Self {
504 builder: self.builder.property("opacity", opacity),
505 }
506 }
507
508 /// How content outside the widget's content area is treated.
509 ///
510 /// This property is meant to be set by widget implementations,
511 /// typically in their instance init function.
512 pub fn overflow(self, overflow: Overflow) -> Self {
513 Self {
514 builder: self.builder.property("overflow", overflow),
515 }
516 }
517
518 /// Whether the widget will receive the default action when it is focused.
519 pub fn receives_default(self, receives_default: bool) -> Self {
520 Self {
521 builder: self.builder.property("receives-default", receives_default),
522 }
523 }
524
525 /// Whether the widget responds to input.
526 pub fn sensitive(self, sensitive: bool) -> Self {
527 Self {
528 builder: self.builder.property("sensitive", sensitive),
529 }
530 }
531
532 /// Sets the text of tooltip to be the given string, which is marked up
533 /// with Pango markup.
534 ///
535 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
536 ///
537 /// This is a convenience property which will take care of getting the
538 /// tooltip shown if the given string is not `NULL`:
539 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
540 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
541 /// the default signal handler.
542 ///
543 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
544 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
545 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
546 Self {
547 builder: self
548 .builder
549 .property("tooltip-markup", tooltip_markup.into()),
550 }
551 }
552
553 /// Sets the text of tooltip to be the given string.
554 ///
555 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
556 ///
557 /// This is a convenience property which will take care of getting the
558 /// tooltip shown if the given string is not `NULL`:
559 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
560 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
561 /// the default signal handler.
562 ///
563 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
564 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
565 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
566 Self {
567 builder: self.builder.property("tooltip-text", tooltip_text.into()),
568 }
569 }
570
571 /// How to distribute vertical space if widget gets extra space.
572 pub fn valign(self, valign: Align) -> Self {
573 Self {
574 builder: self.builder.property("valign", valign),
575 }
576 }
577
578 /// Whether to expand vertically.
579 pub fn vexpand(self, vexpand: bool) -> Self {
580 Self {
581 builder: self.builder.property("vexpand", vexpand),
582 }
583 }
584
585 /// Whether to use the `vexpand` property.
586 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
587 Self {
588 builder: self.builder.property("vexpand-set", vexpand_set),
589 }
590 }
591
592 /// Whether the widget is visible.
593 pub fn visible(self, visible: bool) -> Self {
594 Self {
595 builder: self.builder.property("visible", visible),
596 }
597 }
598
599 /// Overrides for width request of the widget.
600 ///
601 /// If this is -1, the natural request will be used.
602 pub fn width_request(self, width_request: i32) -> Self {
603 Self {
604 builder: self.builder.property("width-request", width_request),
605 }
606 }
607
608 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
609 ///
610 /// The accessible role cannot be changed once set.
611 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
612 Self {
613 builder: self.builder.property("accessible-role", accessible_role),
614 }
615 }
616
617 /// The type of operation that the file chooser is performing.
618 /// Use [`FileDialog`][crate::FileDialog] instead
619 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
620 pub fn action(self, action: FileChooserAction) -> Self {
621 Self {
622 builder: self.builder.property("action", action),
623 }
624 }
625
626 /// Whether a file chooser not in [`FileChooserAction::Open`][crate::FileChooserAction::Open] mode
627 /// will offer the user to create new folders.
628 /// Use [`FileDialog`][crate::FileDialog] instead
629 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
630 pub fn create_folders(self, create_folders: bool) -> Self {
631 Self {
632 builder: self.builder.property("create-folders", create_folders),
633 }
634 }
635
636 /// The current filter for selecting files that are displayed.
637 /// Use [`FileDialog`][crate::FileDialog] instead
638 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
639 pub fn filter(self, filter: &FileFilter) -> Self {
640 Self {
641 builder: self.builder.property("filter", filter.clone()),
642 }
643 }
644
645 /// Whether to allow multiple files to be selected.
646 /// Use [`FileDialog`][crate::FileDialog] instead
647 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
648 pub fn select_multiple(self, select_multiple: bool) -> Self {
649 Self {
650 builder: self.builder.property("select-multiple", select_multiple),
651 }
652 }
653
654 // rustdoc-stripper-ignore-next
655 /// Build the [`FileChooserDialog`].
656 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
657 pub fn build(self) -> FileChooserDialog {
658 assert_initialized_main_thread!();
659 self.builder.build()
660 }
661}