libadwaita/auto/dialog.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::{Breakpoint, DialogPresentationMode, ffi};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{SignalHandlerId, connect_raw},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15#[cfg(feature = "gtk_v4_10")]
16#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_10")))]
17glib::wrapper! {
18 ///
19 ///
20 /// [`Dialog`][crate::Dialog] is similar to a window, but is shown within another window. It
21 /// can be used with [`Window`][crate::Window] and [`ApplicationWindow`][crate::ApplicationWindow], use
22 /// [`AdwDialogExt::present()`][crate::prelude::AdwDialogExt::present()] to show it.
23 ///
24 /// [`Dialog`][crate::Dialog] is not resizable. Use the [`content-width`][struct@crate::Dialog#content-width] and
25 /// [`content-height`][struct@crate::Dialog#content-height] properties to set its size, or set
26 /// [`follows-content-size`][struct@crate::Dialog#follows-content-size] to `TRUE` to make the dialog track the
27 /// content's size as it changes. [`Dialog`][crate::Dialog] can never be larger than its parent
28 /// window.
29 ///
30 /// [`Dialog`][crate::Dialog] can be presented as a centered floating window or a bottom sheet.
31 /// By default it's automatic depending on the available size.
32 /// [`presentation-mode`][struct@crate::Dialog#presentation-mode] can be used to change that.
33 ///
34 /// [`Dialog`][crate::Dialog] can be closed via [`AdwDialogExt::close()`][crate::prelude::AdwDialogExt::close()].
35 ///
36 /// When presented as a bottom sheet, [`Dialog`][crate::Dialog] can also be closed via swiping
37 /// it down.
38 ///
39 /// The [`can-close`][struct@crate::Dialog#can-close] can be used to prevent closing. In that case,
40 /// [`close-attempt`][struct@crate::Dialog#close-attempt] gets emitted instead.
41 ///
42 /// Use [`AdwDialogExt::force_close()`][crate::prelude::AdwDialogExt::force_close()] to close the dialog even when `can-close` is set to
43 /// `FALSE`.
44 ///
45 /// [`Dialog`][crate::Dialog] is transient and doesn't integrate with the window below it, for
46 /// example it's not possible to collapse it into a bottom bar. See
47 /// [`BottomSheet`][crate::BottomSheet] for persistent and more tightly integrated bottom sheets.
48 ///
49 /// ## Header Bar Integration
50 ///
51 /// When placed inside an [`Dialog`][crate::Dialog], [`HeaderBar`][crate::HeaderBar] will display the dialog
52 /// title instead of window title. It will also adjust the decoration layout to
53 /// ensure it always has a close button and nothing else. Set
54 /// [`show-start-title-buttons`][struct@crate::HeaderBar#show-start-title-buttons] and
55 /// [`show-end-title-buttons`][struct@crate::HeaderBar#show-end-title-buttons] to `FALSE` to remove it if it's
56 /// unwanted.
57 ///
58 /// ## Breakpoints
59 ///
60 /// [`Dialog`][crate::Dialog] can be used with [`Breakpoint`][crate::Breakpoint] the same way as
61 /// [`BreakpointBin`][crate::BreakpointBin]. Refer to that widget's documentation for details.
62 ///
63 /// Like [`BreakpointBin`][crate::BreakpointBin], if breakpoints are used, [`Dialog`][crate::Dialog] doesn't have a
64 /// minimum size, and [`width-request`][struct@crate::gtk::Widget#width-request] and
65 /// [`height-request`][struct@crate::gtk::Widget#height-request] properties must be set manually.
66 ///
67 /// ## Properties
68 ///
69 ///
70 /// #### `can-close`
71 /// Whether the dialog can be closed.
72 ///
73 /// If set to `FALSE`, the close button, shortcuts and
74 /// [`AdwDialogExt::close()`][crate::prelude::AdwDialogExt::close()] will result in [`close-attempt`][struct@crate::Dialog#close-attempt] being
75 /// emitted instead, and bottom sheet close swipe will be disabled.
76 /// [`AdwDialogExt::force_close()`][crate::prelude::AdwDialogExt::force_close()] still works.
77 ///
78 /// Readable | Writable
79 ///
80 ///
81 /// #### `child`
82 /// The child widget of the [`Dialog`][crate::Dialog].
83 ///
84 /// Readable | Writable
85 ///
86 ///
87 /// #### `content-height`
88 /// The height of the dialog's contents.
89 ///
90 /// Set it to -1 to reset it to the content's natural height.
91 ///
92 /// See also: [`default-height`][struct@crate::gtk::Window#default-height]
93 ///
94 /// Readable | Writable
95 ///
96 ///
97 /// #### `content-width`
98 /// The width of the dialog's contents.
99 ///
100 /// Set it to -1 to reset it to the content's natural width.
101 ///
102 /// See also: [`default-width`][struct@crate::gtk::Window#default-width]
103 ///
104 /// Readable | Writable
105 ///
106 ///
107 /// #### `current-breakpoint`
108 /// The current breakpoint.
109 ///
110 /// Readable
111 ///
112 ///
113 /// #### `default-widget`
114 /// The default widget.
115 ///
116 /// It's activated when the user presses Enter.
117 ///
118 /// Readable | Writable
119 ///
120 ///
121 /// #### `focus-widget`
122 /// The focus widget.
123 ///
124 /// Readable | Writable
125 ///
126 ///
127 /// #### `follows-content-size`
128 /// Whether to size content automatically.
129 ///
130 /// If set to `TRUE`, always use the content's natural size instead of
131 /// [`content-width`][struct@crate::Dialog#content-width] and [`content-height`][struct@crate::Dialog#content-height]. If
132 /// the content resizes, the dialog will immediately resize as well.
133 ///
134 /// See also: [`resizable`][struct@crate::gtk::Window#resizable]
135 ///
136 /// Readable | Writable
137 ///
138 ///
139 /// #### `presentation-mode`
140 /// The dialog's presentation mode.
141 ///
142 /// When set to [enum@Adw.DialogPresentationMode.auto], the dialog appears as a
143 /// bottom sheet when the following condition is met:
144 /// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
145 ///
146 /// Set it to [enum@Adw.DialogPresentationMode.floating] or
147 /// [enum@Adw.DialogPresentationMode.bottom-sheet] to always present it a
148 /// floating window or a bottom sheet respectively, regardless of available
149 /// size.
150 ///
151 /// Presentation mode does nothing for dialogs presented as a window.
152 ///
153 /// Readable | Writable
154 ///
155 ///
156 /// #### `title`
157 /// The title of the dialog.
158 ///
159 /// Readable | Writable
160 /// <details><summary><h4>Widget</h4></summary>
161 ///
162 ///
163 /// #### `can-focus`
164 /// Whether the widget or any of its descendents can accept
165 /// the input focus.
166 ///
167 /// This property is meant to be set by widget implementations,
168 /// typically in their instance init function.
169 ///
170 /// Readable | Writable
171 ///
172 ///
173 /// #### `can-target`
174 /// Whether the widget can receive pointer events.
175 ///
176 /// Readable | Writable
177 ///
178 ///
179 /// #### `css-classes`
180 /// A list of css classes applied to this widget.
181 ///
182 /// Readable | Writable
183 ///
184 ///
185 /// #### `css-name`
186 /// The name of this widget in the CSS tree.
187 ///
188 /// This property is meant to be set by widget implementations,
189 /// typically in their instance init function.
190 ///
191 /// Readable | Writable | Construct Only
192 ///
193 ///
194 /// #### `cursor`
195 /// The cursor used by @widget.
196 ///
197 /// Readable | Writable
198 ///
199 ///
200 /// #### `focus-on-click`
201 /// Whether the widget should grab focus when it is clicked with the mouse.
202 ///
203 /// This property is only relevant for widgets that can take focus.
204 ///
205 /// Readable | Writable
206 ///
207 ///
208 /// #### `focusable`
209 /// Whether this widget itself will accept the input focus.
210 ///
211 /// Readable | Writable
212 ///
213 ///
214 /// #### `halign`
215 /// How to distribute horizontal space if widget gets extra space.
216 ///
217 /// Readable | Writable
218 ///
219 ///
220 /// #### `has-default`
221 /// Whether the widget is the default widget.
222 ///
223 /// Readable
224 ///
225 ///
226 /// #### `has-focus`
227 /// Whether the widget has the input focus.
228 ///
229 /// Readable
230 ///
231 ///
232 /// #### `has-tooltip`
233 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
234 /// signal on @widget.
235 ///
236 /// A true value indicates that @widget can have a tooltip, in this case
237 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
238 /// determine whether it will provide a tooltip or not.
239 ///
240 /// Readable | Writable
241 ///
242 ///
243 /// #### `height-request`
244 /// Overrides for height request of the widget.
245 ///
246 /// If this is -1, the natural request will be used.
247 ///
248 /// Readable | Writable
249 ///
250 ///
251 /// #### `hexpand`
252 /// Whether to expand horizontally.
253 ///
254 /// Readable | Writable
255 ///
256 ///
257 /// #### `hexpand-set`
258 /// Whether to use the `hexpand` property.
259 ///
260 /// Readable | Writable
261 ///
262 ///
263 /// #### `layout-manager`
264 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
265 /// the preferred size of the widget, and allocate its children.
266 ///
267 /// This property is meant to be set by widget implementations,
268 /// typically in their instance init function.
269 ///
270 /// Readable | Writable
271 ///
272 ///
273 /// #### `limit-events`
274 /// Makes this widget act like a modal dialog, with respect to
275 /// event delivery.
276 ///
277 /// Global event controllers will not handle events with targets
278 /// inside the widget, unless they are set up to ignore propagation
279 /// limits. See `Gtk::EventController::set_propagation_limit()`.
280 ///
281 /// Readable | Writable
282 ///
283 ///
284 /// #### `margin-bottom`
285 /// Margin on bottom side of widget.
286 ///
287 /// This property adds margin outside of the widget's normal size
288 /// request, the margin will be added in addition to the size from
289 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
290 ///
291 /// Readable | Writable
292 ///
293 ///
294 /// #### `margin-end`
295 /// Margin on end of widget, horizontally.
296 ///
297 /// This property supports left-to-right and right-to-left text
298 /// directions.
299 ///
300 /// This property adds margin outside of the widget's normal size
301 /// request, the margin will be added in addition to the size from
302 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
303 ///
304 /// Readable | Writable
305 ///
306 ///
307 /// #### `margin-start`
308 /// Margin on start of widget, horizontally.
309 ///
310 /// This property supports left-to-right and right-to-left text
311 /// directions.
312 ///
313 /// This property adds margin outside of the widget's normal size
314 /// request, the margin will be added in addition to the size from
315 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
316 ///
317 /// Readable | Writable
318 ///
319 ///
320 /// #### `margin-top`
321 /// Margin on top side of widget.
322 ///
323 /// This property adds margin outside of the widget's normal size
324 /// request, the margin will be added in addition to the size from
325 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
326 ///
327 /// Readable | Writable
328 ///
329 ///
330 /// #### `name`
331 /// The name of the widget.
332 ///
333 /// Readable | Writable
334 ///
335 ///
336 /// #### `opacity`
337 /// The requested opacity of the widget.
338 ///
339 /// Readable | Writable
340 ///
341 ///
342 /// #### `overflow`
343 /// How content outside the widget's content area is treated.
344 ///
345 /// This property is meant to be set by widget implementations,
346 /// typically in their instance init function.
347 ///
348 /// Readable | Writable
349 ///
350 ///
351 /// #### `parent`
352 /// The parent widget of this widget.
353 ///
354 /// Readable
355 ///
356 ///
357 /// #### `receives-default`
358 /// Whether the widget will receive the default action when it is focused.
359 ///
360 /// Readable | Writable
361 ///
362 ///
363 /// #### `root`
364 /// The [`gtk::Root`][crate::gtk::Root] widget of the widget tree containing this widget.
365 ///
366 /// This will be `NULL` if the widget is not contained in a root widget.
367 ///
368 /// Readable
369 ///
370 ///
371 /// #### `scale-factor`
372 /// The scale factor of the widget.
373 ///
374 /// Readable
375 ///
376 ///
377 /// #### `sensitive`
378 /// Whether the widget responds to input.
379 ///
380 /// Readable | Writable
381 ///
382 ///
383 /// #### `tooltip-markup`
384 /// Sets the text of tooltip to be the given string, which is marked up
385 /// with Pango markup.
386 ///
387 /// Also see `Gtk::Tooltip::set_markup()`.
388 ///
389 /// This is a convenience property which will take care of getting the
390 /// tooltip shown if the given string is not `NULL`:
391 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
392 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
393 /// the default signal handler.
394 ///
395 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
396 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
397 ///
398 /// Readable | Writable
399 ///
400 ///
401 /// #### `tooltip-text`
402 /// Sets the text of tooltip to be the given string.
403 ///
404 /// Also see `Gtk::Tooltip::set_text()`.
405 ///
406 /// This is a convenience property which will take care of getting the
407 /// tooltip shown if the given string is not `NULL`:
408 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
409 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
410 /// the default signal handler.
411 ///
412 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
413 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
414 ///
415 /// Readable | Writable
416 ///
417 ///
418 /// #### `valign`
419 /// How to distribute vertical space if widget gets extra space.
420 ///
421 /// Readable | Writable
422 ///
423 ///
424 /// #### `vexpand`
425 /// Whether to expand vertically.
426 ///
427 /// Readable | Writable
428 ///
429 ///
430 /// #### `vexpand-set`
431 /// Whether to use the `vexpand` property.
432 ///
433 /// Readable | Writable
434 ///
435 ///
436 /// #### `visible`
437 /// Whether the widget is visible.
438 ///
439 /// Readable | Writable
440 ///
441 ///
442 /// #### `width-request`
443 /// Overrides for width request of the widget.
444 ///
445 /// If this is -1, the natural request will be used.
446 ///
447 /// Readable | Writable
448 /// </details>
449 /// <details><summary><h4>Accessible</h4></summary>
450 ///
451 ///
452 /// #### `accessible-role`
453 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
454 ///
455 /// The accessible role cannot be changed once set.
456 ///
457 /// Readable | Writable
458 /// </details>
459 ///
460 /// ## Signals
461 ///
462 ///
463 /// #### `close-attempt`
464 /// Emitted when the close button or shortcut is used, or
465 /// [`AdwDialogExt::close()`][crate::prelude::AdwDialogExt::close()] is called while [`can-close`][struct@crate::Dialog#can-close] is set to
466 /// `FALSE`.
467 ///
468 ///
469 ///
470 ///
471 /// #### `closed`
472 /// Emitted when the dialog is successfully closed.
473 ///
474 ///
475 /// <details><summary><h4>Widget</h4></summary>
476 ///
477 ///
478 /// #### `destroy`
479 /// Signals that all holders of a reference to the widget should release
480 /// the reference that they hold.
481 ///
482 /// May result in finalization of the widget if all references are released.
483 ///
484 /// This signal is not suitable for saving widget state.
485 ///
486 ///
487 ///
488 ///
489 /// #### `direction-changed`
490 /// Emitted when the text direction of a widget changes.
491 ///
492 ///
493 ///
494 ///
495 /// #### `hide`
496 /// Emitted when @widget is hidden.
497 ///
498 ///
499 ///
500 ///
501 /// #### `keynav-failed`
502 /// Emitted if keyboard navigation fails.
503 ///
504 /// See [`WidgetExtManual::keynav_failed()`][crate::gtk::prelude::WidgetExtManual::keynav_failed()] for details.
505 ///
506 ///
507 ///
508 ///
509 /// #### `map`
510 /// Emitted when @widget is going to be mapped.
511 ///
512 /// A widget is mapped when the widget is visible (which is controlled with
513 /// [`visible`][struct@crate::gtk::Widget#visible]) and all its parents up to the toplevel widget
514 /// are also visible.
515 ///
516 /// The `::map` signal can be used to determine whether a widget will be drawn,
517 /// for instance it can resume an animation that was stopped during the
518 /// emission of [`unmap`][struct@crate::gtk::Widget#unmap].
519 ///
520 ///
521 ///
522 ///
523 /// #### `mnemonic-activate`
524 /// Emitted when a widget is activated via a mnemonic.
525 ///
526 /// The default handler for this signal activates @widget if @group_cycling
527 /// is false, or just makes @widget grab focus if @group_cycling is true.
528 ///
529 ///
530 ///
531 ///
532 /// #### `move-focus`
533 /// to move backward.
534 ///
535 /// Action
536 ///
537 ///
538 /// #### `query-tooltip`
539 /// s tooltip is about to be shown.
540 ///
541 /// This happens when the [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] property
542 /// is true and the hover timeout has expired with the cursor hovering
543 /// above @widget; or emitted when @widget got focus in keyboard mode.
544 ///
545 /// Using the given coordinates, the signal handler should determine
546 /// whether a tooltip should be shown for @widget. If this is the case
547 /// true should be returned, false otherwise. Note that if @keyboard_mode
548 /// is true, the values of @x and @y are undefined and should not be used.
549 ///
550 /// The signal handler is free to manipulate @tooltip with the therefore
551 /// destined function calls.
552 ///
553 ///
554 ///
555 ///
556 /// #### `realize`
557 /// Emitted when @widget is associated with a `GdkSurface`.
558 ///
559 /// This means that [`WidgetExtManual::realize()`][crate::gtk::prelude::WidgetExtManual::realize()] has been called
560 /// or the widget has been mapped (that is, it is going to be drawn).
561 ///
562 ///
563 ///
564 ///
565 /// #### `show`
566 /// Emitted when @widget is shown.
567 ///
568 ///
569 ///
570 ///
571 /// #### `state-flags-changed`
572 /// Emitted when the widget state changes.
573 ///
574 /// See [`WidgetExtManual::state_flags()`][crate::gtk::prelude::WidgetExtManual::state_flags()].
575 ///
576 ///
577 ///
578 ///
579 /// #### `unmap`
580 /// Emitted when @widget is going to be unmapped.
581 ///
582 /// A widget is unmapped when either it or any of its parents up to the
583 /// toplevel widget have been set as hidden.
584 ///
585 /// As `::unmap` indicates that a widget will not be shown any longer,
586 /// it can be used to, for example, stop an animation on the widget.
587 ///
588 ///
589 ///
590 ///
591 /// #### `unrealize`
592 /// Emitted when the `GdkSurface` associated with @widget is destroyed.
593 ///
594 /// This means that [`WidgetExtManual::unrealize()`][crate::gtk::prelude::WidgetExtManual::unrealize()] has been called
595 /// or the widget has been unmapped (that is, it is going to be hidden).
596 ///
597 ///
598 /// </details>
599 ///
600 /// # Implements
601 ///
602 /// [`AdwDialogExt`][trait@crate::prelude::AdwDialogExt], [`trait@gtk::prelude::WidgetExt`], [`trait@glib::ObjectExt`], [`trait@gtk::prelude::AccessibleExt`], [`trait@gtk::prelude::BuildableExt`], [`trait@gtk::prelude::ConstraintTargetExt`], [`trait@gtk::prelude::ShortcutManagerExt`]
603 #[doc(alias = "AdwDialog")]
604 pub struct Dialog(Object<ffi::AdwDialog, ffi::AdwDialogClass>) @extends gtk::Widget, @implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::ShortcutManager;
605
606 match fn {
607 type_ => || ffi::adw_dialog_get_type(),
608 }
609}
610
611#[cfg(not(feature = "gtk_v4_10"))]
612glib::wrapper! {
613 #[doc(alias = "AdwDialog")]
614 pub struct Dialog(Object<ffi::AdwDialog, ffi::AdwDialogClass>) @extends gtk::Widget, @implements gtk::Buildable, gtk::ConstraintTarget, gtk::ShortcutManager;
615
616 match fn {
617 type_ => || ffi::adw_dialog_get_type(),
618 }
619}
620
621impl Dialog {
622 pub const NONE: Option<&'static Dialog> = None;
623
624 /// Creates a new [`Dialog`][crate::Dialog].
625 ///
626 /// # Returns
627 ///
628 /// the new created [`Dialog`][crate::Dialog]
629 #[doc(alias = "adw_dialog_new")]
630 pub fn new() -> Dialog {
631 assert_initialized_main_thread!();
632 unsafe { from_glib_none(ffi::adw_dialog_new()) }
633 }
634
635 // rustdoc-stripper-ignore-next
636 /// Creates a new builder-pattern struct instance to construct [`Dialog`] objects.
637 ///
638 /// This method returns an instance of [`DialogBuilder`](crate::builders::DialogBuilder) which can be used to create [`Dialog`] objects.
639 pub fn builder() -> DialogBuilder {
640 DialogBuilder::new()
641 }
642}
643
644#[cfg(feature = "v1_5")]
645#[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
646impl Default for Dialog {
647 fn default() -> Self {
648 Self::new()
649 }
650}
651
652// rustdoc-stripper-ignore-next
653/// A [builder-pattern] type to construct [`Dialog`] objects.
654///
655/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
656#[must_use = "The builder must be built to be used"]
657pub struct DialogBuilder {
658 builder: glib::object::ObjectBuilder<'static, Dialog>,
659}
660
661impl DialogBuilder {
662 fn new() -> Self {
663 Self {
664 builder: glib::object::Object::builder(),
665 }
666 }
667
668 /// Whether the dialog can be closed.
669 ///
670 /// If set to `FALSE`, the close button, shortcuts and
671 /// [`AdwDialogExt::close()`][crate::prelude::AdwDialogExt::close()] will result in [`close-attempt`][struct@crate::Dialog#close-attempt] being
672 /// emitted instead, and bottom sheet close swipe will be disabled.
673 /// [`AdwDialogExt::force_close()`][crate::prelude::AdwDialogExt::force_close()] still works.
674 #[cfg(feature = "v1_5")]
675 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
676 pub fn can_close(self, can_close: bool) -> Self {
677 Self {
678 builder: self.builder.property("can-close", can_close),
679 }
680 }
681
682 /// The child widget of the [`Dialog`][crate::Dialog].
683 #[cfg(feature = "v1_5")]
684 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
685 pub fn child(self, child: &impl IsA<gtk::Widget>) -> Self {
686 Self {
687 builder: self.builder.property("child", child.clone().upcast()),
688 }
689 }
690
691 /// The height of the dialog's contents.
692 ///
693 /// Set it to -1 to reset it to the content's natural height.
694 ///
695 /// See also: [`default-height`][struct@crate::gtk::Window#default-height]
696 #[cfg(feature = "v1_5")]
697 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
698 pub fn content_height(self, content_height: i32) -> Self {
699 Self {
700 builder: self.builder.property("content-height", content_height),
701 }
702 }
703
704 /// The width of the dialog's contents.
705 ///
706 /// Set it to -1 to reset it to the content's natural width.
707 ///
708 /// See also: [`default-width`][struct@crate::gtk::Window#default-width]
709 #[cfg(feature = "v1_5")]
710 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
711 pub fn content_width(self, content_width: i32) -> Self {
712 Self {
713 builder: self.builder.property("content-width", content_width),
714 }
715 }
716
717 /// The default widget.
718 ///
719 /// It's activated when the user presses Enter.
720 #[cfg(feature = "v1_5")]
721 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
722 pub fn default_widget(self, default_widget: &impl IsA<gtk::Widget>) -> Self {
723 Self {
724 builder: self
725 .builder
726 .property("default-widget", default_widget.clone().upcast()),
727 }
728 }
729
730 /// The focus widget.
731 #[cfg(feature = "v1_5")]
732 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
733 pub fn focus_widget(self, focus_widget: &impl IsA<gtk::Widget>) -> Self {
734 Self {
735 builder: self
736 .builder
737 .property("focus-widget", focus_widget.clone().upcast()),
738 }
739 }
740
741 /// Whether to size content automatically.
742 ///
743 /// If set to `TRUE`, always use the content's natural size instead of
744 /// [`content-width`][struct@crate::Dialog#content-width] and [`content-height`][struct@crate::Dialog#content-height]. If
745 /// the content resizes, the dialog will immediately resize as well.
746 ///
747 /// See also: [`resizable`][struct@crate::gtk::Window#resizable]
748 #[cfg(feature = "v1_5")]
749 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
750 pub fn follows_content_size(self, follows_content_size: bool) -> Self {
751 Self {
752 builder: self
753 .builder
754 .property("follows-content-size", follows_content_size),
755 }
756 }
757
758 /// The dialog's presentation mode.
759 ///
760 /// When set to [enum@Adw.DialogPresentationMode.auto], the dialog appears as a
761 /// bottom sheet when the following condition is met:
762 /// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
763 ///
764 /// Set it to [enum@Adw.DialogPresentationMode.floating] or
765 /// [enum@Adw.DialogPresentationMode.bottom-sheet] to always present it a
766 /// floating window or a bottom sheet respectively, regardless of available
767 /// size.
768 ///
769 /// Presentation mode does nothing for dialogs presented as a window.
770 #[cfg(feature = "v1_5")]
771 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
772 pub fn presentation_mode(self, presentation_mode: DialogPresentationMode) -> Self {
773 Self {
774 builder: self
775 .builder
776 .property("presentation-mode", presentation_mode),
777 }
778 }
779
780 /// The title of the dialog.
781 #[cfg(feature = "v1_5")]
782 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
783 pub fn title(self, title: impl Into<glib::GString>) -> Self {
784 Self {
785 builder: self.builder.property("title", title.into()),
786 }
787 }
788
789 /// Whether the widget or any of its descendents can accept
790 /// the input focus.
791 ///
792 /// This property is meant to be set by widget implementations,
793 /// typically in their instance init function.
794 pub fn can_focus(self, can_focus: bool) -> Self {
795 Self {
796 builder: self.builder.property("can-focus", can_focus),
797 }
798 }
799
800 /// Whether the widget can receive pointer events.
801 pub fn can_target(self, can_target: bool) -> Self {
802 Self {
803 builder: self.builder.property("can-target", can_target),
804 }
805 }
806
807 /// A list of css classes applied to this widget.
808 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
809 Self {
810 builder: self.builder.property("css-classes", css_classes.into()),
811 }
812 }
813
814 /// The name of this widget in the CSS tree.
815 ///
816 /// This property is meant to be set by widget implementations,
817 /// typically in their instance init function.
818 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
819 Self {
820 builder: self.builder.property("css-name", css_name.into()),
821 }
822 }
823
824 /// The cursor used by @widget.
825 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
826 Self {
827 builder: self.builder.property("cursor", cursor.clone()),
828 }
829 }
830
831 /// Whether the widget should grab focus when it is clicked with the mouse.
832 ///
833 /// This property is only relevant for widgets that can take focus.
834 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
835 Self {
836 builder: self.builder.property("focus-on-click", focus_on_click),
837 }
838 }
839
840 /// Whether this widget itself will accept the input focus.
841 pub fn focusable(self, focusable: bool) -> Self {
842 Self {
843 builder: self.builder.property("focusable", focusable),
844 }
845 }
846
847 /// How to distribute horizontal space if widget gets extra space.
848 pub fn halign(self, halign: gtk::Align) -> Self {
849 Self {
850 builder: self.builder.property("halign", halign),
851 }
852 }
853
854 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip]
855 /// signal on @widget.
856 ///
857 /// A true value indicates that @widget can have a tooltip, in this case
858 /// the widget will be queried using [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] to
859 /// determine whether it will provide a tooltip or not.
860 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
861 Self {
862 builder: self.builder.property("has-tooltip", has_tooltip),
863 }
864 }
865
866 /// Overrides for height request of the widget.
867 ///
868 /// If this is -1, the natural request will be used.
869 pub fn height_request(self, height_request: i32) -> Self {
870 Self {
871 builder: self.builder.property("height-request", height_request),
872 }
873 }
874
875 /// Whether to expand horizontally.
876 pub fn hexpand(self, hexpand: bool) -> Self {
877 Self {
878 builder: self.builder.property("hexpand", hexpand),
879 }
880 }
881
882 /// Whether to use the `hexpand` property.
883 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
884 Self {
885 builder: self.builder.property("hexpand-set", hexpand_set),
886 }
887 }
888
889 /// The [`gtk::LayoutManager`][crate::gtk::LayoutManager] instance to use to compute
890 /// the preferred size of the widget, and allocate its children.
891 ///
892 /// This property is meant to be set by widget implementations,
893 /// typically in their instance init function.
894 pub fn layout_manager(self, layout_manager: &impl IsA<gtk::LayoutManager>) -> Self {
895 Self {
896 builder: self
897 .builder
898 .property("layout-manager", layout_manager.clone().upcast()),
899 }
900 }
901
902 /// Makes this widget act like a modal dialog, with respect to
903 /// event delivery.
904 ///
905 /// Global event controllers will not handle events with targets
906 /// inside the widget, unless they are set up to ignore propagation
907 /// limits. See `Gtk::EventController::set_propagation_limit()`.
908 #[cfg(feature = "gtk_v4_18")]
909 #[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_18")))]
910 pub fn limit_events(self, limit_events: bool) -> Self {
911 Self {
912 builder: self.builder.property("limit-events", limit_events),
913 }
914 }
915
916 /// Margin on bottom side of widget.
917 ///
918 /// This property adds margin outside of the widget's normal size
919 /// request, the margin will be added in addition to the size from
920 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
921 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
922 Self {
923 builder: self.builder.property("margin-bottom", margin_bottom),
924 }
925 }
926
927 /// Margin on end of widget, horizontally.
928 ///
929 /// This property supports left-to-right and right-to-left text
930 /// directions.
931 ///
932 /// This property adds margin outside of the widget's normal size
933 /// request, the margin will be added in addition to the size from
934 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
935 pub fn margin_end(self, margin_end: i32) -> Self {
936 Self {
937 builder: self.builder.property("margin-end", margin_end),
938 }
939 }
940
941 /// Margin on start of widget, horizontally.
942 ///
943 /// This property supports left-to-right and right-to-left text
944 /// directions.
945 ///
946 /// This property adds margin outside of the widget's normal size
947 /// request, the margin will be added in addition to the size from
948 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
949 pub fn margin_start(self, margin_start: i32) -> Self {
950 Self {
951 builder: self.builder.property("margin-start", margin_start),
952 }
953 }
954
955 /// Margin on top side of widget.
956 ///
957 /// This property adds margin outside of the widget's normal size
958 /// request, the margin will be added in addition to the size from
959 /// [`WidgetExtManual::set_size_request()`][crate::gtk::prelude::WidgetExtManual::set_size_request()] for example.
960 pub fn margin_top(self, margin_top: i32) -> Self {
961 Self {
962 builder: self.builder.property("margin-top", margin_top),
963 }
964 }
965
966 /// The name of the widget.
967 pub fn name(self, name: impl Into<glib::GString>) -> Self {
968 Self {
969 builder: self.builder.property("name", name.into()),
970 }
971 }
972
973 /// The requested opacity of the widget.
974 pub fn opacity(self, opacity: f64) -> Self {
975 Self {
976 builder: self.builder.property("opacity", opacity),
977 }
978 }
979
980 /// How content outside the widget's content area is treated.
981 ///
982 /// This property is meant to be set by widget implementations,
983 /// typically in their instance init function.
984 pub fn overflow(self, overflow: gtk::Overflow) -> Self {
985 Self {
986 builder: self.builder.property("overflow", overflow),
987 }
988 }
989
990 /// Whether the widget will receive the default action when it is focused.
991 pub fn receives_default(self, receives_default: bool) -> Self {
992 Self {
993 builder: self.builder.property("receives-default", receives_default),
994 }
995 }
996
997 /// Whether the widget responds to input.
998 pub fn sensitive(self, sensitive: bool) -> Self {
999 Self {
1000 builder: self.builder.property("sensitive", sensitive),
1001 }
1002 }
1003
1004 /// Sets the text of tooltip to be the given string, which is marked up
1005 /// with Pango markup.
1006 ///
1007 /// Also see `Gtk::Tooltip::set_markup()`.
1008 ///
1009 /// This is a convenience property which will take care of getting the
1010 /// tooltip shown if the given string is not `NULL`:
1011 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1012 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1013 /// the default signal handler.
1014 ///
1015 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1016 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1017 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1018 Self {
1019 builder: self
1020 .builder
1021 .property("tooltip-markup", tooltip_markup.into()),
1022 }
1023 }
1024
1025 /// Sets the text of tooltip to be the given string.
1026 ///
1027 /// Also see `Gtk::Tooltip::set_text()`.
1028 ///
1029 /// This is a convenience property which will take care of getting the
1030 /// tooltip shown if the given string is not `NULL`:
1031 /// [`has-tooltip`][struct@crate::gtk::Widget#has-tooltip] will automatically be set to true
1032 /// and there will be taken care of [`query-tooltip`][struct@crate::gtk::Widget#query-tooltip] in
1033 /// the default signal handler.
1034 ///
1035 /// Note that if both [`tooltip-text`][struct@crate::gtk::Widget#tooltip-text] and
1036 /// [`tooltip-markup`][struct@crate::gtk::Widget#tooltip-markup] are set, the last one wins.
1037 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1038 Self {
1039 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1040 }
1041 }
1042
1043 /// How to distribute vertical space if widget gets extra space.
1044 pub fn valign(self, valign: gtk::Align) -> Self {
1045 Self {
1046 builder: self.builder.property("valign", valign),
1047 }
1048 }
1049
1050 /// Whether to expand vertically.
1051 pub fn vexpand(self, vexpand: bool) -> Self {
1052 Self {
1053 builder: self.builder.property("vexpand", vexpand),
1054 }
1055 }
1056
1057 /// Whether to use the `vexpand` property.
1058 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1059 Self {
1060 builder: self.builder.property("vexpand-set", vexpand_set),
1061 }
1062 }
1063
1064 /// Whether the widget is visible.
1065 pub fn visible(self, visible: bool) -> Self {
1066 Self {
1067 builder: self.builder.property("visible", visible),
1068 }
1069 }
1070
1071 /// Overrides for width request of the widget.
1072 ///
1073 /// If this is -1, the natural request will be used.
1074 pub fn width_request(self, width_request: i32) -> Self {
1075 Self {
1076 builder: self.builder.property("width-request", width_request),
1077 }
1078 }
1079
1080 /// The accessible role of the given [`gtk::Accessible`][crate::gtk::Accessible] implementation.
1081 ///
1082 /// The accessible role cannot be changed once set.
1083 pub fn accessible_role(self, accessible_role: gtk::AccessibleRole) -> Self {
1084 Self {
1085 builder: self.builder.property("accessible-role", accessible_role),
1086 }
1087 }
1088
1089 // rustdoc-stripper-ignore-next
1090 /// Build the [`Dialog`].
1091 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1092 pub fn build(self) -> Dialog {
1093 assert_initialized_main_thread!();
1094 self.builder.build()
1095 }
1096}
1097
1098/// Trait containing all [`struct@Dialog`] methods.
1099///
1100/// # Implementors
1101///
1102/// [`AboutDialog`][struct@crate::AboutDialog], [`AlertDialog`][struct@crate::AlertDialog], [`Dialog`][struct@crate::Dialog], [`PreferencesDialog`][struct@crate::PreferencesDialog], [`ShortcutsDialog`][struct@crate::ShortcutsDialog]
1103pub trait AdwDialogExt: IsA<Dialog> + 'static {
1104 /// Adds @breakpoint to @self.
1105 /// ## `breakpoint`
1106 /// the breakpoint to add
1107 #[doc(alias = "adw_dialog_add_breakpoint")]
1108 fn add_breakpoint(&self, breakpoint: Breakpoint) {
1109 unsafe {
1110 ffi::adw_dialog_add_breakpoint(
1111 self.as_ref().to_glib_none().0,
1112 breakpoint.into_glib_ptr(),
1113 );
1114 }
1115 }
1116
1117 /// Attempts to close @self.
1118 ///
1119 /// If the [`can-close`][struct@crate::Dialog#can-close] property is set to `FALSE`, the
1120 /// [`close-attempt`][struct@crate::Dialog#close-attempt] signal is emitted.
1121 ///
1122 /// See also: [`force_close()`][Self::force_close()].
1123 ///
1124 /// # Returns
1125 ///
1126 /// whether @self was successfully closed
1127 #[doc(alias = "adw_dialog_close")]
1128 fn close(&self) -> bool {
1129 unsafe { from_glib(ffi::adw_dialog_close(self.as_ref().to_glib_none().0)) }
1130 }
1131
1132 /// Closes @self.
1133 ///
1134 /// Unlike [`close()`][Self::close()], it succeeds even if [`can-close`][struct@crate::Dialog#can-close]
1135 /// is set to `FALSE`.
1136 #[doc(alias = "adw_dialog_force_close")]
1137 fn force_close(&self) {
1138 unsafe {
1139 ffi::adw_dialog_force_close(self.as_ref().to_glib_none().0);
1140 }
1141 }
1142
1143 /// Gets whether @self can be closed.
1144 ///
1145 /// # Returns
1146 ///
1147 /// whether the dialog can be closed
1148 #[doc(alias = "adw_dialog_get_can_close")]
1149 #[doc(alias = "get_can_close")]
1150 #[doc(alias = "can-close")]
1151 fn can_close(&self) -> bool {
1152 unsafe {
1153 from_glib(ffi::adw_dialog_get_can_close(
1154 self.as_ref().to_glib_none().0,
1155 ))
1156 }
1157 }
1158
1159 /// Gets the child widget of @self.
1160 ///
1161 /// # Returns
1162 ///
1163 /// the child widget of @self
1164 #[doc(alias = "adw_dialog_get_child")]
1165 #[doc(alias = "get_child")]
1166 fn child(&self) -> Option<gtk::Widget> {
1167 unsafe { from_glib_none(ffi::adw_dialog_get_child(self.as_ref().to_glib_none().0)) }
1168 }
1169
1170 /// Gets the height of the dialog's contents.
1171 ///
1172 /// # Returns
1173 ///
1174 /// the content height
1175 #[doc(alias = "adw_dialog_get_content_height")]
1176 #[doc(alias = "get_content_height")]
1177 #[doc(alias = "content-height")]
1178 fn content_height(&self) -> i32 {
1179 unsafe { ffi::adw_dialog_get_content_height(self.as_ref().to_glib_none().0) }
1180 }
1181
1182 /// Gets the width of the dialog's contents.
1183 ///
1184 /// # Returns
1185 ///
1186 /// the content width
1187 #[doc(alias = "adw_dialog_get_content_width")]
1188 #[doc(alias = "get_content_width")]
1189 #[doc(alias = "content-width")]
1190 fn content_width(&self) -> i32 {
1191 unsafe { ffi::adw_dialog_get_content_width(self.as_ref().to_glib_none().0) }
1192 }
1193
1194 /// Gets the current breakpoint.
1195 ///
1196 /// # Returns
1197 ///
1198 /// the current breakpoint
1199 #[doc(alias = "adw_dialog_get_current_breakpoint")]
1200 #[doc(alias = "get_current_breakpoint")]
1201 #[doc(alias = "current-breakpoint")]
1202 fn current_breakpoint(&self) -> Option<Breakpoint> {
1203 unsafe {
1204 from_glib_none(ffi::adw_dialog_get_current_breakpoint(
1205 self.as_ref().to_glib_none().0,
1206 ))
1207 }
1208 }
1209
1210 /// Gets the default widget for @self.
1211 ///
1212 /// # Returns
1213 ///
1214 /// the default widget
1215 #[doc(alias = "adw_dialog_get_default_widget")]
1216 #[doc(alias = "get_default_widget")]
1217 #[doc(alias = "default-widget")]
1218 fn default_widget(&self) -> Option<gtk::Widget> {
1219 unsafe {
1220 from_glib_none(ffi::adw_dialog_get_default_widget(
1221 self.as_ref().to_glib_none().0,
1222 ))
1223 }
1224 }
1225
1226 /// Gets the focus widget for @self.
1227 ///
1228 /// # Returns
1229 ///
1230 /// the focus widget
1231 #[doc(alias = "adw_dialog_get_focus")]
1232 #[doc(alias = "get_focus")]
1233 #[doc(alias = "focus-widget")]
1234 fn focus(&self) -> Option<gtk::Widget> {
1235 unsafe { from_glib_none(ffi::adw_dialog_get_focus(self.as_ref().to_glib_none().0)) }
1236 }
1237
1238 /// Gets whether to size content of @self automatically.
1239 ///
1240 /// # Returns
1241 ///
1242 /// whether to size content automatically
1243 #[doc(alias = "adw_dialog_get_follows_content_size")]
1244 #[doc(alias = "get_follows_content_size")]
1245 #[doc(alias = "follows-content-size")]
1246 fn follows_content_size(&self) -> bool {
1247 unsafe {
1248 from_glib(ffi::adw_dialog_get_follows_content_size(
1249 self.as_ref().to_glib_none().0,
1250 ))
1251 }
1252 }
1253
1254 /// Gets presentation mode for @self.
1255 ///
1256 /// # Returns
1257 ///
1258 /// the presentation mode
1259 #[doc(alias = "adw_dialog_get_presentation_mode")]
1260 #[doc(alias = "get_presentation_mode")]
1261 #[doc(alias = "presentation-mode")]
1262 fn presentation_mode(&self) -> DialogPresentationMode {
1263 unsafe {
1264 from_glib(ffi::adw_dialog_get_presentation_mode(
1265 self.as_ref().to_glib_none().0,
1266 ))
1267 }
1268 }
1269
1270 /// Gets the title of @self.
1271 ///
1272 /// # Returns
1273 ///
1274 /// the title
1275 #[doc(alias = "adw_dialog_get_title")]
1276 #[doc(alias = "get_title")]
1277 fn title(&self) -> glib::GString {
1278 unsafe { from_glib_none(ffi::adw_dialog_get_title(self.as_ref().to_glib_none().0)) }
1279 }
1280
1281 /// Presents @self within @parent's window.
1282 ///
1283 /// If @self is already shown, raises it to the top instead.
1284 ///
1285 /// If the window is an [`Window`][crate::Window] or [`ApplicationWindow`][crate::ApplicationWindow], the dialog
1286 /// will be shown within it. Otherwise, it will be a separate window.
1287 /// ## `parent`
1288 /// a widget within the toplevel
1289 #[doc(alias = "adw_dialog_present")]
1290 fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
1291 unsafe {
1292 ffi::adw_dialog_present(
1293 self.as_ref().to_glib_none().0,
1294 parent.map(|p| p.as_ref()).to_glib_none().0,
1295 );
1296 }
1297 }
1298
1299 /// Sets whether @self can be closed.
1300 ///
1301 /// If set to `FALSE`, the close button, shortcuts and
1302 /// [`close()`][Self::close()] will result in [`close-attempt`][struct@crate::Dialog#close-attempt] being
1303 /// emitted instead, and bottom sheet close swipe will be disabled.
1304 /// [`force_close()`][Self::force_close()] still works.
1305 /// ## `can_close`
1306 /// whether to allow closing
1307 #[doc(alias = "adw_dialog_set_can_close")]
1308 #[doc(alias = "can-close")]
1309 fn set_can_close(&self, can_close: bool) {
1310 unsafe {
1311 ffi::adw_dialog_set_can_close(self.as_ref().to_glib_none().0, can_close.into_glib());
1312 }
1313 }
1314
1315 /// Sets the child widget of @self.
1316 /// ## `child`
1317 /// the child widget
1318 #[doc(alias = "adw_dialog_set_child")]
1319 #[doc(alias = "child")]
1320 fn set_child(&self, child: Option<&impl IsA<gtk::Widget>>) {
1321 unsafe {
1322 ffi::adw_dialog_set_child(
1323 self.as_ref().to_glib_none().0,
1324 child.map(|p| p.as_ref()).to_glib_none().0,
1325 );
1326 }
1327 }
1328
1329 /// Sets the height of the dialog's contents.
1330 ///
1331 /// Set it to -1 to reset it to the content's natural height.
1332 ///
1333 /// See also: [`default-height`][struct@crate::gtk::Window#default-height]
1334 /// ## `content_height`
1335 /// the content height
1336 #[doc(alias = "adw_dialog_set_content_height")]
1337 #[doc(alias = "content-height")]
1338 fn set_content_height(&self, content_height: i32) {
1339 unsafe {
1340 ffi::adw_dialog_set_content_height(self.as_ref().to_glib_none().0, content_height);
1341 }
1342 }
1343
1344 /// Sets the width of the dialog's contents.
1345 ///
1346 /// Set it to -1 to reset it to the content's natural width.
1347 ///
1348 /// See also: [`default-width`][struct@crate::gtk::Window#default-width]
1349 /// ## `content_width`
1350 /// the content width
1351 #[doc(alias = "adw_dialog_set_content_width")]
1352 #[doc(alias = "content-width")]
1353 fn set_content_width(&self, content_width: i32) {
1354 unsafe {
1355 ffi::adw_dialog_set_content_width(self.as_ref().to_glib_none().0, content_width);
1356 }
1357 }
1358
1359 /// Sets the default widget for @self.
1360 ///
1361 /// It's activated when the user presses Enter.
1362 /// ## `default_widget`
1363 /// the default widget
1364 #[doc(alias = "adw_dialog_set_default_widget")]
1365 #[doc(alias = "default-widget")]
1366 fn set_default_widget(&self, default_widget: Option<&impl IsA<gtk::Widget>>) {
1367 unsafe {
1368 ffi::adw_dialog_set_default_widget(
1369 self.as_ref().to_glib_none().0,
1370 default_widget.map(|p| p.as_ref()).to_glib_none().0,
1371 );
1372 }
1373 }
1374
1375 /// Sets the focus widget for @self.
1376 ///
1377 /// If @focus is not the current focus widget, and is focusable, sets it as the
1378 /// focus widget for the dialog.
1379 ///
1380 /// If focus is `NULL`, unsets the focus widget for this dialog. To set the focus
1381 /// to a particular widget in the dialog, it is usually more convenient to use
1382 /// [`WidgetExtManual::grab_focus()`][crate::gtk::prelude::WidgetExtManual::grab_focus()] instead of this function.
1383 /// ## `focus`
1384 /// the focus widget
1385 #[doc(alias = "adw_dialog_set_focus")]
1386 #[doc(alias = "focus-widget")]
1387 fn set_focus(&self, focus: Option<&impl IsA<gtk::Widget>>) {
1388 unsafe {
1389 ffi::adw_dialog_set_focus(
1390 self.as_ref().to_glib_none().0,
1391 focus.map(|p| p.as_ref()).to_glib_none().0,
1392 );
1393 }
1394 }
1395
1396 /// Sets whether to size content of @self automatically.
1397 ///
1398 /// If set to `TRUE`, always use the content's natural size instead of
1399 /// [`content-width`][struct@crate::Dialog#content-width] and [`content-height`][struct@crate::Dialog#content-height]. If
1400 /// the content resizes, the dialog will immediately resize as well.
1401 ///
1402 /// See also: [`resizable`][struct@crate::gtk::Window#resizable]
1403 /// ## `follows_content_size`
1404 /// whether to size content automatically
1405 #[doc(alias = "adw_dialog_set_follows_content_size")]
1406 #[doc(alias = "follows-content-size")]
1407 fn set_follows_content_size(&self, follows_content_size: bool) {
1408 unsafe {
1409 ffi::adw_dialog_set_follows_content_size(
1410 self.as_ref().to_glib_none().0,
1411 follows_content_size.into_glib(),
1412 );
1413 }
1414 }
1415
1416 /// Sets presentation mode for @self.
1417 ///
1418 /// When set to [enum@Adw.DialogPresentationMode.auto], the dialog appears as a
1419 /// bottom sheet when the following condition is met:
1420 /// `max-width: 450px or max-height: 360px`, and as a floating window otherwise.
1421 ///
1422 /// Set it to [enum@Adw.DialogPresentationMode.floating] or
1423 /// [enum@Adw.DialogPresentationMode.bottom-sheet] to always present it a
1424 /// floating window or a bottom sheet respectively, regardless of available size.
1425 ///
1426 /// Presentation mode does nothing for dialogs presented as a window.
1427 /// ## `presentation_mode`
1428 /// the new presentation mode
1429 #[doc(alias = "adw_dialog_set_presentation_mode")]
1430 #[doc(alias = "presentation-mode")]
1431 fn set_presentation_mode(&self, presentation_mode: DialogPresentationMode) {
1432 unsafe {
1433 ffi::adw_dialog_set_presentation_mode(
1434 self.as_ref().to_glib_none().0,
1435 presentation_mode.into_glib(),
1436 );
1437 }
1438 }
1439
1440 /// Sets the title of @self.
1441 /// ## `title`
1442 /// the new title
1443 #[doc(alias = "adw_dialog_set_title")]
1444 #[doc(alias = "title")]
1445 fn set_title(&self, title: &str) {
1446 unsafe {
1447 ffi::adw_dialog_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
1448 }
1449 }
1450
1451 /// Emitted when the close button or shortcut is used, or
1452 /// [`close()`][Self::close()] is called while [`can-close`][struct@crate::Dialog#can-close] is set to
1453 /// `FALSE`.
1454 #[cfg(feature = "v1_5")]
1455 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1456 #[doc(alias = "close-attempt")]
1457 fn connect_close_attempt<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1458 unsafe extern "C" fn close_attempt_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1459 this: *mut ffi::AdwDialog,
1460 f: glib::ffi::gpointer,
1461 ) {
1462 unsafe {
1463 let f: &F = &*(f as *const F);
1464 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1465 }
1466 }
1467 unsafe {
1468 let f: Box_<F> = Box_::new(f);
1469 connect_raw(
1470 self.as_ptr() as *mut _,
1471 c"close-attempt".as_ptr(),
1472 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1473 close_attempt_trampoline::<Self, F> as *const (),
1474 )),
1475 Box_::into_raw(f),
1476 )
1477 }
1478 }
1479
1480 /// Emitted when the dialog is successfully closed.
1481 #[cfg(feature = "v1_5")]
1482 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1483 #[doc(alias = "closed")]
1484 fn connect_closed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1485 unsafe extern "C" fn closed_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1486 this: *mut ffi::AdwDialog,
1487 f: glib::ffi::gpointer,
1488 ) {
1489 unsafe {
1490 let f: &F = &*(f as *const F);
1491 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1492 }
1493 }
1494 unsafe {
1495 let f: Box_<F> = Box_::new(f);
1496 connect_raw(
1497 self.as_ptr() as *mut _,
1498 c"closed".as_ptr(),
1499 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1500 closed_trampoline::<Self, F> as *const (),
1501 )),
1502 Box_::into_raw(f),
1503 )
1504 }
1505 }
1506
1507 #[cfg(feature = "v1_5")]
1508 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1509 #[doc(alias = "can-close")]
1510 fn connect_can_close_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1511 unsafe extern "C" fn notify_can_close_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1512 this: *mut ffi::AdwDialog,
1513 _param_spec: glib::ffi::gpointer,
1514 f: glib::ffi::gpointer,
1515 ) {
1516 unsafe {
1517 let f: &F = &*(f as *const F);
1518 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1519 }
1520 }
1521 unsafe {
1522 let f: Box_<F> = Box_::new(f);
1523 connect_raw(
1524 self.as_ptr() as *mut _,
1525 c"notify::can-close".as_ptr(),
1526 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1527 notify_can_close_trampoline::<Self, F> as *const (),
1528 )),
1529 Box_::into_raw(f),
1530 )
1531 }
1532 }
1533
1534 #[cfg(feature = "v1_5")]
1535 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1536 #[doc(alias = "child")]
1537 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1538 unsafe extern "C" fn notify_child_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1539 this: *mut ffi::AdwDialog,
1540 _param_spec: glib::ffi::gpointer,
1541 f: glib::ffi::gpointer,
1542 ) {
1543 unsafe {
1544 let f: &F = &*(f as *const F);
1545 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1546 }
1547 }
1548 unsafe {
1549 let f: Box_<F> = Box_::new(f);
1550 connect_raw(
1551 self.as_ptr() as *mut _,
1552 c"notify::child".as_ptr(),
1553 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1554 notify_child_trampoline::<Self, F> as *const (),
1555 )),
1556 Box_::into_raw(f),
1557 )
1558 }
1559 }
1560
1561 #[cfg(feature = "v1_5")]
1562 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1563 #[doc(alias = "content-height")]
1564 fn connect_content_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1565 unsafe extern "C" fn notify_content_height_trampoline<
1566 P: IsA<Dialog>,
1567 F: Fn(&P) + 'static,
1568 >(
1569 this: *mut ffi::AdwDialog,
1570 _param_spec: glib::ffi::gpointer,
1571 f: glib::ffi::gpointer,
1572 ) {
1573 unsafe {
1574 let f: &F = &*(f as *const F);
1575 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1576 }
1577 }
1578 unsafe {
1579 let f: Box_<F> = Box_::new(f);
1580 connect_raw(
1581 self.as_ptr() as *mut _,
1582 c"notify::content-height".as_ptr(),
1583 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1584 notify_content_height_trampoline::<Self, F> as *const (),
1585 )),
1586 Box_::into_raw(f),
1587 )
1588 }
1589 }
1590
1591 #[cfg(feature = "v1_5")]
1592 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1593 #[doc(alias = "content-width")]
1594 fn connect_content_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1595 unsafe extern "C" fn notify_content_width_trampoline<
1596 P: IsA<Dialog>,
1597 F: Fn(&P) + 'static,
1598 >(
1599 this: *mut ffi::AdwDialog,
1600 _param_spec: glib::ffi::gpointer,
1601 f: glib::ffi::gpointer,
1602 ) {
1603 unsafe {
1604 let f: &F = &*(f as *const F);
1605 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1606 }
1607 }
1608 unsafe {
1609 let f: Box_<F> = Box_::new(f);
1610 connect_raw(
1611 self.as_ptr() as *mut _,
1612 c"notify::content-width".as_ptr(),
1613 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1614 notify_content_width_trampoline::<Self, F> as *const (),
1615 )),
1616 Box_::into_raw(f),
1617 )
1618 }
1619 }
1620
1621 #[cfg(feature = "v1_5")]
1622 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1623 #[doc(alias = "current-breakpoint")]
1624 fn connect_current_breakpoint_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1625 unsafe extern "C" fn notify_current_breakpoint_trampoline<
1626 P: IsA<Dialog>,
1627 F: Fn(&P) + 'static,
1628 >(
1629 this: *mut ffi::AdwDialog,
1630 _param_spec: glib::ffi::gpointer,
1631 f: glib::ffi::gpointer,
1632 ) {
1633 unsafe {
1634 let f: &F = &*(f as *const F);
1635 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1636 }
1637 }
1638 unsafe {
1639 let f: Box_<F> = Box_::new(f);
1640 connect_raw(
1641 self.as_ptr() as *mut _,
1642 c"notify::current-breakpoint".as_ptr(),
1643 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1644 notify_current_breakpoint_trampoline::<Self, F> as *const (),
1645 )),
1646 Box_::into_raw(f),
1647 )
1648 }
1649 }
1650
1651 #[cfg(feature = "v1_5")]
1652 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1653 #[doc(alias = "default-widget")]
1654 fn connect_default_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1655 unsafe extern "C" fn notify_default_widget_trampoline<
1656 P: IsA<Dialog>,
1657 F: Fn(&P) + 'static,
1658 >(
1659 this: *mut ffi::AdwDialog,
1660 _param_spec: glib::ffi::gpointer,
1661 f: glib::ffi::gpointer,
1662 ) {
1663 unsafe {
1664 let f: &F = &*(f as *const F);
1665 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1666 }
1667 }
1668 unsafe {
1669 let f: Box_<F> = Box_::new(f);
1670 connect_raw(
1671 self.as_ptr() as *mut _,
1672 c"notify::default-widget".as_ptr(),
1673 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1674 notify_default_widget_trampoline::<Self, F> as *const (),
1675 )),
1676 Box_::into_raw(f),
1677 )
1678 }
1679 }
1680
1681 #[cfg(feature = "v1_5")]
1682 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1683 #[doc(alias = "focus-widget")]
1684 fn connect_focus_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1685 unsafe extern "C" fn notify_focus_widget_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1686 this: *mut ffi::AdwDialog,
1687 _param_spec: glib::ffi::gpointer,
1688 f: glib::ffi::gpointer,
1689 ) {
1690 unsafe {
1691 let f: &F = &*(f as *const F);
1692 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1693 }
1694 }
1695 unsafe {
1696 let f: Box_<F> = Box_::new(f);
1697 connect_raw(
1698 self.as_ptr() as *mut _,
1699 c"notify::focus-widget".as_ptr(),
1700 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1701 notify_focus_widget_trampoline::<Self, F> as *const (),
1702 )),
1703 Box_::into_raw(f),
1704 )
1705 }
1706 }
1707
1708 #[cfg(feature = "v1_5")]
1709 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1710 #[doc(alias = "follows-content-size")]
1711 fn connect_follows_content_size_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1712 unsafe extern "C" fn notify_follows_content_size_trampoline<
1713 P: IsA<Dialog>,
1714 F: Fn(&P) + 'static,
1715 >(
1716 this: *mut ffi::AdwDialog,
1717 _param_spec: glib::ffi::gpointer,
1718 f: glib::ffi::gpointer,
1719 ) {
1720 unsafe {
1721 let f: &F = &*(f as *const F);
1722 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1723 }
1724 }
1725 unsafe {
1726 let f: Box_<F> = Box_::new(f);
1727 connect_raw(
1728 self.as_ptr() as *mut _,
1729 c"notify::follows-content-size".as_ptr(),
1730 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1731 notify_follows_content_size_trampoline::<Self, F> as *const (),
1732 )),
1733 Box_::into_raw(f),
1734 )
1735 }
1736 }
1737
1738 #[cfg(feature = "v1_5")]
1739 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1740 #[doc(alias = "presentation-mode")]
1741 fn connect_presentation_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1742 unsafe extern "C" fn notify_presentation_mode_trampoline<
1743 P: IsA<Dialog>,
1744 F: Fn(&P) + 'static,
1745 >(
1746 this: *mut ffi::AdwDialog,
1747 _param_spec: glib::ffi::gpointer,
1748 f: glib::ffi::gpointer,
1749 ) {
1750 unsafe {
1751 let f: &F = &*(f as *const F);
1752 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1753 }
1754 }
1755 unsafe {
1756 let f: Box_<F> = Box_::new(f);
1757 connect_raw(
1758 self.as_ptr() as *mut _,
1759 c"notify::presentation-mode".as_ptr(),
1760 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1761 notify_presentation_mode_trampoline::<Self, F> as *const (),
1762 )),
1763 Box_::into_raw(f),
1764 )
1765 }
1766 }
1767
1768 #[cfg(feature = "v1_5")]
1769 #[cfg_attr(docsrs, doc(cfg(feature = "v1_5")))]
1770 #[doc(alias = "title")]
1771 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1772 unsafe extern "C" fn notify_title_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1773 this: *mut ffi::AdwDialog,
1774 _param_spec: glib::ffi::gpointer,
1775 f: glib::ffi::gpointer,
1776 ) {
1777 unsafe {
1778 let f: &F = &*(f as *const F);
1779 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1780 }
1781 }
1782 unsafe {
1783 let f: Box_<F> = Box_::new(f);
1784 connect_raw(
1785 self.as_ptr() as *mut _,
1786 c"notify::title".as_ptr(),
1787 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1788 notify_title_trampoline::<Self, F> as *const (),
1789 )),
1790 Box_::into_raw(f),
1791 )
1792 }
1793 }
1794}
1795
1796impl<O: IsA<Dialog>> AdwDialogExt for O {}