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