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    /// #### `force-close`
740    ///  Emitted when the compositor has decided to eliminate a window.
741    ///
742    /// @window *has* to be in a hidden state after this signal was handled.
743    ///
744    ///
745    ///
746    ///
747    /// #### `keys-changed`
748    ///  Emitted when the set of accelerators or mnemonics that
749    /// are associated with the window changes.
750    ///
751    ///
752    /// </details>
753    /// <details><summary><h4>Widget</h4></summary>
754    ///
755    ///
756    /// #### `destroy`
757    ///  Signals that all holders of a reference to the widget should release
758    /// the reference that they hold.
759    ///
760    /// May result in finalization of the widget if all references are released.
761    ///
762    /// This signal is not suitable for saving widget state.
763    ///
764    ///
765    ///
766    ///
767    /// #### `direction-changed`
768    ///  Emitted when the text direction of a widget changes.
769    ///
770    ///
771    ///
772    ///
773    /// #### `hide`
774    ///  Emitted when @widget is hidden.
775    ///
776    ///
777    ///
778    ///
779    /// #### `keynav-failed`
780    ///  Emitted if keyboard navigation fails.
781    ///
782    /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
783    ///
784    ///
785    ///
786    ///
787    /// #### `map`
788    ///  Emitted when @widget is going to be mapped.
789    ///
790    /// A widget is mapped when the widget is visible (which is controlled with
791    /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
792    /// are also visible.
793    ///
794    /// The `::map` signal can be used to determine whether a widget will be drawn,
795    /// for instance it can resume an animation that was stopped during the
796    /// emission of [`unmap`][struct@crate::Widget#unmap].
797    ///
798    ///
799    ///
800    ///
801    /// #### `mnemonic-activate`
802    ///  Emitted when a widget is activated via a mnemonic.
803    ///
804    /// The default handler for this signal activates @widget if @group_cycling
805    /// is false, or just makes @widget grab focus if @group_cycling is true.
806    ///
807    ///
808    ///
809    ///
810    /// #### `move-focus`
811    ///  Emitted when the focus is moved.
812    ///
813    /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
814    ///
815    /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
816    /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
817    ///
818    /// Action
819    ///
820    ///
821    /// #### `query-tooltip`
822    ///  Emitted when the widget’s tooltip is about to be shown.
823    ///
824    /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
825    /// is true and the hover timeout has expired with the cursor hovering
826    /// above @widget; or emitted when @widget got focus in keyboard mode.
827    ///
828    /// Using the given coordinates, the signal handler should determine
829    /// whether a tooltip should be shown for @widget. If this is the case
830    /// true should be returned, false otherwise. Note that if @keyboard_mode
831    /// is true, the values of @x and @y are undefined and should not be used.
832    ///
833    /// The signal handler is free to manipulate @tooltip with the therefore
834    /// destined function calls.
835    ///
836    ///
837    ///
838    ///
839    /// #### `realize`
840    ///  Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
841    ///
842    /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
843    /// or the widget has been mapped (that is, it is going to be drawn).
844    ///
845    ///
846    ///
847    ///
848    /// #### `show`
849    ///  Emitted when @widget is shown.
850    ///
851    ///
852    ///
853    ///
854    /// #### `state-flags-changed`
855    ///  Emitted when the widget state changes.
856    ///
857    /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
858    ///
859    ///
860    ///
861    ///
862    /// #### `unmap`
863    ///  Emitted when @widget is going to be unmapped.
864    ///
865    /// A widget is unmapped when either it or any of its parents up to the
866    /// toplevel widget have been set as hidden.
867    ///
868    /// As `::unmap` indicates that a widget will not be shown any longer,
869    /// it can be used to, for example, stop an animation on the widget.
870    ///
871    ///
872    ///
873    ///
874    /// #### `unrealize`
875    ///  Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
876    ///
877    /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
878    /// or the widget has been unmapped (that is, it is going to be hidden).
879    ///
880    ///
881    /// </details>
882    ///
883    /// # Implements
884    ///
885    /// [`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]
886    #[doc(alias = "GtkDialog")]
887    pub struct Dialog(Object<ffi::GtkDialog, ffi::GtkDialogClass>) @extends Window, Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager;
888
889    match fn {
890        type_ => || ffi::gtk_dialog_get_type(),
891    }
892}
893
894impl Dialog {
895    pub const NONE: Option<&'static Dialog> = None;
896
897    /// Creates a new dialog box.
898    ///
899    /// Widgets should not be packed into the [`Window`][crate::Window]
900    /// directly, but into the @content_area and @action_area,
901    /// as described above.
902    ///
903    /// # Deprecated since 4.10
904    ///
905    /// Use [`Window`][crate::Window] instead
906    ///
907    /// # Returns
908    ///
909    /// the new dialog as a [`Widget`][crate::Widget]
910    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
911    #[allow(deprecated)]
912    #[doc(alias = "gtk_dialog_new")]
913    pub fn new() -> Dialog {
914        assert_initialized_main_thread!();
915        unsafe { Widget::from_glib_none(ffi::gtk_dialog_new()).unsafe_cast() }
916    }
917
918    // rustdoc-stripper-ignore-next
919    /// Creates a new builder-pattern struct instance to construct [`Dialog`] objects.
920    ///
921    /// This method returns an instance of [`DialogBuilder`](crate::builders::DialogBuilder) which can be used to create [`Dialog`] objects.
922    pub fn builder() -> DialogBuilder {
923        DialogBuilder::new()
924    }
925}
926
927impl Default for Dialog {
928    fn default() -> Self {
929        Self::new()
930    }
931}
932
933// rustdoc-stripper-ignore-next
934/// A [builder-pattern] type to construct [`Dialog`] objects.
935///
936/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
937#[must_use = "The builder must be built to be used"]
938pub struct DialogBuilder {
939    builder: glib::object::ObjectBuilder<'static, Dialog>,
940}
941
942impl DialogBuilder {
943    fn new() -> Self {
944        Self {
945            builder: glib::object::Object::builder(),
946        }
947    }
948
949    /// [`true`] if the dialog uses a headerbar for action buttons
950    /// instead of the action-area.
951    ///
952    /// For technical reasons, this property is declared as an integer
953    /// property, but you should only set it to [`true`] or [`false`].
954    ///
955    /// ## Creating a dialog with headerbar
956    ///
957    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
958    /// set this property according to platform conventions (using the
959    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
960    ///
961    /// Here is how you can achieve the same:
962    ///
963    /// **⚠️ The following code is in c ⚠️**
964    ///
965    /// ```c
966    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
967    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
968    /// ```
969    /// Use [`Window`][crate::Window] instead
970    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
971    pub fn use_header_bar(self, use_header_bar: i32) -> Self {
972        Self {
973            builder: self.builder.property("use-header-bar", use_header_bar),
974        }
975    }
976
977    /// The [`Application`][crate::Application] associated with the window.
978    ///
979    /// The application will be kept alive for at least as long as it
980    /// has any windows associated with it (see g_application_hold()
981    /// for a way to keep it alive without windows).
982    ///
983    /// Normally, the connection between the application and the window
984    /// will remain until the window is destroyed, but you can explicitly
985    /// remove it by setting the this property to `NULL`.
986    pub fn application(self, application: &impl IsA<Application>) -> Self {
987        Self {
988            builder: self
989                .builder
990                .property("application", application.clone().upcast()),
991        }
992    }
993
994    /// The child widget.
995    pub fn child(self, child: &impl IsA<Widget>) -> Self {
996        Self {
997            builder: self.builder.property("child", child.clone().upcast()),
998        }
999    }
1000
1001    /// Whether the window should have a frame (also known as *decorations*).
1002    pub fn decorated(self, decorated: bool) -> Self {
1003        Self {
1004            builder: self.builder.property("decorated", decorated),
1005        }
1006    }
1007
1008    /// The default height of the window.
1009    pub fn default_height(self, default_height: i32) -> Self {
1010        Self {
1011            builder: self.builder.property("default-height", default_height),
1012        }
1013    }
1014
1015    /// The default widget.
1016    pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
1017        Self {
1018            builder: self
1019                .builder
1020                .property("default-widget", default_widget.clone().upcast()),
1021        }
1022    }
1023
1024    /// The default width of the window.
1025    pub fn default_width(self, default_width: i32) -> Self {
1026        Self {
1027            builder: self.builder.property("default-width", default_width),
1028        }
1029    }
1030
1031    /// Whether the window frame should have a close button.
1032    pub fn deletable(self, deletable: bool) -> Self {
1033        Self {
1034            builder: self.builder.property("deletable", deletable),
1035        }
1036    }
1037
1038    /// If this window should be destroyed when the parent is destroyed.
1039    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
1040        Self {
1041            builder: self
1042                .builder
1043                .property("destroy-with-parent", destroy_with_parent),
1044        }
1045    }
1046
1047    /// The display that will display this window.
1048    pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
1049        Self {
1050            builder: self.builder.property("display", display.clone().upcast()),
1051        }
1052    }
1053
1054    /// Whether 'focus rectangles' are currently visible in this window.
1055    ///
1056    /// This property is maintained by GTK based on user input
1057    /// and should not be set by applications.
1058    pub fn focus_visible(self, focus_visible: bool) -> Self {
1059        Self {
1060            builder: self.builder.property("focus-visible", focus_visible),
1061        }
1062    }
1063
1064    /// The focus widget.
1065    pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
1066        Self {
1067            builder: self
1068                .builder
1069                .property("focus-widget", focus_widget.clone().upcast()),
1070        }
1071    }
1072
1073    /// Whether the window is fullscreen.
1074    ///
1075    /// Setting this property is the equivalent of calling
1076    /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
1077    /// either operation is asynchronous, which means you will need to
1078    /// connect to the ::notify signal in order to know whether the
1079    /// operation was successful.
1080    pub fn fullscreened(self, fullscreened: bool) -> Self {
1081        Self {
1082            builder: self.builder.property("fullscreened", fullscreened),
1083        }
1084    }
1085
1086    /// The gravity to use when resizing the window programmatically.
1087    ///
1088    /// Gravity describes which point of the window we want to keep
1089    /// fixed (meaning that the window will grow in the opposite direction).
1090    /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
1091    /// want the to fix top right corner of the window.
1092    #[cfg(feature = "v4_20")]
1093    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1094    pub fn gravity(self, gravity: WindowGravity) -> Self {
1095        Self {
1096            builder: self.builder.property("gravity", gravity),
1097        }
1098    }
1099
1100    /// Whether the window frame should handle <kbd>F10</kbd> for activating
1101    /// menubars.
1102    #[cfg(feature = "v4_2")]
1103    #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
1104    pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
1105        Self {
1106            builder: self
1107                .builder
1108                .property("handle-menubar-accel", handle_menubar_accel),
1109        }
1110    }
1111
1112    /// If this window should be hidden instead of destroyed when the user clicks
1113    /// the close button.
1114    pub fn hide_on_close(self, hide_on_close: bool) -> Self {
1115        Self {
1116            builder: self.builder.property("hide-on-close", hide_on_close),
1117        }
1118    }
1119
1120    /// Specifies the name of the themed icon to use as the window icon.
1121    ///
1122    /// See [`IconTheme`][crate::IconTheme] for more details.
1123    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1124        Self {
1125            builder: self.builder.property("icon-name", icon_name.into()),
1126        }
1127    }
1128
1129    /// Whether the window is maximized.
1130    ///
1131    /// Setting this property is the equivalent of calling
1132    /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
1133    /// either operation is asynchronous, which means you will need to
1134    /// connect to the ::notify signal in order to know whether the
1135    /// operation was successful.
1136    pub fn maximized(self, maximized: bool) -> Self {
1137        Self {
1138            builder: self.builder.property("maximized", maximized),
1139        }
1140    }
1141
1142    /// Whether mnemonics are currently visible in this window.
1143    ///
1144    /// This property is maintained by GTK based on user input,
1145    /// and should not be set by applications.
1146    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
1147        Self {
1148            builder: self
1149                .builder
1150                .property("mnemonics-visible", mnemonics_visible),
1151        }
1152    }
1153
1154    /// If true, the window is modal.
1155    pub fn modal(self, modal: bool) -> Self {
1156        Self {
1157            builder: self.builder.property("modal", modal),
1158        }
1159    }
1160
1161    /// If true, users can resize the window.
1162    pub fn resizable(self, resizable: bool) -> Self {
1163        Self {
1164            builder: self.builder.property("resizable", resizable),
1165        }
1166    }
1167
1168    /// A write-only property for setting window's startup notification identifier.
1169    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
1170        Self {
1171            builder: self.builder.property("startup-id", startup_id.into()),
1172        }
1173    }
1174
1175    /// The title of the window.
1176    pub fn title(self, title: impl Into<glib::GString>) -> Self {
1177        Self {
1178            builder: self.builder.property("title", title.into()),
1179        }
1180    }
1181
1182    /// The titlebar widget.
1183    #[cfg(feature = "v4_6")]
1184    #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1185    pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
1186        Self {
1187            builder: self.builder.property("titlebar", titlebar.clone().upcast()),
1188        }
1189    }
1190
1191    /// The transient parent of the window.
1192    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
1193        Self {
1194            builder: self
1195                .builder
1196                .property("transient-for", transient_for.clone().upcast()),
1197        }
1198    }
1199
1200    /// Whether the widget or any of its descendents can accept
1201    /// the input focus.
1202    ///
1203    /// This property is meant to be set by widget implementations,
1204    /// typically in their instance init function.
1205    pub fn can_focus(self, can_focus: bool) -> Self {
1206        Self {
1207            builder: self.builder.property("can-focus", can_focus),
1208        }
1209    }
1210
1211    /// Whether the widget can receive pointer events.
1212    pub fn can_target(self, can_target: bool) -> Self {
1213        Self {
1214            builder: self.builder.property("can-target", can_target),
1215        }
1216    }
1217
1218    /// A list of css classes applied to this widget.
1219    pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1220        Self {
1221            builder: self.builder.property("css-classes", css_classes.into()),
1222        }
1223    }
1224
1225    /// The name of this widget in the CSS tree.
1226    ///
1227    /// This property is meant to be set by widget implementations,
1228    /// typically in their instance init function.
1229    pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1230        Self {
1231            builder: self.builder.property("css-name", css_name.into()),
1232        }
1233    }
1234
1235    /// The cursor used by @widget.
1236    pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1237        Self {
1238            builder: self.builder.property("cursor", cursor.clone()),
1239        }
1240    }
1241
1242    /// Whether the widget should grab focus when it is clicked with the mouse.
1243    ///
1244    /// This property is only relevant for widgets that can take focus.
1245    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1246        Self {
1247            builder: self.builder.property("focus-on-click", focus_on_click),
1248        }
1249    }
1250
1251    /// Whether this widget itself will accept the input focus.
1252    pub fn focusable(self, focusable: bool) -> Self {
1253        Self {
1254            builder: self.builder.property("focusable", focusable),
1255        }
1256    }
1257
1258    /// How to distribute horizontal space if widget gets extra space.
1259    pub fn halign(self, halign: Align) -> Self {
1260        Self {
1261            builder: self.builder.property("halign", halign),
1262        }
1263    }
1264
1265    /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1266    /// signal on @widget.
1267    ///
1268    /// A true value indicates that @widget can have a tooltip, in this case
1269    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1270    /// determine whether it will provide a tooltip or not.
1271    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1272        Self {
1273            builder: self.builder.property("has-tooltip", has_tooltip),
1274        }
1275    }
1276
1277    /// Overrides for height request of the widget.
1278    ///
1279    /// If this is -1, the natural request will be used.
1280    pub fn height_request(self, height_request: i32) -> Self {
1281        Self {
1282            builder: self.builder.property("height-request", height_request),
1283        }
1284    }
1285
1286    /// Whether to expand horizontally.
1287    pub fn hexpand(self, hexpand: bool) -> Self {
1288        Self {
1289            builder: self.builder.property("hexpand", hexpand),
1290        }
1291    }
1292
1293    /// Whether to use the `hexpand` property.
1294    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1295        Self {
1296            builder: self.builder.property("hexpand-set", hexpand_set),
1297        }
1298    }
1299
1300    /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1301    /// the preferred size of the widget, and allocate its children.
1302    ///
1303    /// This property is meant to be set by widget implementations,
1304    /// typically in their instance init function.
1305    pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1306        Self {
1307            builder: self
1308                .builder
1309                .property("layout-manager", layout_manager.clone().upcast()),
1310        }
1311    }
1312
1313    /// Makes this widget act like a modal dialog, with respect to
1314    /// event delivery.
1315    ///
1316    /// Global event controllers will not handle events with targets
1317    /// inside the widget, unless they are set up to ignore propagation
1318    /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1319    #[cfg(feature = "v4_18")]
1320    #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1321    pub fn limit_events(self, limit_events: bool) -> Self {
1322        Self {
1323            builder: self.builder.property("limit-events", limit_events),
1324        }
1325    }
1326
1327    /// Margin on bottom side of widget.
1328    ///
1329    /// This property adds margin outside of the widget's normal size
1330    /// request, the margin will be added in addition to the size from
1331    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1332    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1333        Self {
1334            builder: self.builder.property("margin-bottom", margin_bottom),
1335        }
1336    }
1337
1338    /// Margin on end of widget, horizontally.
1339    ///
1340    /// This property supports left-to-right and right-to-left text
1341    /// directions.
1342    ///
1343    /// This property adds margin outside of the widget's normal size
1344    /// request, the margin will be added in addition to the size from
1345    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1346    pub fn margin_end(self, margin_end: i32) -> Self {
1347        Self {
1348            builder: self.builder.property("margin-end", margin_end),
1349        }
1350    }
1351
1352    /// Margin on start of widget, horizontally.
1353    ///
1354    /// This property supports left-to-right and right-to-left text
1355    /// directions.
1356    ///
1357    /// This property adds margin outside of the widget's normal size
1358    /// request, the margin will be added in addition to the size from
1359    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1360    pub fn margin_start(self, margin_start: i32) -> Self {
1361        Self {
1362            builder: self.builder.property("margin-start", margin_start),
1363        }
1364    }
1365
1366    /// Margin on top side of widget.
1367    ///
1368    /// This property adds margin outside of the widget's normal size
1369    /// request, the margin will be added in addition to the size from
1370    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1371    pub fn margin_top(self, margin_top: i32) -> Self {
1372        Self {
1373            builder: self.builder.property("margin-top", margin_top),
1374        }
1375    }
1376
1377    /// The name of the widget.
1378    pub fn name(self, name: impl Into<glib::GString>) -> Self {
1379        Self {
1380            builder: self.builder.property("name", name.into()),
1381        }
1382    }
1383
1384    /// The requested opacity of the widget.
1385    pub fn opacity(self, opacity: f64) -> Self {
1386        Self {
1387            builder: self.builder.property("opacity", opacity),
1388        }
1389    }
1390
1391    /// How content outside the widget's content area is treated.
1392    ///
1393    /// This property is meant to be set by widget implementations,
1394    /// typically in their instance init function.
1395    pub fn overflow(self, overflow: Overflow) -> Self {
1396        Self {
1397            builder: self.builder.property("overflow", overflow),
1398        }
1399    }
1400
1401    /// Whether the widget will receive the default action when it is focused.
1402    pub fn receives_default(self, receives_default: bool) -> Self {
1403        Self {
1404            builder: self.builder.property("receives-default", receives_default),
1405        }
1406    }
1407
1408    /// Whether the widget responds to input.
1409    pub fn sensitive(self, sensitive: bool) -> Self {
1410        Self {
1411            builder: self.builder.property("sensitive", sensitive),
1412        }
1413    }
1414
1415    /// Sets the text of tooltip to be the given string, which is marked up
1416    /// with Pango markup.
1417    ///
1418    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1419    ///
1420    /// This is a convenience property which will take care of getting the
1421    /// tooltip shown if the given string is not `NULL`:
1422    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1423    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1424    /// the default signal handler.
1425    ///
1426    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1427    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1428    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1429        Self {
1430            builder: self
1431                .builder
1432                .property("tooltip-markup", tooltip_markup.into()),
1433        }
1434    }
1435
1436    /// Sets the text of tooltip to be the given string.
1437    ///
1438    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1439    ///
1440    /// This is a convenience property which will take care of getting the
1441    /// tooltip shown if the given string is not `NULL`:
1442    /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1443    /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1444    /// the default signal handler.
1445    ///
1446    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1447    /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1448    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1449        Self {
1450            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1451        }
1452    }
1453
1454    /// How to distribute vertical space if widget gets extra space.
1455    pub fn valign(self, valign: Align) -> Self {
1456        Self {
1457            builder: self.builder.property("valign", valign),
1458        }
1459    }
1460
1461    /// Whether to expand vertically.
1462    pub fn vexpand(self, vexpand: bool) -> Self {
1463        Self {
1464            builder: self.builder.property("vexpand", vexpand),
1465        }
1466    }
1467
1468    /// Whether to use the `vexpand` property.
1469    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1470        Self {
1471            builder: self.builder.property("vexpand-set", vexpand_set),
1472        }
1473    }
1474
1475    /// Whether the widget is visible.
1476    pub fn visible(self, visible: bool) -> Self {
1477        Self {
1478            builder: self.builder.property("visible", visible),
1479        }
1480    }
1481
1482    /// Overrides for width request of the widget.
1483    ///
1484    /// If this is -1, the natural request will be used.
1485    pub fn width_request(self, width_request: i32) -> Self {
1486        Self {
1487            builder: self.builder.property("width-request", width_request),
1488        }
1489    }
1490
1491    /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1492    ///
1493    /// The accessible role cannot be changed once set.
1494    pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1495        Self {
1496            builder: self.builder.property("accessible-role", accessible_role),
1497        }
1498    }
1499
1500    // rustdoc-stripper-ignore-next
1501    /// Build the [`Dialog`].
1502    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1503    pub fn build(self) -> Dialog {
1504        assert_initialized_main_thread!();
1505        self.builder.build()
1506    }
1507}
1508
1509/// Trait containing all [`struct@Dialog`] methods.
1510///
1511/// # Implementors
1512///
1513/// [`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]
1514pub trait DialogExt: IsA<Dialog> + 'static {
1515    /// Adds an activatable widget to the action area of a [`Dialog`][crate::Dialog].
1516    ///
1517    /// GTK connects a signal handler that will emit the
1518    /// [`response`][struct@crate::Dialog#response] signal on the dialog when the widget
1519    /// is activated. The widget is appended to the end of the dialog’s action
1520    /// area.
1521    ///
1522    /// If you want to add a non-activatable widget, simply pack it into
1523    /// the @action_area field of the [`Dialog`][crate::Dialog] struct.
1524    ///
1525    /// # Deprecated since 4.10
1526    ///
1527    /// Use [`Window`][crate::Window] instead
1528    /// ## `child`
1529    /// an activatable widget
1530    /// ## `response_id`
1531    /// response ID for @child
1532    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1533    #[allow(deprecated)]
1534    #[doc(alias = "gtk_dialog_add_action_widget")]
1535    fn add_action_widget(&self, child: &impl IsA<Widget>, response_id: ResponseType) {
1536        unsafe {
1537            ffi::gtk_dialog_add_action_widget(
1538                self.as_ref().to_glib_none().0,
1539                child.as_ref().to_glib_none().0,
1540                response_id.into_glib(),
1541            );
1542        }
1543    }
1544
1545    /// Adds a button with the given text.
1546    ///
1547    /// GTK arranges things so that clicking the button will emit the
1548    /// [`response`][struct@crate::Dialog#response] signal with the given @response_id.
1549    /// The button is appended to the end of the dialog’s action area.
1550    /// The button widget is returned, but usually you don’t need it.
1551    ///
1552    /// # Deprecated since 4.10
1553    ///
1554    /// Use [`Window`][crate::Window] instead
1555    /// ## `button_text`
1556    /// text of button
1557    /// ## `response_id`
1558    /// response ID for the button
1559    ///
1560    /// # Returns
1561    ///
1562    /// the [`Button`][crate::Button] widget that was added
1563    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1564    #[allow(deprecated)]
1565    #[doc(alias = "gtk_dialog_add_button")]
1566    fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget {
1567        unsafe {
1568            from_glib_none(ffi::gtk_dialog_add_button(
1569                self.as_ref().to_glib_none().0,
1570                button_text.to_glib_none().0,
1571                response_id.into_glib(),
1572            ))
1573        }
1574    }
1575
1576    /// Returns the content area of @self.
1577    ///
1578    /// # Deprecated since 4.10
1579    ///
1580    /// Use [`Window`][crate::Window] instead
1581    ///
1582    /// # Returns
1583    ///
1584    /// the content area [`Box`][crate::Box].
1585    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1586    #[allow(deprecated)]
1587    #[doc(alias = "gtk_dialog_get_content_area")]
1588    #[doc(alias = "get_content_area")]
1589    fn content_area(&self) -> Box {
1590        unsafe {
1591            from_glib_none(ffi::gtk_dialog_get_content_area(
1592                self.as_ref().to_glib_none().0,
1593            ))
1594        }
1595    }
1596
1597    /// Returns the header bar of @self.
1598    ///
1599    /// Note that the headerbar is only used by the dialog if the
1600    /// [`use-header-bar`][struct@crate::Dialog#use-header-bar] property is [`true`].
1601    ///
1602    /// # Deprecated since 4.10
1603    ///
1604    /// Use [`Window`][crate::Window] instead
1605    ///
1606    /// # Returns
1607    ///
1608    /// the header bar
1609    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1610    #[allow(deprecated)]
1611    #[doc(alias = "gtk_dialog_get_header_bar")]
1612    #[doc(alias = "get_header_bar")]
1613    fn header_bar(&self) -> HeaderBar {
1614        unsafe {
1615            from_glib_none(ffi::gtk_dialog_get_header_bar(
1616                self.as_ref().to_glib_none().0,
1617            ))
1618        }
1619    }
1620
1621    /// Gets the widget button that uses the given response ID in the action area
1622    /// of a dialog.
1623    ///
1624    /// # Deprecated since 4.10
1625    ///
1626    /// Use [`Window`][crate::Window] instead
1627    /// ## `response_id`
1628    /// the response ID used by the @self widget
1629    ///
1630    /// # Returns
1631    ///
1632    /// the @widget button that uses the given
1633    ///   @response_id
1634    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1635    #[allow(deprecated)]
1636    #[doc(alias = "gtk_dialog_get_widget_for_response")]
1637    #[doc(alias = "get_widget_for_response")]
1638    fn widget_for_response(&self, response_id: ResponseType) -> Option<Widget> {
1639        unsafe {
1640            from_glib_none(ffi::gtk_dialog_get_widget_for_response(
1641                self.as_ref().to_glib_none().0,
1642                response_id.into_glib(),
1643            ))
1644        }
1645    }
1646
1647    /// Emits the ::response signal with the given response ID.
1648    ///
1649    /// Used to indicate that the user has responded to the dialog in some way.
1650    ///
1651    /// # Deprecated since 4.10
1652    ///
1653    /// Use [`Window`][crate::Window] instead
1654    /// ## `response_id`
1655    /// response ID
1656    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1657    #[allow(deprecated)]
1658    #[doc(alias = "gtk_dialog_response")]
1659    fn response(&self, response_id: ResponseType) {
1660        unsafe {
1661            ffi::gtk_dialog_response(self.as_ref().to_glib_none().0, response_id.into_glib());
1662        }
1663    }
1664
1665    /// Sets the default widget for the dialog based on the response ID.
1666    ///
1667    /// Pressing “Enter” normally activates the default widget.
1668    ///
1669    /// # Deprecated since 4.10
1670    ///
1671    /// Use [`Window`][crate::Window] instead
1672    /// ## `response_id`
1673    /// a response ID
1674    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1675    #[allow(deprecated)]
1676    #[doc(alias = "gtk_dialog_set_default_response")]
1677    fn set_default_response(&self, response_id: ResponseType) {
1678        unsafe {
1679            ffi::gtk_dialog_set_default_response(
1680                self.as_ref().to_glib_none().0,
1681                response_id.into_glib(),
1682            );
1683        }
1684    }
1685
1686    /// A convenient way to sensitize/desensitize dialog buttons.
1687    ///
1688    /// Calls `gtk_widget_set_sensitive (widget, @setting)`
1689    /// for each widget in the dialog’s action area with the given @response_id.
1690    ///
1691    /// # Deprecated since 4.10
1692    ///
1693    /// Use [`Window`][crate::Window] instead
1694    /// ## `response_id`
1695    /// a response ID
1696    /// ## `setting`
1697    /// [`true`] for sensitive
1698    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1699    #[allow(deprecated)]
1700    #[doc(alias = "gtk_dialog_set_response_sensitive")]
1701    fn set_response_sensitive(&self, response_id: ResponseType, setting: bool) {
1702        unsafe {
1703            ffi::gtk_dialog_set_response_sensitive(
1704                self.as_ref().to_glib_none().0,
1705                response_id.into_glib(),
1706                setting.into_glib(),
1707            );
1708        }
1709    }
1710
1711    /// [`true`] if the dialog uses a headerbar for action buttons
1712    /// instead of the action-area.
1713    ///
1714    /// For technical reasons, this property is declared as an integer
1715    /// property, but you should only set it to [`true`] or [`false`].
1716    ///
1717    /// ## Creating a dialog with headerbar
1718    ///
1719    /// Builtin [`Dialog`][crate::Dialog] subclasses such as [`ColorChooserDialog`][crate::ColorChooserDialog]
1720    /// set this property according to platform conventions (using the
1721    /// [`gtk-dialogs-use-header`][struct@crate::Settings#gtk-dialogs-use-header] setting).
1722    ///
1723    /// Here is how you can achieve the same:
1724    ///
1725    /// **⚠️ The following code is in c ⚠️**
1726    ///
1727    /// ```c
1728    /// g_object_get (settings, "gtk-dialogs-use-header", &header, NULL);
1729    /// dialog = g_object_new (GTK_TYPE_DIALOG, header, TRUE, NULL);
1730    /// ```
1731    ///
1732    /// # Deprecated since 4.10
1733    ///
1734    /// Use [`Window`][crate::Window] instead
1735    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1736    #[doc(alias = "use-header-bar")]
1737    fn use_header_bar(&self) -> i32 {
1738        ObjectExt::property(self.as_ref(), "use-header-bar")
1739    }
1740
1741    /// Emitted when the user uses a keybinding to close the dialog.
1742    ///
1743    /// This is a [keybinding signal](class.SignalAction.html).
1744    ///
1745    /// The default binding for this signal is the Escape key.
1746    ///
1747    /// # Deprecated since 4.10
1748    ///
1749    /// Use [`Window`][crate::Window] instead
1750    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1751    #[doc(alias = "close")]
1752    fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1753        unsafe extern "C" fn close_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
1754            this: *mut ffi::GtkDialog,
1755            f: glib::ffi::gpointer,
1756        ) {
1757            unsafe {
1758                let f: &F = &*(f as *const F);
1759                f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
1760            }
1761        }
1762        unsafe {
1763            let f: Box_<F> = Box_::new(f);
1764            connect_raw(
1765                self.as_ptr() as *mut _,
1766                c"close".as_ptr(),
1767                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1768                    close_trampoline::<Self, F> as *const (),
1769                )),
1770                Box_::into_raw(f),
1771            )
1772        }
1773    }
1774
1775    fn emit_close(&self) {
1776        self.emit_by_name::<()>("close", &[]);
1777    }
1778
1779    /// Emitted when an action widget is clicked.
1780    ///
1781    /// The signal is also emitted when the dialog receives a
1782    /// delete event, and when [`response()`][Self::response()] is called.
1783    /// On a delete event, the response ID is [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent].
1784    /// Otherwise, it depends on which action widget was clicked.
1785    ///
1786    /// # Deprecated since 4.10
1787    ///
1788    /// Use [`Window`][crate::Window] instead
1789    /// ## `response_id`
1790    /// the response ID
1791    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1792    #[doc(alias = "response")]
1793    fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
1794        unsafe extern "C" fn response_trampoline<
1795            P: IsA<Dialog>,
1796            F: Fn(&P, ResponseType) + 'static,
1797        >(
1798            this: *mut ffi::GtkDialog,
1799            response_id: ffi::GtkResponseType,
1800            f: glib::ffi::gpointer,
1801        ) {
1802            unsafe {
1803                let f: &F = &*(f as *const F);
1804                f(
1805                    Dialog::from_glib_borrow(this).unsafe_cast_ref(),
1806                    from_glib(response_id),
1807                )
1808            }
1809        }
1810        unsafe {
1811            let f: Box_<F> = Box_::new(f);
1812            connect_raw(
1813                self.as_ptr() as *mut _,
1814                c"response".as_ptr(),
1815                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1816                    response_trampoline::<Self, F> as *const (),
1817                )),
1818                Box_::into_raw(f),
1819            )
1820        }
1821    }
1822}
1823
1824impl<O: IsA<Dialog>> DialogExt for O {}