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