Skip to main content

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