1#![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 #[doc(alias = "GtkFileChooserDialog")]
15 pub struct FileChooserDialog(Object<ffi::GtkFileChooserDialog>) @extends Dialog, Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager, FileChooser;
16
17 match fn {
18 type_ => || ffi::gtk_file_chooser_dialog_get_type(),
19 }
20}
21
22impl FileChooserDialog {
23 pub fn builder() -> FileChooserDialogBuilder {
28 FileChooserDialogBuilder::new()
29 }
30}
31
32#[must_use = "The builder must be built to be used"]
37pub struct FileChooserDialogBuilder {
38 builder: glib::object::ObjectBuilder<'static, FileChooserDialog>,
39}
40
41impl FileChooserDialogBuilder {
42 fn new() -> Self {
43 Self {
44 builder: glib::object::Object::builder(),
45 }
46 }
47
48 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
49 pub fn use_header_bar(self, use_header_bar: i32) -> Self {
50 Self {
51 builder: self.builder.property("use-header-bar", use_header_bar),
52 }
53 }
54
55 pub fn application(self, application: &impl IsA<Application>) -> Self {
56 Self {
57 builder: self
58 .builder
59 .property("application", application.clone().upcast()),
60 }
61 }
62
63 pub fn child(self, child: &impl IsA<Widget>) -> Self {
64 Self {
65 builder: self.builder.property("child", child.clone().upcast()),
66 }
67 }
68
69 pub fn decorated(self, decorated: bool) -> Self {
70 Self {
71 builder: self.builder.property("decorated", decorated),
72 }
73 }
74
75 pub fn default_height(self, default_height: i32) -> Self {
76 Self {
77 builder: self.builder.property("default-height", default_height),
78 }
79 }
80
81 pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
82 Self {
83 builder: self
84 .builder
85 .property("default-widget", default_widget.clone().upcast()),
86 }
87 }
88
89 pub fn default_width(self, default_width: i32) -> Self {
90 Self {
91 builder: self.builder.property("default-width", default_width),
92 }
93 }
94
95 pub fn deletable(self, deletable: bool) -> Self {
96 Self {
97 builder: self.builder.property("deletable", deletable),
98 }
99 }
100
101 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
102 Self {
103 builder: self
104 .builder
105 .property("destroy-with-parent", destroy_with_parent),
106 }
107 }
108
109 pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
110 Self {
111 builder: self.builder.property("display", display.clone().upcast()),
112 }
113 }
114
115 pub fn focus_visible(self, focus_visible: bool) -> Self {
116 Self {
117 builder: self.builder.property("focus-visible", focus_visible),
118 }
119 }
120
121 pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
122 Self {
123 builder: self
124 .builder
125 .property("focus-widget", focus_widget.clone().upcast()),
126 }
127 }
128
129 pub fn fullscreened(self, fullscreened: bool) -> Self {
130 Self {
131 builder: self.builder.property("fullscreened", fullscreened),
132 }
133 }
134
135 #[cfg(feature = "v4_2")]
136 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
137 pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
138 Self {
139 builder: self
140 .builder
141 .property("handle-menubar-accel", handle_menubar_accel),
142 }
143 }
144
145 pub fn hide_on_close(self, hide_on_close: bool) -> Self {
146 Self {
147 builder: self.builder.property("hide-on-close", hide_on_close),
148 }
149 }
150
151 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
152 Self {
153 builder: self.builder.property("icon-name", icon_name.into()),
154 }
155 }
156
157 pub fn maximized(self, maximized: bool) -> Self {
158 Self {
159 builder: self.builder.property("maximized", maximized),
160 }
161 }
162
163 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
164 Self {
165 builder: self
166 .builder
167 .property("mnemonics-visible", mnemonics_visible),
168 }
169 }
170
171 pub fn modal(self, modal: bool) -> Self {
172 Self {
173 builder: self.builder.property("modal", modal),
174 }
175 }
176
177 pub fn resizable(self, resizable: bool) -> Self {
178 Self {
179 builder: self.builder.property("resizable", resizable),
180 }
181 }
182
183 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
184 Self {
185 builder: self.builder.property("startup-id", startup_id.into()),
186 }
187 }
188
189 pub fn title(self, title: impl Into<glib::GString>) -> Self {
190 Self {
191 builder: self.builder.property("title", title.into()),
192 }
193 }
194
195 #[cfg(feature = "v4_6")]
196 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
197 pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
198 Self {
199 builder: self.builder.property("titlebar", titlebar.clone().upcast()),
200 }
201 }
202
203 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
204 Self {
205 builder: self
206 .builder
207 .property("transient-for", transient_for.clone().upcast()),
208 }
209 }
210
211 pub fn can_focus(self, can_focus: bool) -> Self {
212 Self {
213 builder: self.builder.property("can-focus", can_focus),
214 }
215 }
216
217 pub fn can_target(self, can_target: bool) -> Self {
218 Self {
219 builder: self.builder.property("can-target", can_target),
220 }
221 }
222
223 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
224 Self {
225 builder: self.builder.property("css-classes", css_classes.into()),
226 }
227 }
228
229 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
230 Self {
231 builder: self.builder.property("css-name", css_name.into()),
232 }
233 }
234
235 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
236 Self {
237 builder: self.builder.property("cursor", cursor.clone()),
238 }
239 }
240
241 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
242 Self {
243 builder: self.builder.property("focus-on-click", focus_on_click),
244 }
245 }
246
247 pub fn focusable(self, focusable: bool) -> Self {
248 Self {
249 builder: self.builder.property("focusable", focusable),
250 }
251 }
252
253 pub fn halign(self, halign: Align) -> Self {
254 Self {
255 builder: self.builder.property("halign", halign),
256 }
257 }
258
259 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
260 Self {
261 builder: self.builder.property("has-tooltip", has_tooltip),
262 }
263 }
264
265 pub fn height_request(self, height_request: i32) -> Self {
266 Self {
267 builder: self.builder.property("height-request", height_request),
268 }
269 }
270
271 pub fn hexpand(self, hexpand: bool) -> Self {
272 Self {
273 builder: self.builder.property("hexpand", hexpand),
274 }
275 }
276
277 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
278 Self {
279 builder: self.builder.property("hexpand-set", hexpand_set),
280 }
281 }
282
283 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
284 Self {
285 builder: self
286 .builder
287 .property("layout-manager", layout_manager.clone().upcast()),
288 }
289 }
290
291 #[cfg(feature = "v4_18")]
292 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
293 pub fn limit_events(self, limit_events: bool) -> Self {
294 Self {
295 builder: self.builder.property("limit-events", limit_events),
296 }
297 }
298
299 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
300 Self {
301 builder: self.builder.property("margin-bottom", margin_bottom),
302 }
303 }
304
305 pub fn margin_end(self, margin_end: i32) -> Self {
306 Self {
307 builder: self.builder.property("margin-end", margin_end),
308 }
309 }
310
311 pub fn margin_start(self, margin_start: i32) -> Self {
312 Self {
313 builder: self.builder.property("margin-start", margin_start),
314 }
315 }
316
317 pub fn margin_top(self, margin_top: i32) -> Self {
318 Self {
319 builder: self.builder.property("margin-top", margin_top),
320 }
321 }
322
323 pub fn name(self, name: impl Into<glib::GString>) -> Self {
324 Self {
325 builder: self.builder.property("name", name.into()),
326 }
327 }
328
329 pub fn opacity(self, opacity: f64) -> Self {
330 Self {
331 builder: self.builder.property("opacity", opacity),
332 }
333 }
334
335 pub fn overflow(self, overflow: Overflow) -> Self {
336 Self {
337 builder: self.builder.property("overflow", overflow),
338 }
339 }
340
341 pub fn receives_default(self, receives_default: bool) -> Self {
342 Self {
343 builder: self.builder.property("receives-default", receives_default),
344 }
345 }
346
347 pub fn sensitive(self, sensitive: bool) -> Self {
348 Self {
349 builder: self.builder.property("sensitive", sensitive),
350 }
351 }
352
353 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
354 Self {
355 builder: self
356 .builder
357 .property("tooltip-markup", tooltip_markup.into()),
358 }
359 }
360
361 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
362 Self {
363 builder: self.builder.property("tooltip-text", tooltip_text.into()),
364 }
365 }
366
367 pub fn valign(self, valign: Align) -> Self {
368 Self {
369 builder: self.builder.property("valign", valign),
370 }
371 }
372
373 pub fn vexpand(self, vexpand: bool) -> Self {
374 Self {
375 builder: self.builder.property("vexpand", vexpand),
376 }
377 }
378
379 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
380 Self {
381 builder: self.builder.property("vexpand-set", vexpand_set),
382 }
383 }
384
385 pub fn visible(self, visible: bool) -> Self {
386 Self {
387 builder: self.builder.property("visible", visible),
388 }
389 }
390
391 pub fn width_request(self, width_request: i32) -> Self {
392 Self {
393 builder: self.builder.property("width-request", width_request),
394 }
395 }
396
397 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
398 Self {
399 builder: self.builder.property("accessible-role", accessible_role),
400 }
401 }
402
403 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
404 pub fn action(self, action: FileChooserAction) -> Self {
405 Self {
406 builder: self.builder.property("action", action),
407 }
408 }
409
410 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
411 pub fn create_folders(self, create_folders: bool) -> Self {
412 Self {
413 builder: self.builder.property("create-folders", create_folders),
414 }
415 }
416
417 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
418 pub fn filter(self, filter: &FileFilter) -> Self {
419 Self {
420 builder: self.builder.property("filter", filter.clone()),
421 }
422 }
423
424 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
425 pub fn select_multiple(self, select_multiple: bool) -> Self {
426 Self {
427 builder: self.builder.property("select-multiple", select_multiple),
428 }
429 }
430
431 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
434 pub fn build(self) -> FileChooserDialog {
435 assert_initialized_main_thread!();
436 self.builder.build()
437 }
438}