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