gtk/auto/app_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, AppChooser, Application, Bin, Buildable, Container, Dialog, DialogFlags, ResizeMode,
7 Widget, Window, WindowPosition, WindowType, ffi,
8};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17 /// [`AppChooserDialog`][crate::AppChooserDialog] shows a [`AppChooserWidget`][crate::AppChooserWidget] inside a [`Dialog`][crate::Dialog].
18 ///
19 /// Note that [`AppChooserDialog`][crate::AppChooserDialog] does not have any interesting methods
20 /// of its own. Instead, you should get the embedded [`AppChooserWidget`][crate::AppChooserWidget]
21 /// using [`AppChooserDialogExt::widget()`][crate::prelude::AppChooserDialogExt::widget()] and call its methods if
22 /// the generic [`AppChooser`][crate::AppChooser] interface is not sufficient for your needs.
23 ///
24 /// To set the heading that is shown above the [`AppChooserWidget`][crate::AppChooserWidget],
25 /// use [`AppChooserDialogExt::set_heading()`][crate::prelude::AppChooserDialogExt::set_heading()].
26 ///
27 /// ## Properties
28 ///
29 ///
30 /// #### `gfile`
31 /// The GFile used by the [`AppChooserDialog`][crate::AppChooserDialog].
32 /// The dialog's [`AppChooserWidget`][crate::AppChooserWidget] content type will be guessed from the
33 /// file, if present.
34 ///
35 /// Readable | Writable | Construct Only
36 ///
37 ///
38 /// #### `heading`
39 /// The text to show at the top of the dialog.
40 /// The string may contain Pango markup.
41 ///
42 /// Readable | Writable
43 /// <details><summary><h4>Dialog</h4></summary>
44 ///
45 ///
46 /// #### `use-header-bar`
47 /// [`true`] if the dialog uses a [`HeaderBar`][crate::HeaderBar] for action buttons
48 /// instead of the action-area.
49 ///
50 /// For technical reasons, this property is declared as an integer
51 /// property, but you should only set it to [`true`] or [`false`].
52 ///
53 /// Readable | Writable | Construct Only
54 /// </details>
55 /// <details><summary><h4>Window</h4></summary>
56 ///
57 ///
58 /// #### `accept-focus`
59 /// Whether the window should receive the input focus.
60 ///
61 /// Readable | Writable
62 ///
63 ///
64 /// #### `application`
65 /// The [`Application`][crate::Application] associated with the window.
66 ///
67 /// The application will be kept alive for at least as long as it
68 /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
69 /// for a way to keep it alive without windows).
70 ///
71 /// Normally, the connection between the application and the window
72 /// will remain until the window is destroyed, but you can explicitly
73 /// remove it by setting the :application property to [`None`].
74 ///
75 /// Readable | Writable
76 ///
77 ///
78 /// #### `attached-to`
79 /// The widget to which this window is attached.
80 /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
81 ///
82 /// Examples of places where specifying this relation is useful are
83 /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
84 /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
85 /// created by [`TreeView`][crate::TreeView].
86 ///
87 /// Readable | Writable | Construct
88 ///
89 ///
90 /// #### `decorated`
91 /// Whether the window should be decorated by the window manager.
92 ///
93 /// Readable | Writable
94 ///
95 ///
96 /// #### `default-height`
97 /// Readable | Writable
98 ///
99 ///
100 /// #### `default-width`
101 /// Readable | Writable
102 ///
103 ///
104 /// #### `deletable`
105 /// Whether the window frame should have a close button.
106 ///
107 /// Readable | Writable
108 ///
109 ///
110 /// #### `destroy-with-parent`
111 /// Readable | Writable
112 ///
113 ///
114 /// #### `focus-on-map`
115 /// Whether the window should receive the input focus when mapped.
116 ///
117 /// Readable | Writable
118 ///
119 ///
120 /// #### `focus-visible`
121 /// Whether 'focus rectangles' are currently visible in this window.
122 ///
123 /// This property is maintained by GTK+ based on user input
124 /// and should not be set by applications.
125 ///
126 /// Readable | Writable
127 ///
128 ///
129 /// #### `gravity`
130 /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
131 /// more details about window gravity.
132 ///
133 /// Readable | Writable
134 ///
135 ///
136 /// #### `has-resize-grip`
137 /// Whether the window has a corner resize grip.
138 ///
139 /// Note that the resize grip is only shown if the window is
140 /// actually resizable and not maximized. Use
141 /// [`resize-grip-visible`][struct@crate::Window#resize-grip-visible] to find out if the resize
142 /// grip is currently shown.
143 ///
144 /// Readable | Writable
145 ///
146 ///
147 /// #### `has-toplevel-focus`
148 /// Readable
149 ///
150 ///
151 /// #### `hide-titlebar-when-maximized`
152 /// Whether the titlebar should be hidden during maximization.
153 ///
154 /// Readable | Writable
155 ///
156 ///
157 /// #### `icon`
158 /// Readable | Writable
159 ///
160 ///
161 /// #### `icon-name`
162 /// The :icon-name property specifies the name of the themed icon to
163 /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
164 ///
165 /// Readable | Writable
166 ///
167 ///
168 /// #### `is-active`
169 /// Readable
170 ///
171 ///
172 /// #### `is-maximized`
173 /// Readable
174 ///
175 ///
176 /// #### `mnemonics-visible`
177 /// Whether mnemonics are currently visible in this window.
178 ///
179 /// This property is maintained by GTK+ based on user input,
180 /// and should not be set by applications.
181 ///
182 /// Readable | Writable
183 ///
184 ///
185 /// #### `modal`
186 /// Readable | Writable
187 ///
188 ///
189 /// #### `resizable`
190 /// Readable | Writable
191 ///
192 ///
193 /// #### `resize-grip-visible`
194 /// Whether a corner resize grip is currently shown.
195 ///
196 /// Readable
197 ///
198 ///
199 /// #### `role`
200 /// Readable | Writable
201 ///
202 ///
203 /// #### `screen`
204 /// Readable | Writable
205 ///
206 ///
207 /// #### `skip-pager-hint`
208 /// Readable | Writable
209 ///
210 ///
211 /// #### `skip-taskbar-hint`
212 /// Readable | Writable
213 ///
214 ///
215 /// #### `startup-id`
216 /// The :startup-id is a write-only property for setting window's
217 /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
218 /// for more details.
219 ///
220 /// Writable
221 ///
222 ///
223 /// #### `title`
224 /// Readable | Writable
225 ///
226 ///
227 /// #### `transient-for`
228 /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
229 /// more details about transient windows.
230 ///
231 /// Readable | Writable | Construct
232 ///
233 ///
234 /// #### `type`
235 /// Readable | Writable | Construct Only
236 ///
237 ///
238 /// #### `type-hint`
239 /// Readable | Writable
240 ///
241 ///
242 /// #### `urgency-hint`
243 /// Readable | Writable
244 ///
245 ///
246 /// #### `window-position`
247 /// Readable | Writable
248 /// </details>
249 /// <details><summary><h4>Container</h4></summary>
250 ///
251 ///
252 /// #### `border-width`
253 /// Readable | Writable
254 ///
255 ///
256 /// #### `child`
257 /// Writable
258 ///
259 ///
260 /// #### `resize-mode`
261 /// Readable | Writable
262 /// </details>
263 /// <details><summary><h4>Widget</h4></summary>
264 ///
265 ///
266 /// #### `app-paintable`
267 /// Readable | Writable
268 ///
269 ///
270 /// #### `can-default`
271 /// Readable | Writable
272 ///
273 ///
274 /// #### `can-focus`
275 /// Readable | Writable
276 ///
277 ///
278 /// #### `composite-child`
279 /// Readable
280 ///
281 ///
282 /// #### `double-buffered`
283 /// Whether the widget is double buffered.
284 ///
285 /// Readable | Writable
286 ///
287 ///
288 /// #### `events`
289 /// Readable | Writable
290 ///
291 ///
292 /// #### `expand`
293 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
294 ///
295 /// Readable | Writable
296 ///
297 ///
298 /// #### `focus-on-click`
299 /// Whether the widget should grab focus when it is clicked with the mouse.
300 ///
301 /// This property is only relevant for widgets that can take focus.
302 ///
303 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
304 /// GtkComboBox) implemented this property individually.
305 ///
306 /// Readable | Writable
307 ///
308 ///
309 /// #### `halign`
310 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
311 ///
312 /// Readable | Writable
313 ///
314 ///
315 /// #### `has-default`
316 /// Readable | Writable
317 ///
318 ///
319 /// #### `has-focus`
320 /// Readable | Writable
321 ///
322 ///
323 /// #### `has-tooltip`
324 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
325 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
326 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
327 /// whether it will provide a tooltip or not.
328 ///
329 /// Note that setting this property to [`true`] for the first time will change
330 /// the event masks of the GdkWindows of this widget to include leave-notify
331 /// and motion-notify events. This cannot and will not be undone when the
332 /// property is set to [`false`] again.
333 ///
334 /// Readable | Writable
335 ///
336 ///
337 /// #### `height-request`
338 /// Readable | Writable
339 ///
340 ///
341 /// #### `hexpand`
342 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
343 ///
344 /// Readable | Writable
345 ///
346 ///
347 /// #### `hexpand-set`
348 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
349 ///
350 /// Readable | Writable
351 ///
352 ///
353 /// #### `is-focus`
354 /// Readable | Writable
355 ///
356 ///
357 /// #### `margin`
358 /// Sets all four sides' margin at once. If read, returns max
359 /// margin on any side.
360 ///
361 /// Readable | Writable
362 ///
363 ///
364 /// #### `margin-bottom`
365 /// Margin on bottom side of widget.
366 ///
367 /// This property adds margin outside of the widget's normal size
368 /// request, the margin will be added in addition to the size from
369 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
370 ///
371 /// Readable | Writable
372 ///
373 ///
374 /// #### `margin-end`
375 /// Margin on end of widget, horizontally. This property supports
376 /// left-to-right and right-to-left text directions.
377 ///
378 /// This property adds margin outside of the widget's normal size
379 /// request, the margin will be added in addition to the size from
380 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
381 ///
382 /// Readable | Writable
383 ///
384 ///
385 /// #### `margin-left`
386 /// Margin on left side of widget.
387 ///
388 /// This property adds margin outside of the widget's normal size
389 /// request, the margin will be added in addition to the size from
390 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
391 ///
392 /// Readable | Writable
393 ///
394 ///
395 /// #### `margin-right`
396 /// Margin on right side of widget.
397 ///
398 /// This property adds margin outside of the widget's normal size
399 /// request, the margin will be added in addition to the size from
400 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
401 ///
402 /// Readable | Writable
403 ///
404 ///
405 /// #### `margin-start`
406 /// Margin on start of widget, horizontally. This property supports
407 /// left-to-right and right-to-left text directions.
408 ///
409 /// This property adds margin outside of the widget's normal size
410 /// request, the margin will be added in addition to the size from
411 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
412 ///
413 /// Readable | Writable
414 ///
415 ///
416 /// #### `margin-top`
417 /// Margin on top side of widget.
418 ///
419 /// This property adds margin outside of the widget's normal size
420 /// request, the margin will be added in addition to the size from
421 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
422 ///
423 /// Readable | Writable
424 ///
425 ///
426 /// #### `name`
427 /// Readable | Writable
428 ///
429 ///
430 /// #### `no-show-all`
431 /// Readable | Writable
432 ///
433 ///
434 /// #### `opacity`
435 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
436 /// more details about window opacity.
437 ///
438 /// Before 3.8 this was only available in GtkWindow
439 ///
440 /// Readable | Writable
441 ///
442 ///
443 /// #### `parent`
444 /// Readable | Writable
445 ///
446 ///
447 /// #### `receives-default`
448 /// Readable | Writable
449 ///
450 ///
451 /// #### `scale-factor`
452 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
453 /// more details about widget scaling.
454 ///
455 /// Readable
456 ///
457 ///
458 /// #### `sensitive`
459 /// Readable | Writable
460 ///
461 ///
462 /// #### `style`
463 /// The style of the widget, which contains information about how it will look (colors, etc).
464 ///
465 /// Readable | Writable
466 ///
467 ///
468 /// #### `tooltip-markup`
469 /// Sets the text of tooltip to be the given string, which is marked up
470 /// with the [Pango text markup language][PangoMarkupFormat].
471 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
472 ///
473 /// This is a convenience property which will take care of getting the
474 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
475 /// will automatically be set to [`true`] and there will be taken care of
476 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
477 ///
478 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
479 /// are set, the last one wins.
480 ///
481 /// Readable | Writable
482 ///
483 ///
484 /// #### `tooltip-text`
485 /// Sets the text of tooltip to be the given string.
486 ///
487 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
488 ///
489 /// This is a convenience property which will take care of getting the
490 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
491 /// will automatically be set to [`true`] and there will be taken care of
492 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
493 ///
494 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
495 /// are set, the last one wins.
496 ///
497 /// Readable | Writable
498 ///
499 ///
500 /// #### `valign`
501 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
502 ///
503 /// Readable | Writable
504 ///
505 ///
506 /// #### `vexpand`
507 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
508 ///
509 /// Readable | Writable
510 ///
511 ///
512 /// #### `vexpand-set`
513 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
514 ///
515 /// Readable | Writable
516 ///
517 ///
518 /// #### `visible`
519 /// Readable | Writable
520 ///
521 ///
522 /// #### `width-request`
523 /// Readable | Writable
524 ///
525 ///
526 /// #### `window`
527 /// The widget's window if it is realized, [`None`] otherwise.
528 ///
529 /// Readable
530 /// </details>
531 /// <details><summary><h4>AppChooser</h4></summary>
532 ///
533 ///
534 /// #### `content-type`
535 /// The content type of the [`AppChooser`][crate::AppChooser] object.
536 ///
537 /// See [GContentType][gio-GContentType]
538 /// for more information about content types.
539 ///
540 /// Readable | Writable | Construct Only
541 /// </details>
542 ///
543 /// # Implements
544 ///
545 /// [`AppChooserDialogExt`][trait@crate::prelude::AppChooserDialogExt], [`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], [`AppChooserExt`][trait@crate::prelude::AppChooserExt], [`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]
546 #[doc(alias = "GtkAppChooserDialog")]
547 pub struct AppChooserDialog(Object<ffi::GtkAppChooserDialog, ffi::GtkAppChooserDialogClass>) @extends Dialog, Window, Bin, Container, Widget, @implements Buildable, AppChooser;
548
549 match fn {
550 type_ => || ffi::gtk_app_chooser_dialog_get_type(),
551 }
552}
553
554impl AppChooserDialog {
555 pub const NONE: Option<&'static AppChooserDialog> = None;
556
557 /// Creates a new [`AppChooserDialog`][crate::AppChooserDialog] for the provided [`gio::File`][crate::gio::File],
558 /// to allow the user to select an application for it.
559 /// ## `parent`
560 /// a [`Window`][crate::Window], or [`None`]
561 /// ## `flags`
562 /// flags for this dialog
563 /// ## `file`
564 /// a [`gio::File`][crate::gio::File]
565 ///
566 /// # Returns
567 ///
568 /// a newly created [`AppChooserDialog`][crate::AppChooserDialog]
569 #[doc(alias = "gtk_app_chooser_dialog_new")]
570 pub fn new(
571 parent: Option<&impl IsA<Window>>,
572 flags: DialogFlags,
573 file: &impl IsA<gio::File>,
574 ) -> AppChooserDialog {
575 assert_initialized_main_thread!();
576 unsafe {
577 Widget::from_glib_none(ffi::gtk_app_chooser_dialog_new(
578 parent.map(|p| p.as_ref()).to_glib_none().0,
579 flags.into_glib(),
580 file.as_ref().to_glib_none().0,
581 ))
582 .unsafe_cast()
583 }
584 }
585
586 /// Creates a new [`AppChooserDialog`][crate::AppChooserDialog] for the provided content type,
587 /// to allow the user to select an application for it.
588 /// ## `parent`
589 /// a [`Window`][crate::Window], or [`None`]
590 /// ## `flags`
591 /// flags for this dialog
592 /// ## `content_type`
593 /// a content type string
594 ///
595 /// # Returns
596 ///
597 /// a newly created [`AppChooserDialog`][crate::AppChooserDialog]
598 #[doc(alias = "gtk_app_chooser_dialog_new_for_content_type")]
599 #[doc(alias = "new_for_content_type")]
600 pub fn for_content_type(
601 parent: Option<&impl IsA<Window>>,
602 flags: DialogFlags,
603 content_type: &str,
604 ) -> AppChooserDialog {
605 assert_initialized_main_thread!();
606 unsafe {
607 Widget::from_glib_none(ffi::gtk_app_chooser_dialog_new_for_content_type(
608 parent.map(|p| p.as_ref()).to_glib_none().0,
609 flags.into_glib(),
610 content_type.to_glib_none().0,
611 ))
612 .unsafe_cast()
613 }
614 }
615
616 // rustdoc-stripper-ignore-next
617 /// Creates a new builder-pattern struct instance to construct [`AppChooserDialog`] objects.
618 ///
619 /// This method returns an instance of [`AppChooserDialogBuilder`](crate::builders::AppChooserDialogBuilder) which can be used to create [`AppChooserDialog`] objects.
620 pub fn builder() -> AppChooserDialogBuilder {
621 AppChooserDialogBuilder::new()
622 }
623}
624
625impl Default for AppChooserDialog {
626 fn default() -> Self {
627 glib::object::Object::new::<Self>()
628 }
629}
630
631// rustdoc-stripper-ignore-next
632/// A [builder-pattern] type to construct [`AppChooserDialog`] objects.
633///
634/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
635#[must_use = "The builder must be built to be used"]
636pub struct AppChooserDialogBuilder {
637 builder: glib::object::ObjectBuilder<'static, AppChooserDialog>,
638}
639
640impl AppChooserDialogBuilder {
641 fn new() -> Self {
642 Self {
643 builder: glib::object::Object::builder(),
644 }
645 }
646
647 /// The GFile used by the [`AppChooserDialog`][crate::AppChooserDialog].
648 /// The dialog's [`AppChooserWidget`][crate::AppChooserWidget] content type will be guessed from the
649 /// file, if present.
650 pub fn gfile(self, gfile: &impl IsA<gio::File>) -> Self {
651 Self {
652 builder: self.builder.property("gfile", gfile.clone().upcast()),
653 }
654 }
655
656 /// The text to show at the top of the dialog.
657 /// The string may contain Pango markup.
658 pub fn heading(self, heading: impl Into<glib::GString>) -> Self {
659 Self {
660 builder: self.builder.property("heading", heading.into()),
661 }
662 }
663
664 /// [`true`] if the dialog uses a [`HeaderBar`][crate::HeaderBar] for action buttons
665 /// instead of the action-area.
666 ///
667 /// For technical reasons, this property is declared as an integer
668 /// property, but you should only set it to [`true`] or [`false`].
669 pub fn use_header_bar(self, use_header_bar: i32) -> Self {
670 Self {
671 builder: self.builder.property("use-header-bar", use_header_bar),
672 }
673 }
674
675 /// Whether the window should receive the input focus.
676 pub fn accept_focus(self, accept_focus: bool) -> Self {
677 Self {
678 builder: self.builder.property("accept-focus", accept_focus),
679 }
680 }
681
682 /// The [`Application`][crate::Application] associated with the window.
683 ///
684 /// The application will be kept alive for at least as long as it
685 /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
686 /// for a way to keep it alive without windows).
687 ///
688 /// Normally, the connection between the application and the window
689 /// will remain until the window is destroyed, but you can explicitly
690 /// remove it by setting the :application property to [`None`].
691 pub fn application(self, application: &impl IsA<Application>) -> Self {
692 Self {
693 builder: self
694 .builder
695 .property("application", application.clone().upcast()),
696 }
697 }
698
699 /// The widget to which this window is attached.
700 /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
701 ///
702 /// Examples of places where specifying this relation is useful are
703 /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
704 /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
705 /// created by [`TreeView`][crate::TreeView].
706 pub fn attached_to(self, attached_to: &impl IsA<Widget>) -> Self {
707 Self {
708 builder: self
709 .builder
710 .property("attached-to", attached_to.clone().upcast()),
711 }
712 }
713
714 /// Whether the window should be decorated by the window manager.
715 pub fn decorated(self, decorated: bool) -> Self {
716 Self {
717 builder: self.builder.property("decorated", decorated),
718 }
719 }
720
721 pub fn default_height(self, default_height: i32) -> Self {
722 Self {
723 builder: self.builder.property("default-height", default_height),
724 }
725 }
726
727 pub fn default_width(self, default_width: i32) -> Self {
728 Self {
729 builder: self.builder.property("default-width", default_width),
730 }
731 }
732
733 /// Whether the window frame should have a close button.
734 pub fn deletable(self, deletable: bool) -> Self {
735 Self {
736 builder: self.builder.property("deletable", deletable),
737 }
738 }
739
740 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
741 Self {
742 builder: self
743 .builder
744 .property("destroy-with-parent", destroy_with_parent),
745 }
746 }
747
748 /// Whether the window should receive the input focus when mapped.
749 pub fn focus_on_map(self, focus_on_map: bool) -> Self {
750 Self {
751 builder: self.builder.property("focus-on-map", focus_on_map),
752 }
753 }
754
755 /// Whether 'focus rectangles' are currently visible in this window.
756 ///
757 /// This property is maintained by GTK+ based on user input
758 /// and should not be set by applications.
759 pub fn focus_visible(self, focus_visible: bool) -> Self {
760 Self {
761 builder: self.builder.property("focus-visible", focus_visible),
762 }
763 }
764
765 /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
766 /// more details about window gravity.
767 pub fn gravity(self, gravity: gdk::Gravity) -> Self {
768 Self {
769 builder: self.builder.property("gravity", gravity),
770 }
771 }
772
773 /// Whether the titlebar should be hidden during maximization.
774 pub fn hide_titlebar_when_maximized(self, hide_titlebar_when_maximized: bool) -> Self {
775 Self {
776 builder: self
777 .builder
778 .property("hide-titlebar-when-maximized", hide_titlebar_when_maximized),
779 }
780 }
781
782 pub fn icon(self, icon: &gdk_pixbuf::Pixbuf) -> Self {
783 Self {
784 builder: self.builder.property("icon", icon.clone()),
785 }
786 }
787
788 /// The :icon-name property specifies the name of the themed icon to
789 /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
790 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
791 Self {
792 builder: self.builder.property("icon-name", icon_name.into()),
793 }
794 }
795
796 /// Whether mnemonics are currently visible in this window.
797 ///
798 /// This property is maintained by GTK+ based on user input,
799 /// and should not be set by applications.
800 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
801 Self {
802 builder: self
803 .builder
804 .property("mnemonics-visible", mnemonics_visible),
805 }
806 }
807
808 pub fn modal(self, modal: bool) -> Self {
809 Self {
810 builder: self.builder.property("modal", modal),
811 }
812 }
813
814 pub fn resizable(self, resizable: bool) -> Self {
815 Self {
816 builder: self.builder.property("resizable", resizable),
817 }
818 }
819
820 pub fn role(self, role: impl Into<glib::GString>) -> Self {
821 Self {
822 builder: self.builder.property("role", role.into()),
823 }
824 }
825
826 pub fn screen(self, screen: &gdk::Screen) -> Self {
827 Self {
828 builder: self.builder.property("screen", screen.clone()),
829 }
830 }
831
832 pub fn skip_pager_hint(self, skip_pager_hint: bool) -> Self {
833 Self {
834 builder: self.builder.property("skip-pager-hint", skip_pager_hint),
835 }
836 }
837
838 pub fn skip_taskbar_hint(self, skip_taskbar_hint: bool) -> Self {
839 Self {
840 builder: self
841 .builder
842 .property("skip-taskbar-hint", skip_taskbar_hint),
843 }
844 }
845
846 /// The :startup-id is a write-only property for setting window's
847 /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
848 /// for more details.
849 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
850 Self {
851 builder: self.builder.property("startup-id", startup_id.into()),
852 }
853 }
854
855 pub fn title(self, title: impl Into<glib::GString>) -> Self {
856 Self {
857 builder: self.builder.property("title", title.into()),
858 }
859 }
860
861 /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
862 /// more details about transient windows.
863 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
864 Self {
865 builder: self
866 .builder
867 .property("transient-for", transient_for.clone().upcast()),
868 }
869 }
870
871 pub fn type_(self, type_: WindowType) -> Self {
872 Self {
873 builder: self.builder.property("type", type_),
874 }
875 }
876
877 pub fn type_hint(self, type_hint: gdk::WindowTypeHint) -> Self {
878 Self {
879 builder: self.builder.property("type-hint", type_hint),
880 }
881 }
882
883 pub fn urgency_hint(self, urgency_hint: bool) -> Self {
884 Self {
885 builder: self.builder.property("urgency-hint", urgency_hint),
886 }
887 }
888
889 pub fn window_position(self, window_position: WindowPosition) -> Self {
890 Self {
891 builder: self.builder.property("window-position", window_position),
892 }
893 }
894
895 pub fn border_width(self, border_width: u32) -> Self {
896 Self {
897 builder: self.builder.property("border-width", border_width),
898 }
899 }
900
901 pub fn child(self, child: &impl IsA<Widget>) -> Self {
902 Self {
903 builder: self.builder.property("child", child.clone().upcast()),
904 }
905 }
906
907 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
908 Self {
909 builder: self.builder.property("resize-mode", resize_mode),
910 }
911 }
912
913 pub fn app_paintable(self, app_paintable: bool) -> Self {
914 Self {
915 builder: self.builder.property("app-paintable", app_paintable),
916 }
917 }
918
919 pub fn can_default(self, can_default: bool) -> Self {
920 Self {
921 builder: self.builder.property("can-default", can_default),
922 }
923 }
924
925 pub fn can_focus(self, can_focus: bool) -> Self {
926 Self {
927 builder: self.builder.property("can-focus", can_focus),
928 }
929 }
930
931 pub fn events(self, events: gdk::EventMask) -> Self {
932 Self {
933 builder: self.builder.property("events", events),
934 }
935 }
936
937 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
938 pub fn expand(self, expand: bool) -> Self {
939 Self {
940 builder: self.builder.property("expand", expand),
941 }
942 }
943
944 /// Whether the widget should grab focus when it is clicked with the mouse.
945 ///
946 /// This property is only relevant for widgets that can take focus.
947 ///
948 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
949 /// GtkComboBox) implemented this property individually.
950 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
951 Self {
952 builder: self.builder.property("focus-on-click", focus_on_click),
953 }
954 }
955
956 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
957 pub fn halign(self, halign: Align) -> Self {
958 Self {
959 builder: self.builder.property("halign", halign),
960 }
961 }
962
963 pub fn has_default(self, has_default: bool) -> Self {
964 Self {
965 builder: self.builder.property("has-default", has_default),
966 }
967 }
968
969 pub fn has_focus(self, has_focus: bool) -> Self {
970 Self {
971 builder: self.builder.property("has-focus", has_focus),
972 }
973 }
974
975 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
976 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
977 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
978 /// whether it will provide a tooltip or not.
979 ///
980 /// Note that setting this property to [`true`] for the first time will change
981 /// the event masks of the GdkWindows of this widget to include leave-notify
982 /// and motion-notify events. This cannot and will not be undone when the
983 /// property is set to [`false`] again.
984 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
985 Self {
986 builder: self.builder.property("has-tooltip", has_tooltip),
987 }
988 }
989
990 pub fn height_request(self, height_request: i32) -> Self {
991 Self {
992 builder: self.builder.property("height-request", height_request),
993 }
994 }
995
996 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
997 pub fn hexpand(self, hexpand: bool) -> Self {
998 Self {
999 builder: self.builder.property("hexpand", hexpand),
1000 }
1001 }
1002
1003 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1004 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1005 Self {
1006 builder: self.builder.property("hexpand-set", hexpand_set),
1007 }
1008 }
1009
1010 pub fn is_focus(self, is_focus: bool) -> Self {
1011 Self {
1012 builder: self.builder.property("is-focus", is_focus),
1013 }
1014 }
1015
1016 /// Sets all four sides' margin at once. If read, returns max
1017 /// margin on any side.
1018 pub fn margin(self, margin: i32) -> Self {
1019 Self {
1020 builder: self.builder.property("margin", margin),
1021 }
1022 }
1023
1024 /// Margin on bottom side of widget.
1025 ///
1026 /// This property adds margin outside of the widget's normal size
1027 /// request, the margin will be added in addition to the size from
1028 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1029 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1030 Self {
1031 builder: self.builder.property("margin-bottom", margin_bottom),
1032 }
1033 }
1034
1035 /// Margin on end of widget, horizontally. This property supports
1036 /// left-to-right and right-to-left text directions.
1037 ///
1038 /// This property adds margin outside of the widget's normal size
1039 /// request, the margin will be added in addition to the size from
1040 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1041 pub fn margin_end(self, margin_end: i32) -> Self {
1042 Self {
1043 builder: self.builder.property("margin-end", margin_end),
1044 }
1045 }
1046
1047 /// Margin on start of widget, horizontally. This property supports
1048 /// left-to-right and right-to-left text directions.
1049 ///
1050 /// This property adds margin outside of the widget's normal size
1051 /// request, the margin will be added in addition to the size from
1052 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1053 pub fn margin_start(self, margin_start: i32) -> Self {
1054 Self {
1055 builder: self.builder.property("margin-start", margin_start),
1056 }
1057 }
1058
1059 /// Margin on top side of widget.
1060 ///
1061 /// This property adds margin outside of the widget's normal size
1062 /// request, the margin will be added in addition to the size from
1063 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1064 pub fn margin_top(self, margin_top: i32) -> Self {
1065 Self {
1066 builder: self.builder.property("margin-top", margin_top),
1067 }
1068 }
1069
1070 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1071 Self {
1072 builder: self.builder.property("name", name.into()),
1073 }
1074 }
1075
1076 pub fn no_show_all(self, no_show_all: bool) -> Self {
1077 Self {
1078 builder: self.builder.property("no-show-all", no_show_all),
1079 }
1080 }
1081
1082 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1083 /// more details about window opacity.
1084 ///
1085 /// Before 3.8 this was only available in GtkWindow
1086 pub fn opacity(self, opacity: f64) -> Self {
1087 Self {
1088 builder: self.builder.property("opacity", opacity),
1089 }
1090 }
1091
1092 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1093 Self {
1094 builder: self.builder.property("parent", parent.clone().upcast()),
1095 }
1096 }
1097
1098 pub fn receives_default(self, receives_default: bool) -> Self {
1099 Self {
1100 builder: self.builder.property("receives-default", receives_default),
1101 }
1102 }
1103
1104 pub fn sensitive(self, sensitive: bool) -> Self {
1105 Self {
1106 builder: self.builder.property("sensitive", sensitive),
1107 }
1108 }
1109
1110 /// Sets the text of tooltip to be the given string, which is marked up
1111 /// with the [Pango text markup language][PangoMarkupFormat].
1112 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1113 ///
1114 /// This is a convenience property which will take care of getting the
1115 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1116 /// will automatically be set to [`true`] and there will be taken care of
1117 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1118 ///
1119 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1120 /// are set, the last one wins.
1121 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1122 Self {
1123 builder: self
1124 .builder
1125 .property("tooltip-markup", tooltip_markup.into()),
1126 }
1127 }
1128
1129 /// Sets the text of tooltip to be the given string.
1130 ///
1131 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1132 ///
1133 /// This is a convenience property which will take care of getting the
1134 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1135 /// will automatically be set to [`true`] and there will be taken care of
1136 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1137 ///
1138 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1139 /// are set, the last one wins.
1140 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1141 Self {
1142 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1143 }
1144 }
1145
1146 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1147 pub fn valign(self, valign: Align) -> Self {
1148 Self {
1149 builder: self.builder.property("valign", valign),
1150 }
1151 }
1152
1153 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1154 pub fn vexpand(self, vexpand: bool) -> Self {
1155 Self {
1156 builder: self.builder.property("vexpand", vexpand),
1157 }
1158 }
1159
1160 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1161 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1162 Self {
1163 builder: self.builder.property("vexpand-set", vexpand_set),
1164 }
1165 }
1166
1167 pub fn visible(self, visible: bool) -> Self {
1168 Self {
1169 builder: self.builder.property("visible", visible),
1170 }
1171 }
1172
1173 pub fn width_request(self, width_request: i32) -> Self {
1174 Self {
1175 builder: self.builder.property("width-request", width_request),
1176 }
1177 }
1178
1179 /// The content type of the [`AppChooser`][crate::AppChooser] object.
1180 ///
1181 /// See [GContentType][gio-GContentType]
1182 /// for more information about content types.
1183 pub fn content_type(self, content_type: impl Into<glib::GString>) -> Self {
1184 Self {
1185 builder: self.builder.property("content-type", content_type.into()),
1186 }
1187 }
1188
1189 // rustdoc-stripper-ignore-next
1190 /// Build the [`AppChooserDialog`].
1191 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1192 pub fn build(self) -> AppChooserDialog {
1193 assert_initialized_main_thread!();
1194 self.builder.build()
1195 }
1196}
1197
1198/// Trait containing all [`struct@AppChooserDialog`] methods.
1199///
1200/// # Implementors
1201///
1202/// [`AppChooserDialog`][struct@crate::AppChooserDialog]
1203pub trait AppChooserDialogExt: IsA<AppChooserDialog> + 'static {
1204 /// Returns the text to display at the top of the dialog.
1205 ///
1206 /// # Returns
1207 ///
1208 /// the text to display at the top of the dialog, or [`None`], in which
1209 /// case a default text is displayed
1210 #[doc(alias = "gtk_app_chooser_dialog_get_heading")]
1211 #[doc(alias = "get_heading")]
1212 fn heading(&self) -> Option<glib::GString> {
1213 unsafe {
1214 from_glib_none(ffi::gtk_app_chooser_dialog_get_heading(
1215 self.as_ref().to_glib_none().0,
1216 ))
1217 }
1218 }
1219
1220 /// Returns the [`AppChooserWidget`][crate::AppChooserWidget] of this dialog.
1221 ///
1222 /// # Returns
1223 ///
1224 /// the [`AppChooserWidget`][crate::AppChooserWidget] of `self`
1225 #[doc(alias = "gtk_app_chooser_dialog_get_widget")]
1226 #[doc(alias = "get_widget")]
1227 fn widget(&self) -> Widget {
1228 unsafe {
1229 from_glib_none(ffi::gtk_app_chooser_dialog_get_widget(
1230 self.as_ref().to_glib_none().0,
1231 ))
1232 }
1233 }
1234
1235 /// Sets the text to display at the top of the dialog.
1236 /// If the heading is not set, the dialog displays a default text.
1237 /// ## `heading`
1238 /// a string containing Pango markup
1239 #[doc(alias = "gtk_app_chooser_dialog_set_heading")]
1240 #[doc(alias = "heading")]
1241 fn set_heading(&self, heading: &str) {
1242 unsafe {
1243 ffi::gtk_app_chooser_dialog_set_heading(
1244 self.as_ref().to_glib_none().0,
1245 heading.to_glib_none().0,
1246 );
1247 }
1248 }
1249
1250 /// The GFile used by the [`AppChooserDialog`][crate::AppChooserDialog].
1251 /// The dialog's [`AppChooserWidget`][crate::AppChooserWidget] content type will be guessed from the
1252 /// file, if present.
1253 fn gfile(&self) -> Option<gio::File> {
1254 ObjectExt::property(self.as_ref(), "gfile")
1255 }
1256
1257 #[doc(alias = "heading")]
1258 fn connect_heading_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1259 unsafe extern "C" fn notify_heading_trampoline<
1260 P: IsA<AppChooserDialog>,
1261 F: Fn(&P) + 'static,
1262 >(
1263 this: *mut ffi::GtkAppChooserDialog,
1264 _param_spec: glib::ffi::gpointer,
1265 f: glib::ffi::gpointer,
1266 ) {
1267 unsafe {
1268 let f: &F = &*(f as *const F);
1269 f(AppChooserDialog::from_glib_borrow(this).unsafe_cast_ref())
1270 }
1271 }
1272 unsafe {
1273 let f: Box_<F> = Box_::new(f);
1274 connect_raw(
1275 self.as_ptr() as *mut _,
1276 c"notify::heading".as_ptr(),
1277 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1278 notify_heading_trampoline::<Self, F> as *const (),
1279 )),
1280 Box_::into_raw(f),
1281 )
1282 }
1283 }
1284}
1285
1286impl<O: IsA<AppChooserDialog>> AppChooserDialogExt for O {}