gtk4/auto/
dialog.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4#![allow(deprecated)]
5
6#[cfg(feature = "v4_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
8use crate::WindowGravity;
9use crate::{
10    ffi, Accessible, AccessibleRole, Align, Application, Box, Buildable, ConstraintTarget,
11    HeaderBar, LayoutManager, Native, Overflow, ResponseType, Root, ShortcutManager, Widget,
12    Window,
13};
14use glib::{
15    object::ObjectType as _,
16    prelude::*,
17    signal::{connect_raw, SignalHandlerId},
18    translate::*,
19};
20use std::boxed::Box as Box_;
21
22glib::wrapper! {
23    /// Use [`Window`][crate::Window] instead
24    /// Dialogs are a convenient way to prompt the user for a small amount
25    /// of input.
26    ///
27    /// <picture>
28    ///   <source srcset="dialog-dark.png" media="(prefers-color-scheme: dark)">
29    ///   <img alt="An example GtkDialog" src="dialog.png">
30    /// </picture>
31    ///
32    /// Typical uses are to display a message, ask a question, or anything else
33    /// that does not require extensive effort on the user’s part.
34    ///
35    /// The main area of a [`Dialog`][crate::Dialog] is called the "content area", and is yours
36    /// to populate with widgets such a [`Label`][crate::Label] or [`Entry`][crate::Entry], to present
37    /// your information, questions, or tasks to the user.
38    ///
39    /// In addition, dialogs allow you to add "action widgets". Most commonly,
40    /// action widgets are buttons. Depending on the platform, action widgets may
41    /// be presented in the header bar at the top of the window, or at the bottom
42    /// of the window. To add action widgets, create your [`Dialog`][crate::Dialog] using
43    /// [`with_buttons()`][Self::with_buttons()], or use
44    /// [`DialogExt::add_button()`][crate::prelude::DialogExt::add_button()], [`DialogExtManual::add_buttons()`][crate::prelude::DialogExtManual::add_buttons()],
45    /// or [`DialogExt::add_action_widget()`][crate::prelude::DialogExt::add_action_widget()].
46    ///
47    /// `GtkDialogs` uses some heuristics to decide whether to add a close
48    /// button to the window decorations. If any of the action buttons use
49    /// the response ID [`ResponseType::Close`][crate::ResponseType::Close] or [`ResponseType::Cancel`][crate::ResponseType::Cancel], the
50    /// close button is omitted.
51    ///
52    /// Clicking a button that was added as an action widget will emit the
53    /// [`response`][struct@crate::Dialog#response] signal with a response ID that you specified.
54    /// GTK will never assign a meaning to positive response IDs; these are
55    /// entirely user-defined. But for convenience, you can use the response
56    /// IDs in the [`ResponseType`][crate::ResponseType] enumeration (these all have values
57    /// less than zero). If a dialog receives a delete event, the
58    /// [`response`][struct@crate::Dialog#response] signal will be emitted with the
59    /// [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent] response ID.
60    ///
61    /// Dialogs are created with a call to [`new()`][Self::new()] or
62    /// [`with_buttons()`][Self::with_buttons()]. The latter is recommended; it allows
63    /// you to set the dialog title, some convenient flags, and add buttons.
64    ///
65    /// A “modal” dialog (that is, one which freezes the rest of the application
66    /// from user input), can be created by calling [`GtkWindowExt::set_modal()`][crate::prelude::GtkWindowExt::set_modal()]
67    /// on the dialog. When using [`with_buttons()`][Self::with_buttons()], you can also
68    /// pass the [`DialogFlags::MODAL`][crate::DialogFlags::MODAL] flag to make a dialog modal.
69    ///
70    /// For the simple dialog in the following example, a [`MessageDialog`][crate::MessageDialog]
71    /// would save some effort. But you’d need to create the dialog contents manually
72    /// if you had more than a simple message in the dialog.
73    ///
74    /// An example for simple [`Dialog`][crate::Dialog] usage:
75    ///
76    /// **⚠️ The following code is in c ⚠️**
77    ///
78    /// ```c
79    /// // Function to open a dialog box with a message
80    /// void
81    /// quick_message (GtkWindow *parent, char *message)
82    /// {
83    ///  GtkWidget *dialog, *label, *content_area;
84    ///  GtkDialogFlags flags;
85    ///
86    ///  // Create the widgets
87    ///  flags = GTK_DIALOG_DESTROY_WITH_PARENT;
88    ///  dialog = gtk_dialog_new_with_buttons ("Message",
89    ///                                        parent,
90    ///                                        flags,
91    ///                                        _("_OK"),
92    ///                                        GTK_RESPONSE_NONE,
93    ///                                        NULL);
94    ///  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
95    ///  label = gtk_label_new (message);
96    ///
97    ///  // Ensure that the dialog box is destroyed when the user responds
98    ///
99    ///  g_signal_connect_swapped (dialog,
100    ///                            "response",
101    ///                            G_CALLBACK (gtk_window_destroy),
102    ///                            dialog);
103    ///
104    ///  // Add the label, and show everything we’ve added
105    ///
106    ///  gtk_box_append (GTK_BOX (content_area), label);
107    ///  gtk_widget_show (dialog);
108    /// }
109    /// ```
110    ///
111    /// # GtkDialog as GtkBuildable
112    ///
113    /// The [`Dialog`][crate::Dialog] implementation of the [`Buildable`][crate::Buildable] interface exposes the
114    /// @content_area as an internal child with the name “content_area”.
115    ///
116    /// [`Dialog`][crate::Dialog] supports a custom `<action-widgets>` element, which can contain
117    /// multiple `<action-widget>` elements. The “response” attribute specifies a
118    /// numeric response, and the content of the element is the id of widget
119    /// (which should be a child of the dialogs @action_area). To mark a response
120    /// as default, set the “default” attribute of the `<action-widget>` element
121    /// to true.
122    ///
123    /// [`Dialog`][crate::Dialog] supports adding action widgets by specifying “action” as
124    /// the “type” attribute of a `<child>` element. The widget will be added
125    /// either to the action area or the headerbar of the dialog, depending
126    /// on the “use-header-bar” property. The response id has to be associated
127    /// with the action widget using the `<action-widgets>` element.
128    ///
129    /// An example of a [`Dialog`][crate::Dialog] UI definition fragment:
130    ///
131    /// ```xml
132    /// <object class="GtkDialog" id="dialog1">
133    ///   <child type="action">
134    ///     <object class="GtkButton" id="button_cancel"/>
135    ///   </child>
136    ///   <child type="action">
137    ///     <object class="GtkButton" id="button_ok">
138    ///     </object>
139    ///   </child>
140    ///   <action-widgets>
141    ///     <action-widget response="cancel">button_cancel</action-widget>
142    ///     <action-widget response="ok" default="true">button_ok</action-widget>
143    ///   </action-widgets>
144    /// </object>
145    /// ```
146    ///
147    /// # Accessibility
148    ///
149    /// [`Dialog`][crate::Dialog] uses the [`AccessibleRole::Dialog`][crate::AccessibleRole::Dialog] role.
150    ///
151    /// ## Properties
152    ///
153    ///
154    /// #### `use-header-bar`
155    ///  [`true`] if the dialog uses a headerbar for action buttons
156    /// instead of the action-area.
157    ///
158    /// For technical reasons, this property is declared as an integer
159    /// property, but you should only set it to [`true`] or [`false`].
160    ///
161    /// ## Creating a dialog with headerbar
162    ///
163    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
164    /// set this property according to platform conventions (using the
165    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
166    ///
167    /// Here is how you can achieve the same:
168    ///
169    /// **⚠️ The following code is in c ⚠️**
170    ///
171    /// ```c
172    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
173    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
174    /// ```
175    ///
176    /// Readable | Writeable | Construct Only
177    /// <details><summary><h4>Window</h4></summary>
178    ///
179    ///
180    /// #### `application`
181    ///  The [`Application`][crate::Application] associated with the window.
182    ///
183    /// The application will be kept alive for at least as long as it
184    /// has any windows associated with it (see g_application_hold()
185    /// for a way to keep it alive without windows).
186    ///
187    /// Normally, the connection between the application and the window
188    /// will remain until the window is destroyed, but you can explicitly
189    /// remove it by setting the this property to `NULL`.
190    ///
191    /// Readable | Writeable
192    ///
193    ///
194    /// #### `child`
195    ///  The child widget.
196    ///
197    /// Readable | Writeable
198    ///
199    ///
200    /// #### `decorated`
201    ///  Whether the window should have a frame (also known as *decorations*).
202    ///
203    /// Readable | Writeable
204    ///
205    ///
206    /// #### `default-height`
207    ///  The default height of the window.
208    ///
209    /// Readable | Writeable
210    ///
211    ///
212    /// #### `default-widget`
213    ///  The default widget.
214    ///
215    /// Readable | Writeable
216    ///
217    ///
218    /// #### `default-width`
219    ///  The default width of the window.
220    ///
221    /// Readable | Writeable
222    ///
223    ///
224    /// #### `deletable`
225    ///  Whether the window frame should have a close button.
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `destroy-with-parent`
231    ///  If this window should be destroyed when the parent is destroyed.
232    ///
233    /// Readable | Writeable
234    ///
235    ///
236    /// #### `display`
237    ///  The display that will display this window.
238    ///
239    /// Readable | Writeable
240    ///
241    ///
242    /// #### `focus-visible`
243    ///  Whether 'focus rectangles' are currently visible in this window.
244    ///
245    /// This property is maintained by GTK based on user input
246    /// and should not be set by applications.
247    ///
248    /// Readable | Writeable
249    ///
250    ///
251    /// #### `focus-widget`
252    ///  The focus widget.
253    ///
254    /// Readable | Writeable
255    ///
256    ///
257    /// #### `fullscreened`
258    ///  Whether the window is fullscreen.
259    ///
260    /// Setting this property is the equivalent of calling
261    /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
262    /// either operation is asynchronous, which means you will need to
263    /// connect to the ::notify signal in order to know whether the
264    /// operation was successful.
265    ///
266    /// Readable | Writeable
267    ///
268    ///
269    /// #### `gravity`
270    ///  The gravity to use when resizing the window programmatically.
271    ///
272    /// Gravity describes which point of the window we want to keep
273    /// fixed (meaning that the window will grow in the opposite direction).
274    /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
275    /// want the to fix top right corner of the window.
276    ///
277    /// Readable | Writeable
278    ///
279    ///
280    /// #### `handle-menubar-accel`
281    ///  Whether the window frame should handle <kbd>F10</kbd> for activating
282    /// menubars.
283    ///
284    /// Readable | Writeable
285    ///
286    ///
287    /// #### `hide-on-close`
288    ///  If this window should be hidden instead of destroyed when the user clicks
289    /// the close button.
290    ///
291    /// Readable | Writeable
292    ///
293    ///
294    /// #### `icon-name`
295    ///  Specifies the name of the themed icon to use as the window icon.
296    ///
297    /// See [`IconTheme`][crate::IconTheme] for more details.
298    ///
299    /// Readable | Writeable
300    ///
301    ///
302    /// #### `is-active`
303    ///  Whether the toplevel is the currently active window.
304    ///
305    /// Readable
306    ///
307    ///
308    /// #### `maximized`
309    ///  Whether the window is maximized.
310    ///
311    /// Setting this property is the equivalent of calling
312    /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
313    /// either operation is asynchronous, which means you will need to
314    /// connect to the ::notify signal in order to know whether the
315    /// operation was successful.
316    ///
317    /// Readable | Writeable
318    ///
319    ///
320    /// #### `mnemonics-visible`
321    ///  Whether mnemonics are currently visible in this window.
322    ///
323    /// This property is maintained by GTK based on user input,
324    /// and should not be set by applications.
325    ///
326    /// Readable | Writeable
327    ///
328    ///
329    /// #### `modal`
330    ///  If true, the window is modal.
331    ///
332    /// Readable | Writeable
333    ///
334    ///
335    /// #### `resizable`
336    ///  If true, users can resize the window.
337    ///
338    /// Readable | Writeable
339    ///
340    ///
341    /// #### `startup-id`
342    ///  A write-only property for setting window's startup notification identifier.
343    ///
344    /// Writeable
345    ///
346    ///
347    /// #### `suspended`
348    ///  Whether the window is suspended.
349    ///
350    /// See [`GtkWindowExt::is_suspended()`][crate::prelude::GtkWindowExt::is_suspended()] for details about what suspended means.
351    ///
352    /// Readable
353    ///
354    ///
355    /// #### `title`
356    ///  The title of the window.
357    ///
358    /// Readable | Writeable
359    ///
360    ///
361    /// #### `titlebar`
362    ///  The titlebar widget.
363    ///
364    /// Readable | Writeable
365    ///
366    ///
367    /// #### `transient-for`
368    ///  The transient parent of the window.
369    ///
370    /// Readable | Writeable | Construct
371    /// </details>
372    /// <details><summary><h4>Widget</h4></summary>
373    ///
374    ///
375    /// #### `can-focus`
376    ///  Whether the widget or any of its descendents can accept
377    /// the input focus.
378    ///
379    /// This property is meant to be set by widget implementations,
380    /// typically in their instance init function.
381    ///
382    /// Readable | Writeable
383    ///
384    ///
385    /// #### `can-target`
386    ///  Whether the widget can receive pointer events.
387    ///
388    /// Readable | Writeable
389    ///
390    ///
391    /// #### `css-classes`
392    ///  A list of css classes applied to this widget.
393    ///
394    /// Readable | Writeable
395    ///
396    ///
397    /// #### `css-name`
398    ///  The name of this widget in the CSS tree.
399    ///
400    /// This property is meant to be set by widget implementations,
401    /// typically in their instance init function.
402    ///
403    /// Readable | Writeable | Construct Only
404    ///
405    ///
406    /// #### `cursor`
407    ///  The cursor used by @widget.
408    ///
409    /// Readable | Writeable
410    ///
411    ///
412    /// #### `focus-on-click`
413    ///  Whether the widget should grab focus when it is clicked with the mouse.
414    ///
415    /// This property is only relevant for widgets that can take focus.
416    ///
417    /// Readable | Writeable
418    ///
419    ///
420    /// #### `focusable`
421    ///  Whether this widget itself will accept the input focus.
422    ///
423    /// Readable | Writeable
424    ///
425    ///
426    /// #### `halign`
427    ///  How to distribute horizontal space if widget gets extra space.
428    ///
429    /// Readable | Writeable
430    ///
431    ///
432    /// #### `has-default`
433    ///  Whether the widget is the default widget.
434    ///
435    /// Readable
436    ///
437    ///
438    /// #### `has-focus`
439    ///  Whether the widget has the input focus.
440    ///
441    /// Readable
442    ///
443    ///
444    /// #### `has-tooltip`
445    ///  Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
446    /// signal on @widget.
447    ///
448    /// A true value indicates that @widget can have a tooltip, in this case
449    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
450    /// determine whether it will provide a tooltip or not.
451    ///
452    /// Readable | Writeable
453    ///
454    ///
455    /// #### `height-request`
456    ///  Overrides for height request of the widget.
457    ///
458    /// If this is -1, the natural request will be used.
459    ///
460    /// Readable | Writeable
461    ///
462    ///
463    /// #### `hexpand`
464    ///  Whether to expand horizontally.
465    ///
466    /// Readable | Writeable
467    ///
468    ///
469    /// #### `hexpand-set`
470    ///  Whether to use the `hexpand` property.
471    ///
472    /// Readable | Writeable
473    ///
474    ///
475    /// #### `layout-manager`
476    ///  The [`LayoutManager`][crate::LayoutManager] instance to use to compute
477    /// the preferred size of the widget, and allocate its children.
478    ///
479    /// This property is meant to be set by widget implementations,
480    /// typically in their instance init function.
481    ///
482    /// Readable | Writeable
483    ///
484    ///
485    /// #### `limit-events`
486    ///  Makes this widget act like a modal dialog, with respect to
487    /// event delivery.
488    ///
489    /// Global event controllers will not handle events with targets
490    /// inside the widget, unless they are set up to ignore propagation
491    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
492    ///
493    /// Readable | Writeable
494    ///
495    ///
496    /// #### `margin-bottom`
497    ///  Margin on bottom side of widget.
498    ///
499    /// This property adds margin outside of the widget's normal size
500    /// request, the margin will be added in addition to the size from
501    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
502    ///
503    /// Readable | Writeable
504    ///
505    ///
506    /// #### `margin-end`
507    ///  Margin on end of widget, horizontally.
508    ///
509    /// This property supports left-to-right and right-to-left text
510    /// directions.
511    ///
512    /// This property adds margin outside of the widget's normal size
513    /// request, the margin will be added in addition to the size from
514    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
515    ///
516    /// Readable | Writeable
517    ///
518    ///
519    /// #### `margin-start`
520    ///  Margin on start of widget, horizontally.
521    ///
522    /// This property supports left-to-right and right-to-left text
523    /// directions.
524    ///
525    /// This property adds margin outside of the widget's normal size
526    /// request, the margin will be added in addition to the size from
527    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
528    ///
529    /// Readable | Writeable
530    ///
531    ///
532    /// #### `margin-top`
533    ///  Margin on top side of widget.
534    ///
535    /// This property adds margin outside of the widget's normal size
536    /// request, the margin will be added in addition to the size from
537    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
538    ///
539    /// Readable | Writeable
540    ///
541    ///
542    /// #### `name`
543    ///  The name of the widget.
544    ///
545    /// Readable | Writeable
546    ///
547    ///
548    /// #### `opacity`
549    ///  The requested opacity of the widget.
550    ///
551    /// Readable | Writeable
552    ///
553    ///
554    /// #### `overflow`
555    ///  How content outside the widget's content area is treated.
556    ///
557    /// This property is meant to be set by widget implementations,
558    /// typically in their instance init function.
559    ///
560    /// Readable | Writeable
561    ///
562    ///
563    /// #### `parent`
564    ///  The parent widget of this widget.
565    ///
566    /// Readable
567    ///
568    ///
569    /// #### `receives-default`
570    ///  Whether the widget will receive the default action when it is focused.
571    ///
572    /// Readable | Writeable
573    ///
574    ///
575    /// #### `root`
576    ///  The [`Root`][crate::Root] widget of the widget tree containing this widget.
577    ///
578    /// This will be `NULL` if the widget is not contained in a root widget.
579    ///
580    /// Readable
581    ///
582    ///
583    /// #### `scale-factor`
584    ///  The scale factor of the widget.
585    ///
586    /// Readable
587    ///
588    ///
589    /// #### `sensitive`
590    ///  Whether the widget responds to input.
591    ///
592    /// Readable | Writeable
593    ///
594    ///
595    /// #### `tooltip-markup`
596    ///  Sets the text of tooltip to be the given string, which is marked up
597    /// with Pango markup.
598    ///
599    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
600    ///
601    /// This is a convenience property which will take care of getting the
602    /// tooltip shown if the given string is not `NULL`:
603    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
604    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
605    /// the default signal handler.
606    ///
607    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
608    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
609    ///
610    /// Readable | Writeable
611    ///
612    ///
613    /// #### `tooltip-text`
614    ///  Sets the text of tooltip to be the given string.
615    ///
616    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
617    ///
618    /// This is a convenience property which will take care of getting the
619    /// tooltip shown if the given string is not `NULL`:
620    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
621    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
622    /// the default signal handler.
623    ///
624    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
625    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
626    ///
627    /// Readable | Writeable
628    ///
629    ///
630    /// #### `valign`
631    ///  How to distribute vertical space if widget gets extra space.
632    ///
633    /// Readable | Writeable
634    ///
635    ///
636    /// #### `vexpand`
637    ///  Whether to expand vertically.
638    ///
639    /// Readable | Writeable
640    ///
641    ///
642    /// #### `vexpand-set`
643    ///  Whether to use the `vexpand` property.
644    ///
645    /// Readable | Writeable
646    ///
647    ///
648    /// #### `visible`
649    ///  Whether the widget is visible.
650    ///
651    /// Readable | Writeable
652    ///
653    ///
654    /// #### `width-request`
655    ///  Overrides for width request of the widget.
656    ///
657    /// If this is -1, the natural request will be used.
658    ///
659    /// Readable | Writeable
660    /// </details>
661    /// <details><summary><h4>Accessible</h4></summary>
662    ///
663    ///
664    /// #### `accessible-role`
665    ///  The accessible role of the given [`Accessible`][crate::Accessible] implementation.
666    ///
667    /// The accessible role cannot be changed once set.
668    ///
669    /// Readable | Writeable
670    /// </details>
671    ///
672    /// ## Signals
673    ///
674    ///
675    /// #### `close`
676    ///  Emitted when the user uses a keybinding to close the dialog.
677    ///
678    /// This is a [keybinding signal](class.SignalAction.html).
679    ///
680    /// The default binding for this signal is the Escape key.
681    ///
682    /// Action
683    ///
684    ///
685    /// #### `response`
686    ///  Emitted when an action widget is clicked.
687    ///
688    /// The signal is also emitted when the dialog receives a
689    /// delete event, and when [`DialogExt::response()`][crate::prelude::DialogExt::response()] is called.
690    /// On a delete event, the response ID is [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent].
691    /// Otherwise, it depends on which action widget was clicked.
692    ///
693    ///
694    /// <details><summary><h4>Window</h4></summary>
695    ///
696    ///
697    /// #### `activate-default`
698    ///  Emitted when the user activates the default widget.
699    ///
700    /// This is a [keybinding signal](class.SignalAction.html).
701    ///
702    /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
703    ///
704    /// Action
705    ///
706    ///
707    /// #### `activate-focus`
708    ///  Emitted when the user activates the currently focused
709    /// widget of @window.
710    ///
711    /// This is a [keybinding signal](class.SignalAction.html).
712    ///
713    /// The default binding for this signal is <kbd>␣</kbd>.
714    ///
715    /// Action
716    ///
717    ///
718    /// #### `close-request`
719    ///  Emitted when the user clicks on the close button of the window.
720    ///
721    ///
722    ///
723    ///
724    /// #### `enable-debugging`
725    ///  Emitted when the user enables or disables interactive debugging.
726    ///
727    /// When @toggle is true, interactive debugging is toggled on or off,
728    /// when it is false, the debugger will be pointed at the widget
729    /// under the pointer.
730    ///
731    /// This is a [keybinding signal](class.SignalAction.html).
732    ///
733    /// The default bindings for this signal are
734    /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> and
735    /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd>.
736    ///
737    /// Action
738    ///
739    ///
740    /// #### `keys-changed`
741    ///  Emitted when the set of accelerators or mnemonics that
742    /// are associated with the window changes.
743    ///
744    ///
745    /// </details>
746    /// <details><summary><h4>Widget</h4></summary>
747    ///
748    ///
749    /// #### `destroy`
750    ///  Signals that all holders of a reference to the widget should release
751    /// the reference that they hold.
752    ///
753    /// May result in finalization of the widget if all references are released.
754    ///
755    /// This signal is not suitable for saving widget state.
756    ///
757    ///
758    ///
759    ///
760    /// #### `direction-changed`
761    ///  Emitted when the text direction of a widget changes.
762    ///
763    ///
764    ///
765    ///
766    /// #### `hide`
767    ///  Emitted when @widget is hidden.
768    ///
769    ///
770    ///
771    ///
772    /// #### `keynav-failed`
773    ///  Emitted if keyboard navigation fails.
774    ///
775    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
776    ///
777    ///
778    ///
779    ///
780    /// #### `map`
781    ///  Emitted when @widget is going to be mapped.
782    ///
783    /// A widget is mapped when the widget is visible (which is controlled with
784    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
785    /// are also visible.
786    ///
787    /// The `::map` signal can be used to determine whether a widget will be drawn,
788    /// for instance it can resume an animation that was stopped during the
789    /// emission of [`unmap`][struct@crate::Widget#unmap].
790    ///
791    ///
792    ///
793    ///
794    /// #### `mnemonic-activate`
795    ///  Emitted when a widget is activated via a mnemonic.
796    ///
797    /// The default handler for this signal activates @widget if @group_cycling
798    /// is false, or just makes @widget grab focus if @group_cycling is true.
799    ///
800    ///
801    ///
802    ///
803    /// #### `move-focus`
804    ///  Emitted when the focus is moved.
805    ///
806    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
807    ///
808    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
809    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
810    ///
811    /// Action
812    ///
813    ///
814    /// #### `query-tooltip`
815    ///  Emitted when the widget’s tooltip is about to be shown.
816    ///
817    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
818    /// is true and the hover timeout has expired with the cursor hovering
819    /// above @widget; or emitted when @widget got focus in keyboard mode.
820    ///
821    /// Using the given coordinates, the signal handler should determine
822    /// whether a tooltip should be shown for @widget. If this is the case
823    /// true should be returned, false otherwise. Note that if @keyboard_mode
824    /// is true, the values of @x and @y are undefined and should not be used.
825    ///
826    /// The signal handler is free to manipulate @tooltip with the therefore
827    /// destined function calls.
828    ///
829    ///
830    ///
831    ///
832    /// #### `realize`
833    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
834    ///
835    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
836    /// or the widget has been mapped (that is, it is going to be drawn).
837    ///
838    ///
839    ///
840    ///
841    /// #### `show`
842    ///  Emitted when @widget is shown.
843    ///
844    ///
845    ///
846    ///
847    /// #### `state-flags-changed`
848    ///  Emitted when the widget state changes.
849    ///
850    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
851    ///
852    ///
853    ///
854    ///
855    /// #### `unmap`
856    ///  Emitted when @widget is going to be unmapped.
857    ///
858    /// A widget is unmapped when either it or any of its parents up to the
859    /// toplevel widget have been set as hidden.
860    ///
861    /// As `::unmap` indicates that a widget will not be shown any longer,
862    /// it can be used to, for example, stop an animation on the widget.
863    ///
864    ///
865    ///
866    ///
867    /// #### `unrealize`
868    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
869    ///
870    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
871    /// or the widget has been unmapped (that is, it is going to be hidden).
872    ///
873    ///
874    /// </details>
875    ///
876    /// # Implements
877    ///
878    /// [`DialogExt`][trait@crate::prelude::DialogExt], [`GtkWindowExt`][trait@crate::prelude::GtkWindowExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`NativeExt`][trait@crate::prelude::NativeExt], [`RootExt`][trait@crate::prelude::RootExt], [`ShortcutManagerExt`][trait@crate::prelude::ShortcutManagerExt], [`DialogExtManual`][trait@crate::prelude::DialogExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
879    #[doc(alias = "GtkDialog")]
880    pub struct Dialog(Object<ffi::GtkDialog, ffi::GtkDialogClass>) @extends Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager;
881
882    match fn {
883        type_ => || ffi::gtk_dialog_get_type(),
884    }
885}
886
887impl Dialog {
888    pub const NONE: Option<&'static Dialog> = None;
889
890    /// Creates a new dialog box.
891    ///
892    /// Widgets should not be packed into the [`Window`][crate::Window]
893    /// directly, but into the @content_area and @action_area,
894    /// as described above.
895    ///
896    /// # Deprecated since 4.10
897    ///
898    /// Use [`Window`][crate::Window] instead
899    ///
900    /// # Returns
901    ///
902    /// the new dialog as a [`Widget`][crate::Widget]
903    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
904    #[allow(deprecated)]
905    #[doc(alias = "gtk_dialog_new")]
906    pub fn new() -> Dialog {
907        assert_initialized_main_thread!();
908        unsafe { Widget::from_glib_none(ffi::gtk_dialog_new()).unsafe_cast() }
909    }
910
911    // rustdoc-stripper-ignore-next
912    /// Creates a new builder-pattern struct instance to construct [`Dialog`] objects.
913    ///
914    /// This method returns an instance of [`DialogBuilder`](crate::builders::DialogBuilder) which can be used to create [`Dialog`] objects.
915    pub fn builder() -> DialogBuilder {
916        DialogBuilder::new()
917    }
918}
919
920impl Default for Dialog {
921    fn default() -> Self {
922        Self::new()
923    }
924}
925
926// rustdoc-stripper-ignore-next
927/// A [builder-pattern] type to construct [`Dialog`] objects.
928///
929/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
930#[must_use = "The builder must be built to be used"]
931pub struct DialogBuilder {
932    builder: glib::object::ObjectBuilder<'static, Dialog>,
933}
934
935impl DialogBuilder {
936    fn new() -> Self {
937        Self {
938            builder: glib::object::Object::builder(),
939        }
940    }
941
942    /// [`true`] if the dialog uses a headerbar for action buttons
943    /// instead of the action-area.
944    ///
945    /// For technical reasons, this property is declared as an integer
946    /// property, but you should only set it to [`true`] or [`false`].
947    ///
948    /// ## Creating a dialog with headerbar
949    ///
950    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
951    /// set this property according to platform conventions (using the
952    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
953    ///
954    /// Here is how you can achieve the same:
955    ///
956    /// **⚠️ The following code is in c ⚠️**
957    ///
958    /// ```c
959    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
960    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
961    /// ```
962    /// Use [`Window`][crate::Window] instead
963    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
964    pub fn use_header_bar(self, use_header_bar: i32) -> Self {
965        Self {
966            builder: self.builder.property("use-header-bar", use_header_bar),
967        }
968    }
969
970    /// The [`Application`][crate::Application] associated with the window.
971    ///
972    /// The application will be kept alive for at least as long as it
973    /// has any windows associated with it (see g_application_hold()
974    /// for a way to keep it alive without windows).
975    ///
976    /// Normally, the connection between the application and the window
977    /// will remain until the window is destroyed, but you can explicitly
978    /// remove it by setting the this property to `NULL`.
979    pub fn application(self, application: &impl IsA<Application>) -> Self {
980        Self {
981            builder: self
982                .builder
983                .property("application", application.clone().upcast()),
984        }
985    }
986
987    /// The child widget.
988    pub fn child(self, child: &impl IsA<Widget>) -> Self {
989        Self {
990            builder: self.builder.property("child", child.clone().upcast()),
991        }
992    }
993
994    /// Whether the window should have a frame (also known as *decorations*).
995    pub fn decorated(self, decorated: bool) -> Self {
996        Self {
997            builder: self.builder.property("decorated", decorated),
998        }
999    }
1000
1001    /// The default height of the window.
1002    pub fn default_height(self, default_height: i32) -> Self {
1003        Self {
1004            builder: self.builder.property("default-height", default_height),
1005        }
1006    }
1007
1008    /// The default widget.
1009    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
1010        Self {
1011            builder: self
1012                .builder
1013                .property("default-widget", default_widget.clone().upcast()),
1014        }
1015    }
1016
1017    /// The default width of the window.
1018    pub fn default_width(self, default_width: i32) -> Self {
1019        Self {
1020            builder: self.builder.property("default-width", default_width),
1021        }
1022    }
1023
1024    /// Whether the window frame should have a close button.
1025    pub fn deletable(self, deletable: bool) -> Self {
1026        Self {
1027            builder: self.builder.property("deletable", deletable),
1028        }
1029    }
1030
1031    /// If this window should be destroyed when the parent is destroyed.
1032    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
1033        Self {
1034            builder: self
1035                .builder
1036                .property("destroy-with-parent", destroy_with_parent),
1037        }
1038    }
1039
1040    /// The display that will display this window.
1041    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
1042        Self {
1043            builder: self.builder.property("display", display.clone().upcast()),
1044        }
1045    }
1046
1047    /// Whether 'focus rectangles' are currently visible in this window.
1048    ///
1049    /// This property is maintained by GTK based on user input
1050    /// and should not be set by applications.
1051    pub fn focus_visible(self, focus_visible: bool) -> Self {
1052        Self {
1053            builder: self.builder.property("focus-visible", focus_visible),
1054        }
1055    }
1056
1057    /// The focus widget.
1058    pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
1059        Self {
1060            builder: self
1061                .builder
1062                .property("focus-widget", focus_widget.clone().upcast()),
1063        }
1064    }
1065
1066    /// Whether the window is fullscreen.
1067    ///
1068    /// Setting this property is the equivalent of calling
1069    /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
1070    /// either operation is asynchronous, which means you will need to
1071    /// connect to the ::notify signal in order to know whether the
1072    /// operation was successful.
1073    pub fn fullscreened(self, fullscreened: bool) -> Self {
1074        Self {
1075            builder: self.builder.property("fullscreened", fullscreened),
1076        }
1077    }
1078
1079    /// The gravity to use when resizing the window programmatically.
1080    ///
1081    /// Gravity describes which point of the window we want to keep
1082    /// fixed (meaning that the window will grow in the opposite direction).
1083    /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
1084    /// want the to fix top right corner of the window.
1085    #[cfg(feature = "v4_20")]
1086    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1087    pub fn gravity(self, gravity: WindowGravity) -> Self {
1088        Self {
1089            builder: self.builder.property("gravity", gravity),
1090        }
1091    }
1092
1093    /// Whether the window frame should handle <kbd>F10</kbd> for activating
1094    /// menubars.
1095    #[cfg(feature = "v4_2")]
1096    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
1097    pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
1098        Self {
1099            builder: self
1100                .builder
1101                .property("handle-menubar-accel", handle_menubar_accel),
1102        }
1103    }
1104
1105    /// If this window should be hidden instead of destroyed when the user clicks
1106    /// the close button.
1107    pub fn hide_on_close(self, hide_on_close: bool) -> Self {
1108        Self {
1109            builder: self.builder.property("hide-on-close", hide_on_close),
1110        }
1111    }
1112
1113    /// Specifies the name of the themed icon to use as the window icon.
1114    ///
1115    /// See [`IconTheme`][crate::IconTheme] for more details.
1116    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1117        Self {
1118            builder: self.builder.property("icon-name", icon_name.into()),
1119        }
1120    }
1121
1122    /// Whether the window is maximized.
1123    ///
1124    /// Setting this property is the equivalent of calling
1125    /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
1126    /// either operation is asynchronous, which means you will need to
1127    /// connect to the ::notify signal in order to know whether the
1128    /// operation was successful.
1129    pub fn maximized(self, maximized: bool) -> Self {
1130        Self {
1131            builder: self.builder.property("maximized", maximized),
1132        }
1133    }
1134
1135    /// Whether mnemonics are currently visible in this window.
1136    ///
1137    /// This property is maintained by GTK based on user input,
1138    /// and should not be set by applications.
1139    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
1140        Self {
1141            builder: self
1142                .builder
1143                .property("mnemonics-visible", mnemonics_visible),
1144        }
1145    }
1146
1147    /// If true, the window is modal.
1148    pub fn modal(self, modal: bool) -> Self {
1149        Self {
1150            builder: self.builder.property("modal", modal),
1151        }
1152    }
1153
1154    /// If true, users can resize the window.
1155    pub fn resizable(self, resizable: bool) -> Self {
1156        Self {
1157            builder: self.builder.property("resizable", resizable),
1158        }
1159    }
1160
1161    /// A write-only property for setting window's startup notification identifier.
1162    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
1163        Self {
1164            builder: self.builder.property("startup-id", startup_id.into()),
1165        }
1166    }
1167
1168    /// The title of the window.
1169    pub fn title(self, title: impl Into<glib::GString>) -> Self {
1170        Self {
1171            builder: self.builder.property("title", title.into()),
1172        }
1173    }
1174
1175    /// The titlebar widget.
1176    #[cfg(feature = "v4_6")]
1177    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1178    pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
1179        Self {
1180            builder: self.builder.property("titlebar", titlebar.clone().upcast()),
1181        }
1182    }
1183
1184    /// The transient parent of the window.
1185    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
1186        Self {
1187            builder: self
1188                .builder
1189                .property("transient-for", transient_for.clone().upcast()),
1190        }
1191    }
1192
1193    /// Whether the widget or any of its descendents can accept
1194    /// the input focus.
1195    ///
1196    /// This property is meant to be set by widget implementations,
1197    /// typically in their instance init function.
1198    pub fn can_focus(self, can_focus: bool) -> Self {
1199        Self {
1200            builder: self.builder.property("can-focus", can_focus),
1201        }
1202    }
1203
1204    /// Whether the widget can receive pointer events.
1205    pub fn can_target(self, can_target: bool) -> Self {
1206        Self {
1207            builder: self.builder.property("can-target", can_target),
1208        }
1209    }
1210
1211    /// A list of css classes applied to this widget.
1212    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1213        Self {
1214            builder: self.builder.property("css-classes", css_classes.into()),
1215        }
1216    }
1217
1218    /// The name of this widget in the CSS tree.
1219    ///
1220    /// This property is meant to be set by widget implementations,
1221    /// typically in their instance init function.
1222    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1223        Self {
1224            builder: self.builder.property("css-name", css_name.into()),
1225        }
1226    }
1227
1228    /// The cursor used by @widget.
1229    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1230        Self {
1231            builder: self.builder.property("cursor", cursor.clone()),
1232        }
1233    }
1234
1235    /// Whether the widget should grab focus when it is clicked with the mouse.
1236    ///
1237    /// This property is only relevant for widgets that can take focus.
1238    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1239        Self {
1240            builder: self.builder.property("focus-on-click", focus_on_click),
1241        }
1242    }
1243
1244    /// Whether this widget itself will accept the input focus.
1245    pub fn focusable(self, focusable: bool) -> Self {
1246        Self {
1247            builder: self.builder.property("focusable", focusable),
1248        }
1249    }
1250
1251    /// How to distribute horizontal space if widget gets extra space.
1252    pub fn halign(self, halign: Align) -> Self {
1253        Self {
1254            builder: self.builder.property("halign", halign),
1255        }
1256    }
1257
1258    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1259    /// signal on @widget.
1260    ///
1261    /// A true value indicates that @widget can have a tooltip, in this case
1262    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1263    /// determine whether it will provide a tooltip or not.
1264    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1265        Self {
1266            builder: self.builder.property("has-tooltip", has_tooltip),
1267        }
1268    }
1269
1270    /// Overrides for height request of the widget.
1271    ///
1272    /// If this is -1, the natural request will be used.
1273    pub fn height_request(self, height_request: i32) -> Self {
1274        Self {
1275            builder: self.builder.property("height-request", height_request),
1276        }
1277    }
1278
1279    /// Whether to expand horizontally.
1280    pub fn hexpand(self, hexpand: bool) -> Self {
1281        Self {
1282            builder: self.builder.property("hexpand", hexpand),
1283        }
1284    }
1285
1286    /// Whether to use the `hexpand` property.
1287    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1288        Self {
1289            builder: self.builder.property("hexpand-set", hexpand_set),
1290        }
1291    }
1292
1293    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1294    /// the preferred size of the widget, and allocate its children.
1295    ///
1296    /// This property is meant to be set by widget implementations,
1297    /// typically in their instance init function.
1298    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1299        Self {
1300            builder: self
1301                .builder
1302                .property("layout-manager", layout_manager.clone().upcast()),
1303        }
1304    }
1305
1306    /// Makes this widget act like a modal dialog, with respect to
1307    /// event delivery.
1308    ///
1309    /// Global event controllers will not handle events with targets
1310    /// inside the widget, unless they are set up to ignore propagation
1311    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1312    #[cfg(feature = "v4_18")]
1313    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1314    pub fn limit_events(self, limit_events: bool) -> Self {
1315        Self {
1316            builder: self.builder.property("limit-events", limit_events),
1317        }
1318    }
1319
1320    /// Margin on bottom side of widget.
1321    ///
1322    /// This property adds margin outside of the widget's normal size
1323    /// request, the margin will be added in addition to the size from
1324    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1325    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1326        Self {
1327            builder: self.builder.property("margin-bottom", margin_bottom),
1328        }
1329    }
1330
1331    /// Margin on end of widget, horizontally.
1332    ///
1333    /// This property supports left-to-right and right-to-left text
1334    /// directions.
1335    ///
1336    /// This property adds margin outside of the widget's normal size
1337    /// request, the margin will be added in addition to the size from
1338    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1339    pub fn margin_end(self, margin_end: i32) -> Self {
1340        Self {
1341            builder: self.builder.property("margin-end", margin_end),
1342        }
1343    }
1344
1345    /// Margin on start of widget, horizontally.
1346    ///
1347    /// This property supports left-to-right and right-to-left text
1348    /// directions.
1349    ///
1350    /// This property adds margin outside of the widget's normal size
1351    /// request, the margin will be added in addition to the size from
1352    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1353    pub fn margin_start(self, margin_start: i32) -> Self {
1354        Self {
1355            builder: self.builder.property("margin-start", margin_start),
1356        }
1357    }
1358
1359    /// Margin on top side of widget.
1360    ///
1361    /// This property adds margin outside of the widget's normal size
1362    /// request, the margin will be added in addition to the size from
1363    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1364    pub fn margin_top(self, margin_top: i32) -> Self {
1365        Self {
1366            builder: self.builder.property("margin-top", margin_top),
1367        }
1368    }
1369
1370    /// The name of the widget.
1371    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1372        Self {
1373            builder: self.builder.property("name", name.into()),
1374        }
1375    }
1376
1377    /// The requested opacity of the widget.
1378    pub fn opacity(self, opacity: f64) -> Self {
1379        Self {
1380            builder: self.builder.property("opacity", opacity),
1381        }
1382    }
1383
1384    /// How content outside the widget's content area is treated.
1385    ///
1386    /// This property is meant to be set by widget implementations,
1387    /// typically in their instance init function.
1388    pub fn overflow(self, overflow: Overflow) -> Self {
1389        Self {
1390            builder: self.builder.property("overflow", overflow),
1391        }
1392    }
1393
1394    /// Whether the widget will receive the default action when it is focused.
1395    pub fn receives_default(self, receives_default: bool) -> Self {
1396        Self {
1397            builder: self.builder.property("receives-default", receives_default),
1398        }
1399    }
1400
1401    /// Whether the widget responds to input.
1402    pub fn sensitive(self, sensitive: bool) -> Self {
1403        Self {
1404            builder: self.builder.property("sensitive", sensitive),
1405        }
1406    }
1407
1408    /// Sets the text of tooltip to be the given string, which is marked up
1409    /// with Pango markup.
1410    ///
1411    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1412    ///
1413    /// This is a convenience property which will take care of getting the
1414    /// tooltip shown if the given string is not `NULL`:
1415    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1416    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1417    /// the default signal handler.
1418    ///
1419    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1420    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1421    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1422        Self {
1423            builder: self
1424                .builder
1425                .property("tooltip-markup", tooltip_markup.into()),
1426        }
1427    }
1428
1429    /// Sets the text of tooltip to be the given string.
1430    ///
1431    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1432    ///
1433    /// This is a convenience property which will take care of getting the
1434    /// tooltip shown if the given string is not `NULL`:
1435    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1436    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1437    /// the default signal handler.
1438    ///
1439    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1440    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1441    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1442        Self {
1443            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1444        }
1445    }
1446
1447    /// How to distribute vertical space if widget gets extra space.
1448    pub fn valign(self, valign: Align) -> Self {
1449        Self {
1450            builder: self.builder.property("valign", valign),
1451        }
1452    }
1453
1454    /// Whether to expand vertically.
1455    pub fn vexpand(self, vexpand: bool) -> Self {
1456        Self {
1457            builder: self.builder.property("vexpand", vexpand),
1458        }
1459    }
1460
1461    /// Whether to use the `vexpand` property.
1462    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1463        Self {
1464            builder: self.builder.property("vexpand-set", vexpand_set),
1465        }
1466    }
1467
1468    /// Whether the widget is visible.
1469    pub fn visible(self, visible: bool) -> Self {
1470        Self {
1471            builder: self.builder.property("visible", visible),
1472        }
1473    }
1474
1475    /// Overrides for width request of the widget.
1476    ///
1477    /// If this is -1, the natural request will be used.
1478    pub fn width_request(self, width_request: i32) -> Self {
1479        Self {
1480            builder: self.builder.property("width-request", width_request),
1481        }
1482    }
1483
1484    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1485    ///
1486    /// The accessible role cannot be changed once set.
1487    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1488        Self {
1489            builder: self.builder.property("accessible-role", accessible_role),
1490        }
1491    }
1492
1493    // rustdoc-stripper-ignore-next
1494    /// Build the [`Dialog`].
1495    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1496    pub fn build(self) -> Dialog {
1497        assert_initialized_main_thread!();
1498        self.builder.build()
1499    }
1500}
1501
1502/// Trait containing all [`struct@Dialog`] methods.
1503///
1504/// # Implementors
1505///
1506/// [`AppChooserDialog`][struct@crate::AppChooserDialog], [`ColorChooserDialog`][struct@crate::ColorChooserDialog], [`Dialog`][struct@crate::Dialog], [`FileChooserDialog`][struct@crate::FileChooserDialog], [`FontChooserDialog`][struct@crate::FontChooserDialog], [`MessageDialog`][struct@crate::MessageDialog], [`PageSetupUnixDialog`][struct@crate::PageSetupUnixDialog], [`PrintUnixDialog`][struct@crate::PrintUnixDialog]
1507pub trait DialogExt: IsA<Dialog> + 'static {
1508    /// Adds an activatable widget to the action area of a [`Dialog`][crate::Dialog].
1509    ///
1510    /// GTK connects a signal handler that will emit the
1511    /// [`response`][struct@crate::Dialog#response] signal on the dialog when the widget
1512    /// is activated. The widget is appended to the end of the dialog’s action
1513    /// area.
1514    ///
1515    /// If you want to add a non-activatable widget, simply pack it into
1516    /// the @action_area field of the [`Dialog`][crate::Dialog] struct.
1517    ///
1518    /// # Deprecated since 4.10
1519    ///
1520    /// Use [`Window`][crate::Window] instead
1521    /// ## `child`
1522    /// an activatable widget
1523    /// ## `response_id`
1524    /// response ID for @child
1525    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1526    #[allow(deprecated)]
1527    #[doc(alias = "gtk_dialog_add_action_widget")]
1528    fn add_action_widget(&self, child: &impl IsA<Widget>, response_id: ResponseType) {
1529        unsafe {
1530            ffi::gtk_dialog_add_action_widget(
1531                self.as_ref().to_glib_none().0,
1532                child.as_ref().to_glib_none().0,
1533                response_id.into_glib(),
1534            );
1535        }
1536    }
1537
1538    /// Adds a button with the given text.
1539    ///
1540    /// GTK arranges things so that clicking the button will emit the
1541    /// [`response`][struct@crate::Dialog#response] signal with the given @response_id.
1542    /// The button is appended to the end of the dialog’s action area.
1543    /// The button widget is returned, but usually you don’t need it.
1544    ///
1545    /// # Deprecated since 4.10
1546    ///
1547    /// Use [`Window`][crate::Window] instead
1548    /// ## `button_text`
1549    /// text of button
1550    /// ## `response_id`
1551    /// response ID for the button
1552    ///
1553    /// # Returns
1554    ///
1555    /// the [`Button`][crate::Button] widget that was added
1556    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1557    #[allow(deprecated)]
1558    #[doc(alias = "gtk_dialog_add_button")]
1559    fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget {
1560        unsafe {
1561            from_glib_none(ffi::gtk_dialog_add_button(
1562                self.as_ref().to_glib_none().0,
1563                button_text.to_glib_none().0,
1564                response_id.into_glib(),
1565            ))
1566        }
1567    }
1568
1569    /// Returns the content area of @self.
1570    ///
1571    /// # Deprecated since 4.10
1572    ///
1573    /// Use [`Window`][crate::Window] instead
1574    ///
1575    /// # Returns
1576    ///
1577    /// the content area [`Box`][crate::Box].
1578    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1579    #[allow(deprecated)]
1580    #[doc(alias = "gtk_dialog_get_content_area")]
1581    #[doc(alias = "get_content_area")]
1582    fn content_area(&self) -> Box {
1583        unsafe {
1584            from_glib_none(ffi::gtk_dialog_get_content_area(
1585                self.as_ref().to_glib_none().0,
1586            ))
1587        }
1588    }
1589
1590    /// Returns the header bar of @self.
1591    ///
1592    /// Note that the headerbar is only used by the dialog if the
1593    /// [`use-header-bar`][struct@crate::Dialog#use-header-bar] property is [`true`].
1594    ///
1595    /// # Deprecated since 4.10
1596    ///
1597    /// Use [`Window`][crate::Window] instead
1598    ///
1599    /// # Returns
1600    ///
1601    /// the header bar
1602    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1603    #[allow(deprecated)]
1604    #[doc(alias = "gtk_dialog_get_header_bar")]
1605    #[doc(alias = "get_header_bar")]
1606    fn header_bar(&self) -> HeaderBar {
1607        unsafe {
1608            from_glib_none(ffi::gtk_dialog_get_header_bar(
1609                self.as_ref().to_glib_none().0,
1610            ))
1611        }
1612    }
1613
1614    /// Gets the widget button that uses the given response ID in the action area
1615    /// of a dialog.
1616    ///
1617    /// # Deprecated since 4.10
1618    ///
1619    /// Use [`Window`][crate::Window] instead
1620    /// ## `response_id`
1621    /// the response ID used by the @self widget
1622    ///
1623    /// # Returns
1624    ///
1625    /// the @widget button that uses the given
1626    ///   @response_id
1627    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1628    #[allow(deprecated)]
1629    #[doc(alias = "gtk_dialog_get_widget_for_response")]
1630    #[doc(alias = "get_widget_for_response")]
1631    fn widget_for_response(&self, response_id: ResponseType) -> Option<Widget> {
1632        unsafe {
1633            from_glib_none(ffi::gtk_dialog_get_widget_for_response(
1634                self.as_ref().to_glib_none().0,
1635                response_id.into_glib(),
1636            ))
1637        }
1638    }
1639
1640    /// Emits the ::response signal with the given response ID.
1641    ///
1642    /// Used to indicate that the user has responded to the dialog in some way.
1643    ///
1644    /// # Deprecated since 4.10
1645    ///
1646    /// Use [`Window`][crate::Window] instead
1647    /// ## `response_id`
1648    /// response ID
1649    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1650    #[allow(deprecated)]
1651    #[doc(alias = "gtk_dialog_response")]
1652    fn response(&self, response_id: ResponseType) {
1653        unsafe {
1654            ffi::gtk_dialog_response(self.as_ref().to_glib_none().0, response_id.into_glib());
1655        }
1656    }
1657
1658    /// Sets the default widget for the dialog based on the response ID.
1659    ///
1660    /// Pressing “Enter” normally activates the default widget.
1661    ///
1662    /// # Deprecated since 4.10
1663    ///
1664    /// Use [`Window`][crate::Window] instead
1665    /// ## `response_id`
1666    /// a response ID
1667    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1668    #[allow(deprecated)]
1669    #[doc(alias = "gtk_dialog_set_default_response")]
1670    fn set_default_response(&self, response_id: ResponseType) {
1671        unsafe {
1672            ffi::gtk_dialog_set_default_response(
1673                self.as_ref().to_glib_none().0,
1674                response_id.into_glib(),
1675            );
1676        }
1677    }
1678
1679    /// A convenient way to sensitize/desensitize dialog buttons.
1680    ///
1681    /// Calls `gtk_widget_set_sensitive (widget, @setting)`
1682    /// for each widget in the dialog’s action area with the given @response_id.
1683    ///
1684    /// # Deprecated since 4.10
1685    ///
1686    /// Use [`Window`][crate::Window] instead
1687    /// ## `response_id`
1688    /// a response ID
1689    /// ## `setting`
1690    /// [`true`] for sensitive
1691    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1692    #[allow(deprecated)]
1693    #[doc(alias = "gtk_dialog_set_response_sensitive")]
1694    fn set_response_sensitive(&self, response_id: ResponseType, setting: bool) {
1695        unsafe {
1696            ffi::gtk_dialog_set_response_sensitive(
1697                self.as_ref().to_glib_none().0,
1698                response_id.into_glib(),
1699                setting.into_glib(),
1700            );
1701        }
1702    }
1703
1704    /// [`true`] if the dialog uses a headerbar for action buttons
1705    /// instead of the action-area.
1706    ///
1707    /// For technical reasons, this property is declared as an integer
1708    /// property, but you should only set it to [`true`] or [`false`].
1709    ///
1710    /// ## Creating a dialog with headerbar
1711    ///
1712    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
1713    /// set this property according to platform conventions (using the
1714    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
1715    ///
1716    /// Here is how you can achieve the same:
1717    ///
1718    /// **⚠️ The following code is in c ⚠️**
1719    ///
1720    /// ```c
1721    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
1722    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
1723    /// ```
1724    ///
1725    /// # Deprecated since 4.10
1726    ///
1727    /// Use [`Window`][crate::Window] instead
1728    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1729    #[doc(alias = "use-header-bar")]
1730    fn use_header_bar(&self) -> i32 {
1731        ObjectExt::property(self.as_ref(), "use-header-bar")
1732    }
1733
1734    /// Emitted when the user uses a keybinding to close the dialog.
1735    ///
1736    /// This is a [keybinding signal](class.SignalAction.html).
1737    ///
1738    /// The default binding for this signal is the Escape key.
1739    ///
1740    /// # Deprecated since 4.10
1741    ///
1742    /// Use [`Window`][crate::Window] instead
1743    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1744    #[doc(alias = "close")]
1745    fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1746        unsafe extern "C" fn close_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1747            this: *mut ffi::GtkDialog,
1748            f: glib::ffi::gpointer,
1749        ) {
1750            let f: &F = &*(f as *const F);
1751            f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1752        }
1753        unsafe {
1754            let f: Box_<F> = Box_::new(f);
1755            connect_raw(
1756                self.as_ptr() as *mut _,
1757                c"close".as_ptr() as *const _,
1758                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1759                    close_trampoline::<Self, F> as *const (),
1760                )),
1761                Box_::into_raw(f),
1762            )
1763        }
1764    }
1765
1766    fn emit_close(&self) {
1767        self.emit_by_name::<()>("close", &[]);
1768    }
1769
1770    /// Emitted when an action widget is clicked.
1771    ///
1772    /// The signal is also emitted when the dialog receives a
1773    /// delete event, and when [`response()`][Self::response()] is called.
1774    /// On a delete event, the response ID is [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent].
1775    /// Otherwise, it depends on which action widget was clicked.
1776    ///
1777    /// # Deprecated since 4.10
1778    ///
1779    /// Use [`Window`][crate::Window] instead
1780    /// ## `response_id`
1781    /// the response ID
1782    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1783    #[doc(alias = "response")]
1784    fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
1785        unsafe extern "C" fn response_trampoline<
1786            P: IsA<Dialog>,
1787            F: Fn(&P, ResponseType) + 'static,
1788        >(
1789            this: *mut ffi::GtkDialog,
1790            response_id: ffi::GtkResponseType,
1791            f: glib::ffi::gpointer,
1792        ) {
1793            let f: &F = &*(f as *const F);
1794            f(
1795                Dialog::from_glib_borrow(this).unsafe_cast_ref(),
1796                from_glib(response_id),
1797            )
1798        }
1799        unsafe {
1800            let f: Box_<F> = Box_::new(f);
1801            connect_raw(
1802                self.as_ptr() as *mut _,
1803                c"response".as_ptr() as *const _,
1804                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1805                    response_trampoline::<Self, F> as *const (),
1806                )),
1807                Box_::into_raw(f),
1808            )
1809        }
1810    }
1811}
1812
1813impl<O: IsA<Dialog>> DialogExt for O {}