gtk/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
5use crate::{
6 Align, Application, Bin, Box, Buildable, Container, HeaderBar, ResizeMode, ResponseType,
7 Widget, Window, WindowPosition, WindowType, ffi,
8};
9use glib::{
10 object::ObjectType as _,
11 prelude::*,
12 signal::{SignalHandlerId, connect_raw},
13 translate::*,
14};
15use std::boxed::Box as Box_;
16
17glib::wrapper! {
18 /// Dialog boxes are a convenient way to prompt the user for a small amount
19 /// of input, e.g. to display a message, ask a question, or anything else
20 /// that does not require extensive effort on the user’s part.
21 ///
22 /// GTK+ treats a dialog as a window split vertically. The top section is a
23 /// `GtkVBox`, and is where widgets such as a [`Label`][crate::Label] or a [`Entry`][crate::Entry] should
24 /// be packed. The bottom area is known as the
25 /// “action area”. This is generally used for
26 /// packing buttons into the dialog which may perform functions such as
27 /// cancel, ok, or apply.
28 ///
29 /// [`Dialog`][crate::Dialog] boxes are created with a call to [`new()`][Self::new()] or
30 /// `gtk_dialog_new_with_buttons()`. `gtk_dialog_new_with_buttons()` is
31 /// recommended; it allows you to set the dialog title, some convenient
32 /// flags, and add simple buttons.
33 ///
34 /// If “dialog” is a newly created dialog, the two primary areas of the
35 /// window can be accessed through [`DialogExt::content_area()`][crate::prelude::DialogExt::content_area()] and
36 /// `gtk_dialog_get_action_area()`, as can be seen from the example below.
37 ///
38 /// A “modal” dialog (that is, one which freezes the rest of the application
39 /// from user input), can be created by calling [`GtkWindowExt::set_modal()`][crate::prelude::GtkWindowExt::set_modal()] on the
40 /// dialog. Use the GTK_WINDOW() macro to cast the widget returned from
41 /// [`new()`][Self::new()] into a [`Window`][crate::Window]. When using `gtk_dialog_new_with_buttons()`
42 /// you can also pass the [`DialogFlags::MODAL`][crate::DialogFlags::MODAL] flag to make a dialog modal.
43 ///
44 /// If you add buttons to [`Dialog`][crate::Dialog] using `gtk_dialog_new_with_buttons()`,
45 /// [`DialogExt::add_button()`][crate::prelude::DialogExt::add_button()], [`DialogExtManual::add_buttons()`][crate::prelude::DialogExtManual::add_buttons()], or
46 /// [`DialogExt::add_action_widget()`][crate::prelude::DialogExt::add_action_widget()], clicking the button will emit a signal
47 /// called [`response`][struct@crate::Dialog#response] with a response ID that you specified. GTK+
48 /// will never assign a meaning to positive response IDs; these are entirely
49 /// user-defined. But for convenience, you can use the response IDs in the
50 /// [`ResponseType`][crate::ResponseType] enumeration (these all have values less than zero). If
51 /// a dialog receives a delete event, the [`response`][struct@crate::Dialog#response] signal will
52 /// be emitted with a response ID of [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent].
53 ///
54 /// If you want to block waiting for a dialog to return before returning
55 /// control flow to your code, you can call [`DialogExt::run()`][crate::prelude::DialogExt::run()]. This function
56 /// enters a recursive main loop and waits for the user to respond to the
57 /// dialog, returning the response ID corresponding to the button the user
58 /// clicked.
59 ///
60 /// For the simple dialog in the following example, in reality you’d probably
61 /// use [`MessageDialog`][crate::MessageDialog] to save yourself some effort. But you’d need to
62 /// create the dialog contents manually if you had more than a simple message
63 /// in the dialog.
64 ///
65 /// An example for simple GtkDialog usage:
66 ///
67 ///
68 /// **⚠️ The following code is in C ⚠️**
69 ///
70 /// ```C
71 /// // Function to open a dialog box with a message
72 /// void
73 /// quick_message (GtkWindow *parent, gchar *message)
74 /// {
75 /// GtkWidget *dialog, *label, *content_area;
76 /// GtkDialogFlags flags;
77 ///
78 /// // Create the widgets
79 /// flags = GTK_DIALOG_DESTROY_WITH_PARENT;
80 /// dialog = gtk_dialog_new_with_buttons ("Message",
81 /// parent,
82 /// flags,
83 /// _("_OK"),
84 /// GTK_RESPONSE_NONE,
85 /// NULL);
86 /// content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
87 /// label = gtk_label_new (message);
88 ///
89 /// // Ensure that the dialog box is destroyed when the user responds
90 ///
91 /// g_signal_connect_swapped (dialog,
92 /// "response",
93 /// G_CALLBACK (gtk_widget_destroy),
94 /// dialog);
95 ///
96 /// // Add the label, and show everything we’ve added
97 ///
98 /// gtk_container_add (GTK_CONTAINER (content_area), label);
99 /// gtk_widget_show_all (dialog);
100 /// }
101 /// ```
102 ///
103 /// # GtkDialog as GtkBuildable
104 ///
105 /// The GtkDialog implementation of the [`Buildable`][crate::Buildable] interface exposes the
106 /// `vbox` and `action_area` as internal children with the names “vbox” and
107 /// “action_area”.
108 ///
109 /// GtkDialog supports a custom ``<action-widgets>`` element, which can contain
110 /// multiple ``<action-widget>`` elements. The “response” attribute specifies a
111 /// numeric response, and the content of the element is the id of widget
112 /// (which should be a child of the dialogs `action_area`). To mark a response
113 /// as default, set the “default“ attribute of the ``<action-widget>`` element
114 /// to true.
115 ///
116 /// GtkDialog supports adding action widgets by specifying “action“ as
117 /// the “type“ attribute of a ``<child>`` element. The widget will be added
118 /// either to the action area or the headerbar of the dialog, depending
119 /// on the “use-header-bar“ property. The response id has to be associated
120 /// with the action widget using the ``<action-widgets>`` element.
121 ///
122 /// An example of a [`Dialog`][crate::Dialog] UI definition fragment:
123 ///
124 ///
125 ///
126 /// **⚠️ The following code is in xml ⚠️**
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 /// <property name="can-default">True</property>
136 /// </object>
137 /// </child>
138 /// <action-widgets>
139 /// <action-widget response="cancel">button_cancel</action-widget>
140 /// <action-widget response="ok" default="true">button_ok</action-widget>
141 /// </action-widgets>
142 /// </object>
143 /// ```
144 ///
145 /// ## Properties
146 ///
147 ///
148 /// #### `use-header-bar`
149 /// [`true`] if the dialog uses a [`HeaderBar`][crate::HeaderBar] for action buttons
150 /// instead of the action-area.
151 ///
152 /// For technical reasons, this property is declared as an integer
153 /// property, but you should only set it to [`true`] or [`false`].
154 ///
155 /// Readable | Writable | Construct Only
156 /// <details><summary><h4>Window</h4></summary>
157 ///
158 ///
159 /// #### `accept-focus`
160 /// Whether the window should receive the input focus.
161 ///
162 /// Readable | Writable
163 ///
164 ///
165 /// #### `application`
166 /// The [`Application`][crate::Application] associated with the window.
167 ///
168 /// The application will be kept alive for at least as long as it
169 /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
170 /// for a way to keep it alive without windows).
171 ///
172 /// Normally, the connection between the application and the window
173 /// will remain until the window is destroyed, but you can explicitly
174 /// remove it by setting the :application property to [`None`].
175 ///
176 /// Readable | Writable
177 ///
178 ///
179 /// #### `attached-to`
180 /// The widget to which this window is attached.
181 /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
182 ///
183 /// Examples of places where specifying this relation is useful are
184 /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
185 /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
186 /// created by [`TreeView`][crate::TreeView].
187 ///
188 /// Readable | Writable | Construct
189 ///
190 ///
191 /// #### `decorated`
192 /// Whether the window should be decorated by the window manager.
193 ///
194 /// Readable | Writable
195 ///
196 ///
197 /// #### `default-height`
198 /// Readable | Writable
199 ///
200 ///
201 /// #### `default-width`
202 /// Readable | Writable
203 ///
204 ///
205 /// #### `deletable`
206 /// Whether the window frame should have a close button.
207 ///
208 /// Readable | Writable
209 ///
210 ///
211 /// #### `destroy-with-parent`
212 /// Readable | Writable
213 ///
214 ///
215 /// #### `focus-on-map`
216 /// Whether the window should receive the input focus when mapped.
217 ///
218 /// Readable | Writable
219 ///
220 ///
221 /// #### `focus-visible`
222 /// Whether 'focus rectangles' are currently visible in this window.
223 ///
224 /// This property is maintained by GTK+ based on user input
225 /// and should not be set by applications.
226 ///
227 /// Readable | Writable
228 ///
229 ///
230 /// #### `gravity`
231 /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
232 /// more details about window gravity.
233 ///
234 /// Readable | Writable
235 ///
236 ///
237 /// #### `has-resize-grip`
238 /// Whether the window has a corner resize grip.
239 ///
240 /// Note that the resize grip is only shown if the window is
241 /// actually resizable and not maximized. Use
242 /// [`resize-grip-visible`][struct@crate::Window#resize-grip-visible] to find out if the resize
243 /// grip is currently shown.
244 ///
245 /// Readable | Writable
246 ///
247 ///
248 /// #### `has-toplevel-focus`
249 /// Readable
250 ///
251 ///
252 /// #### `hide-titlebar-when-maximized`
253 /// Whether the titlebar should be hidden during maximization.
254 ///
255 /// Readable | Writable
256 ///
257 ///
258 /// #### `icon`
259 /// Readable | Writable
260 ///
261 ///
262 /// #### `icon-name`
263 /// The :icon-name property specifies the name of the themed icon to
264 /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
265 ///
266 /// Readable | Writable
267 ///
268 ///
269 /// #### `is-active`
270 /// Readable
271 ///
272 ///
273 /// #### `is-maximized`
274 /// Readable
275 ///
276 ///
277 /// #### `mnemonics-visible`
278 /// Whether mnemonics are currently visible in this window.
279 ///
280 /// This property is maintained by GTK+ based on user input,
281 /// and should not be set by applications.
282 ///
283 /// Readable | Writable
284 ///
285 ///
286 /// #### `modal`
287 /// Readable | Writable
288 ///
289 ///
290 /// #### `resizable`
291 /// Readable | Writable
292 ///
293 ///
294 /// #### `resize-grip-visible`
295 /// Whether a corner resize grip is currently shown.
296 ///
297 /// Readable
298 ///
299 ///
300 /// #### `role`
301 /// Readable | Writable
302 ///
303 ///
304 /// #### `screen`
305 /// Readable | Writable
306 ///
307 ///
308 /// #### `skip-pager-hint`
309 /// Readable | Writable
310 ///
311 ///
312 /// #### `skip-taskbar-hint`
313 /// Readable | Writable
314 ///
315 ///
316 /// #### `startup-id`
317 /// The :startup-id is a write-only property for setting window's
318 /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
319 /// for more details.
320 ///
321 /// Writable
322 ///
323 ///
324 /// #### `title`
325 /// Readable | Writable
326 ///
327 ///
328 /// #### `transient-for`
329 /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
330 /// more details about transient windows.
331 ///
332 /// Readable | Writable | Construct
333 ///
334 ///
335 /// #### `type`
336 /// Readable | Writable | Construct Only
337 ///
338 ///
339 /// #### `type-hint`
340 /// Readable | Writable
341 ///
342 ///
343 /// #### `urgency-hint`
344 /// Readable | Writable
345 ///
346 ///
347 /// #### `window-position`
348 /// Readable | Writable
349 /// </details>
350 /// <details><summary><h4>Container</h4></summary>
351 ///
352 ///
353 /// #### `border-width`
354 /// Readable | Writable
355 ///
356 ///
357 /// #### `child`
358 /// Writable
359 ///
360 ///
361 /// #### `resize-mode`
362 /// Readable | Writable
363 /// </details>
364 /// <details><summary><h4>Widget</h4></summary>
365 ///
366 ///
367 /// #### `app-paintable`
368 /// Readable | Writable
369 ///
370 ///
371 /// #### `can-default`
372 /// Readable | Writable
373 ///
374 ///
375 /// #### `can-focus`
376 /// Readable | Writable
377 ///
378 ///
379 /// #### `composite-child`
380 /// Readable
381 ///
382 ///
383 /// #### `double-buffered`
384 /// Whether the widget is double buffered.
385 ///
386 /// Readable | Writable
387 ///
388 ///
389 /// #### `events`
390 /// Readable | Writable
391 ///
392 ///
393 /// #### `expand`
394 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
395 ///
396 /// Readable | Writable
397 ///
398 ///
399 /// #### `focus-on-click`
400 /// Whether the widget should grab focus when it is clicked with the mouse.
401 ///
402 /// This property is only relevant for widgets that can take focus.
403 ///
404 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
405 /// GtkComboBox) implemented this property individually.
406 ///
407 /// Readable | Writable
408 ///
409 ///
410 /// #### `halign`
411 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
412 ///
413 /// Readable | Writable
414 ///
415 ///
416 /// #### `has-default`
417 /// Readable | Writable
418 ///
419 ///
420 /// #### `has-focus`
421 /// Readable | Writable
422 ///
423 ///
424 /// #### `has-tooltip`
425 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
426 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
427 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
428 /// whether it will provide a tooltip or not.
429 ///
430 /// Note that setting this property to [`true`] for the first time will change
431 /// the event masks of the GdkWindows of this widget to include leave-notify
432 /// and motion-notify events. This cannot and will not be undone when the
433 /// property is set to [`false`] again.
434 ///
435 /// Readable | Writable
436 ///
437 ///
438 /// #### `height-request`
439 /// Readable | Writable
440 ///
441 ///
442 /// #### `hexpand`
443 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
444 ///
445 /// Readable | Writable
446 ///
447 ///
448 /// #### `hexpand-set`
449 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
450 ///
451 /// Readable | Writable
452 ///
453 ///
454 /// #### `is-focus`
455 /// Readable | Writable
456 ///
457 ///
458 /// #### `margin`
459 /// Sets all four sides' margin at once. If read, returns max
460 /// margin on any side.
461 ///
462 /// Readable | Writable
463 ///
464 ///
465 /// #### `margin-bottom`
466 /// Margin on bottom side of widget.
467 ///
468 /// This property adds margin outside of the widget's normal size
469 /// request, the margin will be added in addition to the size from
470 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
471 ///
472 /// Readable | Writable
473 ///
474 ///
475 /// #### `margin-end`
476 /// Margin on end of widget, horizontally. This property supports
477 /// left-to-right and right-to-left text directions.
478 ///
479 /// This property adds margin outside of the widget's normal size
480 /// request, the margin will be added in addition to the size from
481 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
482 ///
483 /// Readable | Writable
484 ///
485 ///
486 /// #### `margin-left`
487 /// Margin on left side of widget.
488 ///
489 /// This property adds margin outside of the widget's normal size
490 /// request, the margin will be added in addition to the size from
491 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
492 ///
493 /// Readable | Writable
494 ///
495 ///
496 /// #### `margin-right`
497 /// Margin on right side of widget.
498 ///
499 /// This property adds margin outside of the widget's normal size
500 /// request, the margin will be added in addition to the size from
501 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
502 ///
503 /// Readable | Writable
504 ///
505 ///
506 /// #### `margin-start`
507 /// Margin on start of widget, horizontally. This property supports
508 /// left-to-right and right-to-left text directions.
509 ///
510 /// This property adds margin outside of the widget's normal size
511 /// request, the margin will be added in addition to the size from
512 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
513 ///
514 /// Readable | Writable
515 ///
516 ///
517 /// #### `margin-top`
518 /// Margin on top side of widget.
519 ///
520 /// This property adds margin outside of the widget's normal size
521 /// request, the margin will be added in addition to the size from
522 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
523 ///
524 /// Readable | Writable
525 ///
526 ///
527 /// #### `name`
528 /// Readable | Writable
529 ///
530 ///
531 /// #### `no-show-all`
532 /// Readable | Writable
533 ///
534 ///
535 /// #### `opacity`
536 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
537 /// more details about window opacity.
538 ///
539 /// Before 3.8 this was only available in GtkWindow
540 ///
541 /// Readable | Writable
542 ///
543 ///
544 /// #### `parent`
545 /// Readable | Writable
546 ///
547 ///
548 /// #### `receives-default`
549 /// Readable | Writable
550 ///
551 ///
552 /// #### `scale-factor`
553 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
554 /// more details about widget scaling.
555 ///
556 /// Readable
557 ///
558 ///
559 /// #### `sensitive`
560 /// Readable | Writable
561 ///
562 ///
563 /// #### `style`
564 /// The style of the widget, which contains information about how it will look (colors, etc).
565 ///
566 /// Readable | Writable
567 ///
568 ///
569 /// #### `tooltip-markup`
570 /// Sets the text of tooltip to be the given string, which is marked up
571 /// with the [Pango text markup language][PangoMarkupFormat].
572 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
573 ///
574 /// This is a convenience property which will take care of getting the
575 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
576 /// will automatically be set to [`true`] and there will be taken care of
577 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
578 ///
579 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
580 /// are set, the last one wins.
581 ///
582 /// Readable | Writable
583 ///
584 ///
585 /// #### `tooltip-text`
586 /// Sets the text of tooltip to be the given string.
587 ///
588 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
589 ///
590 /// This is a convenience property which will take care of getting the
591 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
592 /// will automatically be set to [`true`] and there will be taken care of
593 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
594 ///
595 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
596 /// are set, the last one wins.
597 ///
598 /// Readable | Writable
599 ///
600 ///
601 /// #### `valign`
602 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
603 ///
604 /// Readable | Writable
605 ///
606 ///
607 /// #### `vexpand`
608 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
609 ///
610 /// Readable | Writable
611 ///
612 ///
613 /// #### `vexpand-set`
614 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
615 ///
616 /// Readable | Writable
617 ///
618 ///
619 /// #### `visible`
620 /// Readable | Writable
621 ///
622 ///
623 /// #### `width-request`
624 /// Readable | Writable
625 ///
626 ///
627 /// #### `window`
628 /// The widget's window if it is realized, [`None`] otherwise.
629 ///
630 /// Readable
631 /// </details>
632 ///
633 /// ## Signals
634 ///
635 ///
636 /// #### `close`
637 /// The ::close signal is a
638 /// [keybinding signal][GtkBindingSignal]
639 /// which gets emitted when the user uses a keybinding to close
640 /// the dialog.
641 ///
642 /// The default binding for this signal is the Escape key.
643 ///
644 /// Action
645 ///
646 ///
647 /// #### `response`
648 /// Emitted when an action widget is clicked, the dialog receives a
649 /// delete event, or the application programmer calls [`DialogExt::response()`][crate::prelude::DialogExt::response()].
650 /// On a delete event, the response ID is [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent].
651 /// Otherwise, it depends on which action widget was clicked.
652 ///
653 ///
654 /// <details><summary><h4>Window</h4></summary>
655 ///
656 ///
657 /// #### `activate-default`
658 /// The ::activate-default signal is a
659 /// [keybinding signal][GtkBindingSignal]
660 /// which gets emitted when the user activates the default widget
661 /// of `window`.
662 ///
663 /// Action
664 ///
665 ///
666 /// #### `activate-focus`
667 /// The ::activate-focus signal is a
668 /// [keybinding signal][GtkBindingSignal]
669 /// which gets emitted when the user activates the currently
670 /// focused widget of `window`.
671 ///
672 /// Action
673 ///
674 ///
675 /// #### `enable-debugging`
676 /// The ::enable-debugging signal is a [keybinding signal][GtkBindingSignal]
677 /// which gets emitted when the user enables or disables interactive
678 /// debugging. When `toggle` is [`true`], interactive debugging is toggled
679 /// on or off, when it is [`false`], the debugger will be pointed at the
680 /// widget under the pointer.
681 ///
682 /// The default bindings for this signal are Ctrl-Shift-I
683 /// and Ctrl-Shift-D.
684 ///
685 /// Action
686 ///
687 ///
688 /// #### `keys-changed`
689 /// The ::keys-changed signal gets emitted when the set of accelerators
690 /// or mnemonics that are associated with `window` changes.
691 ///
692 ///
693 ///
694 ///
695 /// #### `set-focus`
696 /// This signal is emitted whenever the currently focused widget in
697 /// this window changes.
698 ///
699 ///
700 /// </details>
701 /// <details><summary><h4>Container</h4></summary>
702 ///
703 ///
704 /// #### `add`
705 ///
706 ///
707 ///
708 /// #### `check-resize`
709 ///
710 ///
711 ///
712 /// #### `remove`
713 ///
714 ///
715 ///
716 /// #### `set-focus-child`
717 ///
718 /// </details>
719 /// <details><summary><h4>Widget</h4></summary>
720 ///
721 ///
722 /// #### `accel-closures-changed`
723 ///
724 ///
725 ///
726 /// #### `button-press-event`
727 /// The ::button-press-event signal will be emitted when a button
728 /// (typically from a mouse) is pressed.
729 ///
730 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
731 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
732 ///
733 /// This signal will be sent to the grab widget if there is one.
734 ///
735 ///
736 ///
737 ///
738 /// #### `button-release-event`
739 /// The ::button-release-event signal will be emitted when a button
740 /// (typically from a mouse) is released.
741 ///
742 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
743 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
744 ///
745 /// This signal will be sent to the grab widget if there is one.
746 ///
747 ///
748 ///
749 ///
750 /// #### `can-activate-accel`
751 /// Determines whether an accelerator that activates the signal
752 /// identified by `signal_id` can currently be activated.
753 /// This signal is present to allow applications and derived
754 /// widgets to override the default [`Widget`][crate::Widget] handling
755 /// for determining whether an accelerator can be activated.
756 ///
757 ///
758 ///
759 ///
760 /// #### `child-notify`
761 /// The ::child-notify signal is emitted for each
762 /// [child property][child-properties] that has
763 /// changed on an object. The signal's detail holds the property name.
764 ///
765 /// Detailed
766 ///
767 ///
768 /// #### `composited-changed`
769 /// The ::composited-changed signal is emitted when the composited
770 /// status of `widgets` screen changes.
771 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
772 ///
773 /// Action
774 ///
775 ///
776 /// #### `configure-event`
777 /// The ::configure-event signal will be emitted when the size, position or
778 /// stacking of the `widget`'s window has changed.
779 ///
780 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
781 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
782 /// automatically for all new windows.
783 ///
784 ///
785 ///
786 ///
787 /// #### `damage-event`
788 /// Emitted when a redirected window belonging to `widget` gets drawn into.
789 /// The region/area members of the event shows what area of the redirected
790 /// drawable was drawn into.
791 ///
792 ///
793 ///
794 ///
795 /// #### `delete-event`
796 /// The ::delete-event signal is emitted if a user requests that
797 /// a toplevel window is closed. The default handler for this signal
798 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
799 /// this signal will cause the window to be hidden instead, so that
800 /// it can later be shown again without reconstructing it.
801 ///
802 ///
803 ///
804 ///
805 /// #### `destroy`
806 /// Signals that all holders of a reference to the widget should release
807 /// the reference that they hold. May result in finalization of the widget
808 /// if all references are released.
809 ///
810 /// This signal is not suitable for saving widget state.
811 ///
812 ///
813 ///
814 ///
815 /// #### `destroy-event`
816 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
817 /// You rarely get this signal, because most widgets disconnect themselves
818 /// from their window before they destroy it, so no widget owns the
819 /// window at destroy time.
820 ///
821 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
822 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
823 /// automatically for all new windows.
824 ///
825 ///
826 ///
827 ///
828 /// #### `direction-changed`
829 /// The ::direction-changed signal is emitted when the text direction
830 /// of a widget changes.
831 ///
832 ///
833 ///
834 ///
835 /// #### `drag-begin`
836 /// The ::drag-begin signal is emitted on the drag source when a drag is
837 /// started. A typical reason to connect to this signal is to set up a
838 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
839 ///
840 /// Note that some widgets set up a drag icon in the default handler of
841 /// this signal, so you may have to use `g_signal_connect_after()` to
842 /// override what the default handler did.
843 ///
844 ///
845 ///
846 ///
847 /// #### `drag-data-delete`
848 /// The ::drag-data-delete signal is emitted on the drag source when a drag
849 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
850 /// handler is responsible for deleting the data that has been dropped. What
851 /// "delete" means depends on the context of the drag operation.
852 ///
853 ///
854 ///
855 ///
856 /// #### `drag-data-get`
857 /// The ::drag-data-get signal is emitted on the drag source when the drop
858 /// site requests the data which is dragged. It is the responsibility of
859 /// the signal handler to fill `data` with the data in the format which
860 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
861 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
862 ///
863 ///
864 ///
865 ///
866 /// #### `drag-data-received`
867 /// The ::drag-data-received signal is emitted on the drop site when the
868 /// dragged data has been received. If the data was received in order to
869 /// determine whether the drop will be accepted, the handler is expected
870 /// to call `gdk_drag_status()` and not finish the drag.
871 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
872 /// (and this is the last target to be received), the handler for this
873 /// signal is expected to process the received data and then call
874 /// `gtk_drag_finish()`, setting the `success` parameter depending on
875 /// whether the data was processed successfully.
876 ///
877 /// Applications must create some means to determine why the signal was emitted
878 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
879 ///
880 /// The handler may inspect the selected action with
881 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
882 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
883 /// shown in the following example:
884 ///
885 ///
886 /// **⚠️ The following code is in C ⚠️**
887 ///
888 /// ```C
889 /// void
890 /// drag_data_received (GtkWidget *widget,
891 /// GdkDragContext *context,
892 /// gint x,
893 /// gint y,
894 /// GtkSelectionData *data,
895 /// guint info,
896 /// guint time)
897 /// {
898 /// if ((data->length >= 0) && (data->format == 8))
899 /// {
900 /// GdkDragAction action;
901 ///
902 /// // handle data here
903 ///
904 /// action = gdk_drag_context_get_selected_action (context);
905 /// if (action == GDK_ACTION_ASK)
906 /// {
907 /// GtkWidget *dialog;
908 /// gint response;
909 ///
910 /// dialog = gtk_message_dialog_new (NULL,
911 /// GTK_DIALOG_MODAL |
912 /// GTK_DIALOG_DESTROY_WITH_PARENT,
913 /// GTK_MESSAGE_INFO,
914 /// GTK_BUTTONS_YES_NO,
915 /// "Move the data ?\n");
916 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
917 /// gtk_widget_destroy (dialog);
918 ///
919 /// if (response == GTK_RESPONSE_YES)
920 /// action = GDK_ACTION_MOVE;
921 /// else
922 /// action = GDK_ACTION_COPY;
923 /// }
924 ///
925 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
926 /// }
927 /// else
928 /// gtk_drag_finish (context, FALSE, FALSE, time);
929 /// }
930 /// ```
931 ///
932 ///
933 ///
934 ///
935 /// #### `drag-drop`
936 /// The ::drag-drop signal is emitted on the drop site when the user drops
937 /// the data onto the widget. The signal handler must determine whether
938 /// the cursor position is in a drop zone or not. If it is not in a drop
939 /// zone, it returns [`false`] and no further processing is necessary.
940 /// Otherwise, the handler returns [`true`]. In this case, the handler must
941 /// ensure that `gtk_drag_finish()` is called to let the source know that
942 /// the drop is done. The call to `gtk_drag_finish()` can be done either
943 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
944 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
945 /// or more of the supported targets.
946 ///
947 ///
948 ///
949 ///
950 /// #### `drag-end`
951 /// The ::drag-end signal is emitted on the drag source when a drag is
952 /// finished. A typical reason to connect to this signal is to undo
953 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
954 ///
955 ///
956 ///
957 ///
958 /// #### `drag-failed`
959 /// The ::drag-failed signal is emitted on the drag source when a drag has
960 /// failed. The signal handler may hook custom code to handle a failed DnD
961 /// operation based on the type of error, it returns [`true`] is the failure has
962 /// been already handled (not showing the default "drag operation failed"
963 /// animation), otherwise it returns [`false`].
964 ///
965 ///
966 ///
967 ///
968 /// #### `drag-leave`
969 /// The ::drag-leave signal is emitted on the drop site when the cursor
970 /// leaves the widget. A typical reason to connect to this signal is to
971 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
972 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
973 ///
974 ///
975 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
976 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
977 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
978 ///
979 ///
980 ///
981 ///
982 /// #### `drag-motion`
983 /// The ::drag-motion signal is emitted on the drop site when the user
984 /// moves the cursor over the widget during a drag. The signal handler
985 /// must determine whether the cursor position is in a drop zone or not.
986 /// If it is not in a drop zone, it returns [`false`] and no further processing
987 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
988 /// handler is responsible for providing the necessary information for
989 /// displaying feedback to the user, by calling `gdk_drag_status()`.
990 ///
991 /// If the decision whether the drop will be accepted or rejected can't be
992 /// made based solely on the cursor position and the type of the data, the
993 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
994 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
995 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
996 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
997 /// when using the drag-motion signal that way.
998 ///
999 /// Also note that there is no drag-enter signal. The drag receiver has to
1000 /// keep track of whether he has received any drag-motion signals since the
1001 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
1002 /// an "enter" signal. Upon an "enter", the handler will typically highlight
1003 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
1004 ///
1005 ///
1006 /// **⚠️ The following code is in C ⚠️**
1007 ///
1008 /// ```C
1009 /// static void
1010 /// drag_motion (GtkWidget *widget,
1011 /// GdkDragContext *context,
1012 /// gint x,
1013 /// gint y,
1014 /// guint time)
1015 /// {
1016 /// GdkAtom target;
1017 ///
1018 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
1019 ///
1020 /// if (!private_data->drag_highlight)
1021 /// {
1022 /// private_data->drag_highlight = 1;
1023 /// gtk_drag_highlight (widget);
1024 /// }
1025 ///
1026 /// target = gtk_drag_dest_find_target (widget, context, NULL);
1027 /// if (target == GDK_NONE)
1028 /// gdk_drag_status (context, 0, time);
1029 /// else
1030 /// {
1031 /// private_data->pending_status
1032 /// = gdk_drag_context_get_suggested_action (context);
1033 /// gtk_drag_get_data (widget, context, target, time);
1034 /// }
1035 ///
1036 /// return TRUE;
1037 /// }
1038 ///
1039 /// static void
1040 /// drag_data_received (GtkWidget *widget,
1041 /// GdkDragContext *context,
1042 /// gint x,
1043 /// gint y,
1044 /// GtkSelectionData *selection_data,
1045 /// guint info,
1046 /// guint time)
1047 /// {
1048 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
1049 ///
1050 /// if (private_data->suggested_action)
1051 /// {
1052 /// private_data->suggested_action = 0;
1053 ///
1054 /// // We are getting this data due to a request in drag_motion,
1055 /// // rather than due to a request in drag_drop, so we are just
1056 /// // supposed to call gdk_drag_status(), not actually paste in
1057 /// // the data.
1058 ///
1059 /// str = gtk_selection_data_get_text (selection_data);
1060 /// if (!data_is_acceptable (str))
1061 /// gdk_drag_status (context, 0, time);
1062 /// else
1063 /// gdk_drag_status (context,
1064 /// private_data->suggested_action,
1065 /// time);
1066 /// }
1067 /// else
1068 /// {
1069 /// // accept the drop
1070 /// }
1071 /// }
1072 /// ```
1073 ///
1074 ///
1075 ///
1076 ///
1077 /// #### `draw`
1078 /// This signal is emitted when a widget is supposed to render itself.
1079 /// The `widget`'s top left corner must be painted at the origin of
1080 /// the passed in context and be sized to the values returned by
1081 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
1082 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
1083 ///
1084 /// Signal handlers connected to this signal can modify the cairo
1085 /// context passed as `cr` in any way they like and don't need to
1086 /// restore it. The signal emission takes care of calling `cairo_save()`
1087 /// before and `cairo_restore()` after invoking the handler.
1088 ///
1089 /// The signal handler will get a `cr` with a clip region already set to the
1090 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
1091 /// widgets that want to avoid redrawing themselves completely can get the full
1092 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
1093 /// get a finer-grained representation of the dirty region with
1094 /// `cairo_copy_clip_rectangle_list()`.
1095 ///
1096 ///
1097 ///
1098 ///
1099 /// #### `enter-notify-event`
1100 /// The ::enter-notify-event will be emitted when the pointer enters
1101 /// the `widget`'s window.
1102 ///
1103 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1104 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
1105 ///
1106 /// This signal will be sent to the grab widget if there is one.
1107 ///
1108 ///
1109 ///
1110 ///
1111 /// #### `event`
1112 /// The GTK+ main loop will emit three signals for each GDK event delivered
1113 /// to a widget: one generic ::event signal, another, more specific,
1114 /// signal that matches the type of event delivered (e.g.
1115 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
1116 /// [`event-after`][struct@crate::Widget#event-after] signal.
1117 ///
1118 ///
1119 ///
1120 ///
1121 /// #### `event-after`
1122 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
1123 /// the second more specific signal, ::event-after will be emitted
1124 /// regardless of the previous two signals handlers return values.
1125 ///
1126 ///
1127 ///
1128 ///
1129 /// #### `focus`
1130 ///
1131 ///
1132 ///
1133 /// #### `focus-in-event`
1134 /// The ::focus-in-event signal will be emitted when the keyboard focus
1135 /// enters the `widget`'s window.
1136 ///
1137 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1138 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1139 ///
1140 ///
1141 ///
1142 ///
1143 /// #### `focus-out-event`
1144 /// The ::focus-out-event signal will be emitted when the keyboard focus
1145 /// leaves the `widget`'s window.
1146 ///
1147 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1148 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1149 ///
1150 ///
1151 ///
1152 ///
1153 /// #### `grab-broken-event`
1154 /// Emitted when a pointer or keyboard grab on a window belonging
1155 /// to `widget` gets broken.
1156 ///
1157 /// On X11, this happens when the grab window becomes unviewable
1158 /// (i.e. it or one of its ancestors is unmapped), or if the same
1159 /// application grabs the pointer or keyboard again.
1160 ///
1161 ///
1162 ///
1163 ///
1164 /// #### `grab-focus`
1165 /// Action
1166 ///
1167 ///
1168 /// #### `grab-notify`
1169 /// The ::grab-notify signal is emitted when a widget becomes
1170 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1171 /// another widget, or when it becomes unshadowed due to a grab
1172 /// being removed.
1173 ///
1174 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
1175 /// grab widget in the grab stack of its window group is not
1176 /// its ancestor.
1177 ///
1178 ///
1179 ///
1180 ///
1181 /// #### `hide`
1182 /// The ::hide signal is emitted when `widget` is hidden, for example with
1183 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
1184 ///
1185 ///
1186 ///
1187 ///
1188 /// #### `hierarchy-changed`
1189 /// The ::hierarchy-changed signal is emitted when the
1190 /// anchored state of a widget changes. A widget is
1191 /// “anchored” when its toplevel
1192 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
1193 /// a widget changes from un-anchored to anchored or vice-versa.
1194 ///
1195 ///
1196 ///
1197 ///
1198 /// #### `key-press-event`
1199 /// The ::key-press-event signal is emitted when a key is pressed. The signal
1200 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
1201 ///
1202 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1203 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
1204 ///
1205 /// This signal will be sent to the grab widget if there is one.
1206 ///
1207 ///
1208 ///
1209 ///
1210 /// #### `key-release-event`
1211 /// The ::key-release-event signal is emitted when a key is released.
1212 ///
1213 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1214 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
1215 ///
1216 /// This signal will be sent to the grab widget if there is one.
1217 ///
1218 ///
1219 ///
1220 ///
1221 /// #### `keynav-failed`
1222 /// Gets emitted if keyboard navigation fails.
1223 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
1224 ///
1225 ///
1226 ///
1227 ///
1228 /// #### `leave-notify-event`
1229 /// The ::leave-notify-event will be emitted when the pointer leaves
1230 /// the `widget`'s window.
1231 ///
1232 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1233 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1234 ///
1235 /// This signal will be sent to the grab widget if there is one.
1236 ///
1237 ///
1238 ///
1239 ///
1240 /// #### `map`
1241 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1242 /// when the widget is visible (which is controlled with
1243 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1244 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1245 /// be emitted.
1246 ///
1247 /// The ::map signal can be used to determine whether a widget will be drawn,
1248 /// for instance it can resume an animation that was stopped during the
1249 /// emission of [`unmap`][struct@crate::Widget#unmap].
1250 ///
1251 ///
1252 ///
1253 ///
1254 /// #### `map-event`
1255 /// The ::map-event signal will be emitted when the `widget`'s window is
1256 /// mapped. A window is mapped when it becomes visible on the screen.
1257 ///
1258 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1259 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1260 /// automatically for all new windows.
1261 ///
1262 ///
1263 ///
1264 ///
1265 /// #### `mnemonic-activate`
1266 /// The default handler for this signal activates `widget` if `group_cycling`
1267 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1268 ///
1269 ///
1270 ///
1271 ///
1272 /// #### `motion-notify-event`
1273 /// The ::motion-notify-event signal is emitted when the pointer moves
1274 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1275 ///
1276 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1277 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1278 ///
1279 /// This signal will be sent to the grab widget if there is one.
1280 ///
1281 ///
1282 ///
1283 ///
1284 /// #### `move-focus`
1285 /// Action
1286 ///
1287 ///
1288 /// #### `parent-set`
1289 /// The ::parent-set signal is emitted when a new parent
1290 /// has been set on a widget.
1291 ///
1292 ///
1293 ///
1294 ///
1295 /// #### `popup-menu`
1296 /// This signal gets emitted whenever a widget should pop up a context
1297 /// menu. This usually happens through the standard key binding mechanism;
1298 /// by pressing a certain key while a widget is focused, the user can cause
1299 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1300 /// a menu with clipboard commands. See the
1301 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1302 /// for an example of how to use this signal.
1303 ///
1304 /// Action
1305 ///
1306 ///
1307 /// #### `property-notify-event`
1308 /// The ::property-notify-event signal will be emitted when a property on
1309 /// the `widget`'s window has been changed or deleted.
1310 ///
1311 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1312 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1313 ///
1314 ///
1315 ///
1316 ///
1317 /// #### `proximity-in-event`
1318 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1319 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1320 ///
1321 /// This signal will be sent to the grab widget if there is one.
1322 ///
1323 ///
1324 ///
1325 ///
1326 /// #### `proximity-out-event`
1327 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1328 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1329 ///
1330 /// This signal will be sent to the grab widget if there is one.
1331 ///
1332 ///
1333 ///
1334 ///
1335 /// #### `query-tooltip`
1336 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1337 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1338 /// focus in keyboard mode.
1339 ///
1340 /// Using the given coordinates, the signal handler should determine
1341 /// whether a tooltip should be shown for `widget`. If this is the case
1342 /// [`true`] should be returned, [`false`] otherwise. Note that if
1343 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1344 /// should not be used.
1345 ///
1346 /// The signal handler is free to manipulate `tooltip` with the therefore
1347 /// destined function calls.
1348 ///
1349 ///
1350 ///
1351 ///
1352 /// #### `realize`
1353 /// The ::realize signal is emitted when `widget` is associated with a
1354 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1355 /// widget has been mapped (that is, it is going to be drawn).
1356 ///
1357 ///
1358 ///
1359 ///
1360 /// #### `screen-changed`
1361 /// The ::screen-changed signal gets emitted when the
1362 /// screen of a widget has changed.
1363 ///
1364 ///
1365 ///
1366 ///
1367 /// #### `scroll-event`
1368 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1369 /// range is pressed. Wheel mice are usually configured to generate
1370 /// button press events for buttons 4 and 5 when the wheel is turned.
1371 ///
1372 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1373 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1374 ///
1375 /// This signal will be sent to the grab widget if there is one.
1376 ///
1377 ///
1378 ///
1379 ///
1380 /// #### `selection-clear-event`
1381 /// The ::selection-clear-event signal will be emitted when the
1382 /// the `widget`'s window has lost ownership of a selection.
1383 ///
1384 ///
1385 ///
1386 ///
1387 /// #### `selection-get`
1388 ///
1389 ///
1390 ///
1391 /// #### `selection-notify-event`
1392 ///
1393 ///
1394 ///
1395 /// #### `selection-received`
1396 ///
1397 ///
1398 ///
1399 /// #### `selection-request-event`
1400 /// The ::selection-request-event signal will be emitted when
1401 /// another client requests ownership of the selection owned by
1402 /// the `widget`'s window.
1403 ///
1404 ///
1405 ///
1406 ///
1407 /// #### `show`
1408 /// The ::show signal is emitted when `widget` is shown, for example with
1409 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1410 ///
1411 ///
1412 ///
1413 ///
1414 /// #### `show-help`
1415 /// Action
1416 ///
1417 ///
1418 /// #### `size-allocate`
1419 ///
1420 ///
1421 ///
1422 /// #### `state-changed`
1423 /// The ::state-changed signal is emitted when the widget state changes.
1424 /// See `gtk_widget_get_state()`.
1425 ///
1426 ///
1427 ///
1428 ///
1429 /// #### `state-flags-changed`
1430 /// The ::state-flags-changed signal is emitted when the widget state
1431 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1432 ///
1433 ///
1434 ///
1435 ///
1436 /// #### `style-set`
1437 /// The ::style-set signal is emitted when a new style has been set
1438 /// on a widget. Note that style-modifying functions like
1439 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1440 ///
1441 /// Note that this signal is emitted for changes to the deprecated
1442 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1443 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1444 ///
1445 ///
1446 ///
1447 ///
1448 /// #### `style-updated`
1449 /// The ::style-updated signal is a convenience signal that is emitted when the
1450 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1451 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1452 ///
1453 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1454 /// cause this signal to be emitted.
1455 ///
1456 ///
1457 ///
1458 ///
1459 /// #### `touch-event`
1460 ///
1461 ///
1462 ///
1463 /// #### `unmap`
1464 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1465 /// means that either it or any of its parents up to the toplevel widget have
1466 /// been set as hidden.
1467 ///
1468 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1469 /// used to, for example, stop an animation on the widget.
1470 ///
1471 ///
1472 ///
1473 ///
1474 /// #### `unmap-event`
1475 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1476 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1477 ///
1478 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1479 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1480 /// automatically for all new windows.
1481 ///
1482 ///
1483 ///
1484 ///
1485 /// #### `unrealize`
1486 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1487 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1488 /// called or the widget has been unmapped (that is, it is going to be
1489 /// hidden).
1490 ///
1491 ///
1492 ///
1493 ///
1494 /// #### `visibility-notify-event`
1495 /// The ::visibility-notify-event will be emitted when the `widget`'s
1496 /// window is obscured or unobscured.
1497 ///
1498 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1499 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1500 ///
1501 ///
1502 ///
1503 ///
1504 /// #### `window-state-event`
1505 /// The ::window-state-event will be emitted when the state of the
1506 /// toplevel window associated to the `widget` changes.
1507 ///
1508 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1509 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1510 /// this mask automatically for all new windows.
1511 ///
1512 ///
1513 /// </details>
1514 ///
1515 /// # Implements
1516 ///
1517 /// [`DialogExt`][trait@crate::prelude::DialogExt], [`GtkWindowExt`][trait@crate::prelude::GtkWindowExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`DialogExtManual`][trait@crate::prelude::DialogExtManual], [`GtkWindowExtManual`][trait@crate::prelude::GtkWindowExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1518 #[doc(alias = "GtkDialog")]
1519 pub struct Dialog(Object<ffi::GtkDialog, ffi::GtkDialogClass>) @extends Window, Bin, Container, Widget, @implements Buildable;
1520
1521 match fn {
1522 type_ => || ffi::gtk_dialog_get_type(),
1523 }
1524}
1525
1526impl Dialog {
1527 pub const NONE: Option<&'static Dialog> = None;
1528
1529 /// Creates a new dialog box.
1530 ///
1531 /// Widgets should not be packed into this [`Window`][crate::Window]
1532 /// directly, but into the `vbox` and `action_area`, as described above.
1533 ///
1534 /// # Returns
1535 ///
1536 /// the new dialog as a [`Widget`][crate::Widget]
1537 #[doc(alias = "gtk_dialog_new")]
1538 pub fn new() -> Dialog {
1539 assert_initialized_main_thread!();
1540 unsafe { Widget::from_glib_none(ffi::gtk_dialog_new()).unsafe_cast() }
1541 }
1542
1543 //#[doc(alias = "gtk_dialog_new_with_buttons")]
1544 //#[doc(alias = "new_with_buttons")]
1545 //pub fn with_buttons(title: Option<&str>, parent: Option<&impl IsA<Window>>, flags: DialogFlags, first_button_text: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Dialog {
1546 // unsafe { TODO: call ffi:gtk_dialog_new_with_buttons() }
1547 //}
1548
1549 // rustdoc-stripper-ignore-next
1550 /// Creates a new builder-pattern struct instance to construct [`Dialog`] objects.
1551 ///
1552 /// This method returns an instance of [`DialogBuilder`](crate::builders::DialogBuilder) which can be used to create [`Dialog`] objects.
1553 pub fn builder() -> DialogBuilder {
1554 DialogBuilder::new()
1555 }
1556}
1557
1558impl Default for Dialog {
1559 fn default() -> Self {
1560 Self::new()
1561 }
1562}
1563
1564// rustdoc-stripper-ignore-next
1565/// A [builder-pattern] type to construct [`Dialog`] objects.
1566///
1567/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1568#[must_use = "The builder must be built to be used"]
1569pub struct DialogBuilder {
1570 builder: glib::object::ObjectBuilder<'static, Dialog>,
1571}
1572
1573impl DialogBuilder {
1574 fn new() -> Self {
1575 Self {
1576 builder: glib::object::Object::builder(),
1577 }
1578 }
1579
1580 /// [`true`] if the dialog uses a [`HeaderBar`][crate::HeaderBar] for action buttons
1581 /// instead of the action-area.
1582 ///
1583 /// For technical reasons, this property is declared as an integer
1584 /// property, but you should only set it to [`true`] or [`false`].
1585 pub fn use_header_bar(self, use_header_bar: i32) -> Self {
1586 Self {
1587 builder: self.builder.property("use-header-bar", use_header_bar),
1588 }
1589 }
1590
1591 /// Whether the window should receive the input focus.
1592 pub fn accept_focus(self, accept_focus: bool) -> Self {
1593 Self {
1594 builder: self.builder.property("accept-focus", accept_focus),
1595 }
1596 }
1597
1598 /// The [`Application`][crate::Application] associated with the window.
1599 ///
1600 /// The application will be kept alive for at least as long as it
1601 /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
1602 /// for a way to keep it alive without windows).
1603 ///
1604 /// Normally, the connection between the application and the window
1605 /// will remain until the window is destroyed, but you can explicitly
1606 /// remove it by setting the :application property to [`None`].
1607 pub fn application(self, application: &impl IsA<Application>) -> Self {
1608 Self {
1609 builder: self
1610 .builder
1611 .property("application", application.clone().upcast()),
1612 }
1613 }
1614
1615 /// The widget to which this window is attached.
1616 /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
1617 ///
1618 /// Examples of places where specifying this relation is useful are
1619 /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
1620 /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
1621 /// created by [`TreeView`][crate::TreeView].
1622 pub fn attached_to(self, attached_to: &impl IsA<Widget>) -> Self {
1623 Self {
1624 builder: self
1625 .builder
1626 .property("attached-to", attached_to.clone().upcast()),
1627 }
1628 }
1629
1630 /// Whether the window should be decorated by the window manager.
1631 pub fn decorated(self, decorated: bool) -> Self {
1632 Self {
1633 builder: self.builder.property("decorated", decorated),
1634 }
1635 }
1636
1637 pub fn default_height(self, default_height: i32) -> Self {
1638 Self {
1639 builder: self.builder.property("default-height", default_height),
1640 }
1641 }
1642
1643 pub fn default_width(self, default_width: i32) -> Self {
1644 Self {
1645 builder: self.builder.property("default-width", default_width),
1646 }
1647 }
1648
1649 /// Whether the window frame should have a close button.
1650 pub fn deletable(self, deletable: bool) -> Self {
1651 Self {
1652 builder: self.builder.property("deletable", deletable),
1653 }
1654 }
1655
1656 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
1657 Self {
1658 builder: self
1659 .builder
1660 .property("destroy-with-parent", destroy_with_parent),
1661 }
1662 }
1663
1664 /// Whether the window should receive the input focus when mapped.
1665 pub fn focus_on_map(self, focus_on_map: bool) -> Self {
1666 Self {
1667 builder: self.builder.property("focus-on-map", focus_on_map),
1668 }
1669 }
1670
1671 /// Whether 'focus rectangles' are currently visible in this window.
1672 ///
1673 /// This property is maintained by GTK+ based on user input
1674 /// and should not be set by applications.
1675 pub fn focus_visible(self, focus_visible: bool) -> Self {
1676 Self {
1677 builder: self.builder.property("focus-visible", focus_visible),
1678 }
1679 }
1680
1681 /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
1682 /// more details about window gravity.
1683 pub fn gravity(self, gravity: gdk::Gravity) -> Self {
1684 Self {
1685 builder: self.builder.property("gravity", gravity),
1686 }
1687 }
1688
1689 /// Whether the titlebar should be hidden during maximization.
1690 pub fn hide_titlebar_when_maximized(self, hide_titlebar_when_maximized: bool) -> Self {
1691 Self {
1692 builder: self
1693 .builder
1694 .property("hide-titlebar-when-maximized", hide_titlebar_when_maximized),
1695 }
1696 }
1697
1698 pub fn icon(self, icon: &gdk_pixbuf::Pixbuf) -> Self {
1699 Self {
1700 builder: self.builder.property("icon", icon.clone()),
1701 }
1702 }
1703
1704 /// The :icon-name property specifies the name of the themed icon to
1705 /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
1706 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1707 Self {
1708 builder: self.builder.property("icon-name", icon_name.into()),
1709 }
1710 }
1711
1712 /// Whether mnemonics are currently visible in this window.
1713 ///
1714 /// This property is maintained by GTK+ based on user input,
1715 /// and should not be set by applications.
1716 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
1717 Self {
1718 builder: self
1719 .builder
1720 .property("mnemonics-visible", mnemonics_visible),
1721 }
1722 }
1723
1724 pub fn modal(self, modal: bool) -> Self {
1725 Self {
1726 builder: self.builder.property("modal", modal),
1727 }
1728 }
1729
1730 pub fn resizable(self, resizable: bool) -> Self {
1731 Self {
1732 builder: self.builder.property("resizable", resizable),
1733 }
1734 }
1735
1736 pub fn role(self, role: impl Into<glib::GString>) -> Self {
1737 Self {
1738 builder: self.builder.property("role", role.into()),
1739 }
1740 }
1741
1742 pub fn screen(self, screen: &gdk::Screen) -> Self {
1743 Self {
1744 builder: self.builder.property("screen", screen.clone()),
1745 }
1746 }
1747
1748 pub fn skip_pager_hint(self, skip_pager_hint: bool) -> Self {
1749 Self {
1750 builder: self.builder.property("skip-pager-hint", skip_pager_hint),
1751 }
1752 }
1753
1754 pub fn skip_taskbar_hint(self, skip_taskbar_hint: bool) -> Self {
1755 Self {
1756 builder: self
1757 .builder
1758 .property("skip-taskbar-hint", skip_taskbar_hint),
1759 }
1760 }
1761
1762 /// The :startup-id is a write-only property for setting window's
1763 /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
1764 /// for more details.
1765 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
1766 Self {
1767 builder: self.builder.property("startup-id", startup_id.into()),
1768 }
1769 }
1770
1771 pub fn title(self, title: impl Into<glib::GString>) -> Self {
1772 Self {
1773 builder: self.builder.property("title", title.into()),
1774 }
1775 }
1776
1777 /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
1778 /// more details about transient windows.
1779 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
1780 Self {
1781 builder: self
1782 .builder
1783 .property("transient-for", transient_for.clone().upcast()),
1784 }
1785 }
1786
1787 pub fn type_(self, type_: WindowType) -> Self {
1788 Self {
1789 builder: self.builder.property("type", type_),
1790 }
1791 }
1792
1793 pub fn type_hint(self, type_hint: gdk::WindowTypeHint) -> Self {
1794 Self {
1795 builder: self.builder.property("type-hint", type_hint),
1796 }
1797 }
1798
1799 pub fn urgency_hint(self, urgency_hint: bool) -> Self {
1800 Self {
1801 builder: self.builder.property("urgency-hint", urgency_hint),
1802 }
1803 }
1804
1805 pub fn window_position(self, window_position: WindowPosition) -> Self {
1806 Self {
1807 builder: self.builder.property("window-position", window_position),
1808 }
1809 }
1810
1811 pub fn border_width(self, border_width: u32) -> Self {
1812 Self {
1813 builder: self.builder.property("border-width", border_width),
1814 }
1815 }
1816
1817 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1818 Self {
1819 builder: self.builder.property("child", child.clone().upcast()),
1820 }
1821 }
1822
1823 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1824 Self {
1825 builder: self.builder.property("resize-mode", resize_mode),
1826 }
1827 }
1828
1829 pub fn app_paintable(self, app_paintable: bool) -> Self {
1830 Self {
1831 builder: self.builder.property("app-paintable", app_paintable),
1832 }
1833 }
1834
1835 pub fn can_default(self, can_default: bool) -> Self {
1836 Self {
1837 builder: self.builder.property("can-default", can_default),
1838 }
1839 }
1840
1841 pub fn can_focus(self, can_focus: bool) -> Self {
1842 Self {
1843 builder: self.builder.property("can-focus", can_focus),
1844 }
1845 }
1846
1847 pub fn events(self, events: gdk::EventMask) -> Self {
1848 Self {
1849 builder: self.builder.property("events", events),
1850 }
1851 }
1852
1853 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1854 pub fn expand(self, expand: bool) -> Self {
1855 Self {
1856 builder: self.builder.property("expand", expand),
1857 }
1858 }
1859
1860 /// Whether the widget should grab focus when it is clicked with the mouse.
1861 ///
1862 /// This property is only relevant for widgets that can take focus.
1863 ///
1864 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1865 /// GtkComboBox) implemented this property individually.
1866 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1867 Self {
1868 builder: self.builder.property("focus-on-click", focus_on_click),
1869 }
1870 }
1871
1872 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1873 pub fn halign(self, halign: Align) -> Self {
1874 Self {
1875 builder: self.builder.property("halign", halign),
1876 }
1877 }
1878
1879 pub fn has_default(self, has_default: bool) -> Self {
1880 Self {
1881 builder: self.builder.property("has-default", has_default),
1882 }
1883 }
1884
1885 pub fn has_focus(self, has_focus: bool) -> Self {
1886 Self {
1887 builder: self.builder.property("has-focus", has_focus),
1888 }
1889 }
1890
1891 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1892 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1893 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1894 /// whether it will provide a tooltip or not.
1895 ///
1896 /// Note that setting this property to [`true`] for the first time will change
1897 /// the event masks of the GdkWindows of this widget to include leave-notify
1898 /// and motion-notify events. This cannot and will not be undone when the
1899 /// property is set to [`false`] again.
1900 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1901 Self {
1902 builder: self.builder.property("has-tooltip", has_tooltip),
1903 }
1904 }
1905
1906 pub fn height_request(self, height_request: i32) -> Self {
1907 Self {
1908 builder: self.builder.property("height-request", height_request),
1909 }
1910 }
1911
1912 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1913 pub fn hexpand(self, hexpand: bool) -> Self {
1914 Self {
1915 builder: self.builder.property("hexpand", hexpand),
1916 }
1917 }
1918
1919 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1920 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1921 Self {
1922 builder: self.builder.property("hexpand-set", hexpand_set),
1923 }
1924 }
1925
1926 pub fn is_focus(self, is_focus: bool) -> Self {
1927 Self {
1928 builder: self.builder.property("is-focus", is_focus),
1929 }
1930 }
1931
1932 /// Sets all four sides' margin at once. If read, returns max
1933 /// margin on any side.
1934 pub fn margin(self, margin: i32) -> Self {
1935 Self {
1936 builder: self.builder.property("margin", margin),
1937 }
1938 }
1939
1940 /// Margin on bottom side of widget.
1941 ///
1942 /// This property adds margin outside of the widget's normal size
1943 /// request, the margin will be added in addition to the size from
1944 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1945 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1946 Self {
1947 builder: self.builder.property("margin-bottom", margin_bottom),
1948 }
1949 }
1950
1951 /// Margin on end of widget, horizontally. This property supports
1952 /// left-to-right and right-to-left text directions.
1953 ///
1954 /// This property adds margin outside of the widget's normal size
1955 /// request, the margin will be added in addition to the size from
1956 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1957 pub fn margin_end(self, margin_end: i32) -> Self {
1958 Self {
1959 builder: self.builder.property("margin-end", margin_end),
1960 }
1961 }
1962
1963 /// Margin on start of widget, horizontally. This property supports
1964 /// left-to-right and right-to-left text directions.
1965 ///
1966 /// This property adds margin outside of the widget's normal size
1967 /// request, the margin will be added in addition to the size from
1968 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1969 pub fn margin_start(self, margin_start: i32) -> Self {
1970 Self {
1971 builder: self.builder.property("margin-start", margin_start),
1972 }
1973 }
1974
1975 /// Margin on top side of widget.
1976 ///
1977 /// This property adds margin outside of the widget's normal size
1978 /// request, the margin will be added in addition to the size from
1979 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1980 pub fn margin_top(self, margin_top: i32) -> Self {
1981 Self {
1982 builder: self.builder.property("margin-top", margin_top),
1983 }
1984 }
1985
1986 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1987 Self {
1988 builder: self.builder.property("name", name.into()),
1989 }
1990 }
1991
1992 pub fn no_show_all(self, no_show_all: bool) -> Self {
1993 Self {
1994 builder: self.builder.property("no-show-all", no_show_all),
1995 }
1996 }
1997
1998 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1999 /// more details about window opacity.
2000 ///
2001 /// Before 3.8 this was only available in GtkWindow
2002 pub fn opacity(self, opacity: f64) -> Self {
2003 Self {
2004 builder: self.builder.property("opacity", opacity),
2005 }
2006 }
2007
2008 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
2009 Self {
2010 builder: self.builder.property("parent", parent.clone().upcast()),
2011 }
2012 }
2013
2014 pub fn receives_default(self, receives_default: bool) -> Self {
2015 Self {
2016 builder: self.builder.property("receives-default", receives_default),
2017 }
2018 }
2019
2020 pub fn sensitive(self, sensitive: bool) -> Self {
2021 Self {
2022 builder: self.builder.property("sensitive", sensitive),
2023 }
2024 }
2025
2026 /// Sets the text of tooltip to be the given string, which is marked up
2027 /// with the [Pango text markup language][PangoMarkupFormat].
2028 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2029 ///
2030 /// This is a convenience property which will take care of getting the
2031 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
2032 /// will automatically be set to [`true`] and there will be taken care of
2033 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
2034 ///
2035 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
2036 /// are set, the last one wins.
2037 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2038 Self {
2039 builder: self
2040 .builder
2041 .property("tooltip-markup", tooltip_markup.into()),
2042 }
2043 }
2044
2045 /// Sets the text of tooltip to be the given string.
2046 ///
2047 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2048 ///
2049 /// This is a convenience property which will take care of getting the
2050 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
2051 /// will automatically be set to [`true`] and there will be taken care of
2052 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
2053 ///
2054 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
2055 /// are set, the last one wins.
2056 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2057 Self {
2058 builder: self.builder.property("tooltip-text", tooltip_text.into()),
2059 }
2060 }
2061
2062 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
2063 pub fn valign(self, valign: Align) -> Self {
2064 Self {
2065 builder: self.builder.property("valign", valign),
2066 }
2067 }
2068
2069 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
2070 pub fn vexpand(self, vexpand: bool) -> Self {
2071 Self {
2072 builder: self.builder.property("vexpand", vexpand),
2073 }
2074 }
2075
2076 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
2077 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2078 Self {
2079 builder: self.builder.property("vexpand-set", vexpand_set),
2080 }
2081 }
2082
2083 pub fn visible(self, visible: bool) -> Self {
2084 Self {
2085 builder: self.builder.property("visible", visible),
2086 }
2087 }
2088
2089 pub fn width_request(self, width_request: i32) -> Self {
2090 Self {
2091 builder: self.builder.property("width-request", width_request),
2092 }
2093 }
2094
2095 // rustdoc-stripper-ignore-next
2096 /// Build the [`Dialog`].
2097 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2098 pub fn build(self) -> Dialog {
2099 assert_initialized_main_thread!();
2100 self.builder.build()
2101 }
2102}
2103
2104/// Trait containing all [`struct@Dialog`] methods.
2105///
2106/// # Implementors
2107///
2108/// [`AboutDialog`][struct@crate::AboutDialog], [`AppChooserDialog`][struct@crate::AppChooserDialog], [`ColorChooserDialog`][struct@crate::ColorChooserDialog], [`Dialog`][struct@crate::Dialog], [`FileChooserDialog`][struct@crate::FileChooserDialog], [`FontChooserDialog`][struct@crate::FontChooserDialog], [`MessageDialog`][struct@crate::MessageDialog], [`RecentChooserDialog`][struct@crate::RecentChooserDialog]
2109pub trait DialogExt: IsA<Dialog> + 'static {
2110 /// Adds an activatable widget to the action area of a [`Dialog`][crate::Dialog],
2111 /// connecting a signal handler that will emit the [`response`][struct@crate::Dialog#response]
2112 /// signal on the dialog when the widget is activated. The widget is
2113 /// appended to the end of the dialog’s action area. If you want to add a
2114 /// non-activatable widget, simply pack it into the `action_area` field
2115 /// of the [`Dialog`][crate::Dialog] struct.
2116 /// ## `child`
2117 /// an activatable widget
2118 /// ## `response_id`
2119 /// response ID for `child`
2120 #[doc(alias = "gtk_dialog_add_action_widget")]
2121 fn add_action_widget(&self, child: &impl IsA<Widget>, response_id: ResponseType) {
2122 unsafe {
2123 ffi::gtk_dialog_add_action_widget(
2124 self.as_ref().to_glib_none().0,
2125 child.as_ref().to_glib_none().0,
2126 response_id.into_glib(),
2127 );
2128 }
2129 }
2130
2131 /// Adds a button with the given text and sets things up so that
2132 /// clicking the button will emit the [`response`][struct@crate::Dialog#response] signal with
2133 /// the given `response_id`. The button is appended to the end of the
2134 /// dialog’s action area. The button widget is returned, but usually
2135 /// you don’t need it.
2136 /// ## `button_text`
2137 /// text of button
2138 /// ## `response_id`
2139 /// response ID for the button
2140 ///
2141 /// # Returns
2142 ///
2143 /// the [`Button`][crate::Button] widget that was added
2144 #[doc(alias = "gtk_dialog_add_button")]
2145 fn add_button(&self, button_text: &str, response_id: ResponseType) -> Widget {
2146 unsafe {
2147 from_glib_none(ffi::gtk_dialog_add_button(
2148 self.as_ref().to_glib_none().0,
2149 button_text.to_glib_none().0,
2150 response_id.into_glib(),
2151 ))
2152 }
2153 }
2154
2155 /// Returns the content area of `self`.
2156 ///
2157 /// # Returns
2158 ///
2159 /// the content area [`Box`][crate::Box].
2160 #[doc(alias = "gtk_dialog_get_content_area")]
2161 #[doc(alias = "get_content_area")]
2162 fn content_area(&self) -> Box {
2163 unsafe {
2164 from_glib_none(ffi::gtk_dialog_get_content_area(
2165 self.as_ref().to_glib_none().0,
2166 ))
2167 }
2168 }
2169
2170 /// Returns the header bar of `self`. Note that the
2171 /// headerbar is only used by the dialog if the
2172 /// [`use-header-bar`][struct@crate::Dialog#use-header-bar] property is [`true`].
2173 ///
2174 /// # Returns
2175 ///
2176 /// the header bar
2177 #[doc(alias = "gtk_dialog_get_header_bar")]
2178 #[doc(alias = "get_header_bar")]
2179 fn header_bar(&self) -> Option<HeaderBar> {
2180 unsafe {
2181 from_glib_none(ffi::gtk_dialog_get_header_bar(
2182 self.as_ref().to_glib_none().0,
2183 ))
2184 }
2185 }
2186
2187 /// Gets the response id of a widget in the action area
2188 /// of a dialog.
2189 /// ## `widget`
2190 /// a widget in the action area of `self`
2191 ///
2192 /// # Returns
2193 ///
2194 /// the response id of `widget`, or [`ResponseType::None`][crate::ResponseType::None]
2195 /// if `widget` doesn’t have a response id set.
2196 #[doc(alias = "gtk_dialog_get_response_for_widget")]
2197 #[doc(alias = "get_response_for_widget")]
2198 fn response_for_widget(&self, widget: &impl IsA<Widget>) -> ResponseType {
2199 unsafe {
2200 from_glib(ffi::gtk_dialog_get_response_for_widget(
2201 self.as_ref().to_glib_none().0,
2202 widget.as_ref().to_glib_none().0,
2203 ))
2204 }
2205 }
2206
2207 /// Gets the widget button that uses the given response ID in the action area
2208 /// of a dialog.
2209 /// ## `response_id`
2210 /// the response ID used by the `self` widget
2211 ///
2212 /// # Returns
2213 ///
2214 /// the `widget` button that uses the given
2215 /// `response_id`, or [`None`].
2216 #[doc(alias = "gtk_dialog_get_widget_for_response")]
2217 #[doc(alias = "get_widget_for_response")]
2218 fn widget_for_response(&self, response_id: ResponseType) -> Option<Widget> {
2219 unsafe {
2220 from_glib_none(ffi::gtk_dialog_get_widget_for_response(
2221 self.as_ref().to_glib_none().0,
2222 response_id.into_glib(),
2223 ))
2224 }
2225 }
2226
2227 /// Emits the [`response`][struct@crate::Dialog#response] signal with the given response ID.
2228 /// Used to indicate that the user has responded to the dialog in some way;
2229 /// typically either you or [`run()`][Self::run()] will be monitoring the
2230 /// ::response signal and take appropriate action.
2231 /// ## `response_id`
2232 /// response ID
2233 #[doc(alias = "gtk_dialog_response")]
2234 fn response(&self, response_id: ResponseType) {
2235 unsafe {
2236 ffi::gtk_dialog_response(self.as_ref().to_glib_none().0, response_id.into_glib());
2237 }
2238 }
2239
2240 /// Blocks in a recursive main loop until the `self` either emits the
2241 /// [`response`][struct@crate::Dialog#response] signal, or is destroyed. If the dialog is
2242 /// destroyed during the call to [`run()`][Self::run()], [`run()`][Self::run()] returns
2243 /// [`ResponseType::None`][crate::ResponseType::None]. Otherwise, it returns the response ID from the
2244 /// ::response signal emission.
2245 ///
2246 /// Before entering the recursive main loop, [`run()`][Self::run()] calls
2247 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()] on the dialog for you. Note that you still
2248 /// need to show any children of the dialog yourself.
2249 ///
2250 /// During [`run()`][Self::run()], the default behavior of [`delete-event`][struct@crate::Widget#delete-event]
2251 /// is disabled; if the dialog receives ::delete_event, it will not be
2252 /// destroyed as windows usually are, and [`run()`][Self::run()] will return
2253 /// [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent]. Also, during [`run()`][Self::run()] the dialog
2254 /// will be modal. You can force [`run()`][Self::run()] to return at any time by
2255 /// calling [`response()`][Self::response()] to emit the ::response signal. Destroying
2256 /// the dialog during [`run()`][Self::run()] is a very bad idea, because your
2257 /// post-run code won’t know whether the dialog was destroyed or not.
2258 ///
2259 /// After [`run()`][Self::run()] returns, you are responsible for hiding or
2260 /// destroying the dialog if you wish to do so.
2261 ///
2262 /// Typical usage of this function might be:
2263 ///
2264 ///
2265 /// **⚠️ The following code is in C ⚠️**
2266 ///
2267 /// ```C
2268 /// GtkWidget *dialog = gtk_dialog_new ();
2269 /// // Set up dialog...
2270 ///
2271 /// int result = gtk_dialog_run (GTK_DIALOG (dialog));
2272 /// switch (result)
2273 /// {
2274 /// case GTK_RESPONSE_ACCEPT:
2275 /// // do_application_specific_something ();
2276 /// break;
2277 /// default:
2278 /// // do_nothing_since_dialog_was_cancelled ();
2279 /// break;
2280 /// }
2281 /// gtk_widget_destroy (dialog);
2282 /// ```
2283 ///
2284 /// Note that even though the recursive main loop gives the effect of a
2285 /// modal dialog (it prevents the user from interacting with other
2286 /// windows in the same window group while the dialog is run), callbacks
2287 /// such as timeouts, IO channel watches, DND drops, etc, will
2288 /// be triggered during a [`run()`][Self::run()] call.
2289 ///
2290 /// # Returns
2291 ///
2292 /// response ID
2293 #[doc(alias = "gtk_dialog_run")]
2294 fn run(&self) -> ResponseType {
2295 unsafe { from_glib(ffi::gtk_dialog_run(self.as_ref().to_glib_none().0)) }
2296 }
2297
2298 /// Sets the last widget in the dialog’s action area with the given `response_id`
2299 /// as the default widget for the dialog. Pressing “Enter” normally activates
2300 /// the default widget.
2301 /// ## `response_id`
2302 /// a response ID
2303 #[doc(alias = "gtk_dialog_set_default_response")]
2304 fn set_default_response(&self, response_id: ResponseType) {
2305 unsafe {
2306 ffi::gtk_dialog_set_default_response(
2307 self.as_ref().to_glib_none().0,
2308 response_id.into_glib(),
2309 );
2310 }
2311 }
2312
2313 /// Calls `gtk_widget_set_sensitive (widget, `setting`)`
2314 /// for each widget in the dialog’s action area with the given `response_id`.
2315 /// A convenient way to sensitize/desensitize dialog buttons.
2316 /// ## `response_id`
2317 /// a response ID
2318 /// ## `setting`
2319 /// [`true`] for sensitive
2320 #[doc(alias = "gtk_dialog_set_response_sensitive")]
2321 fn set_response_sensitive(&self, response_id: ResponseType, setting: bool) {
2322 unsafe {
2323 ffi::gtk_dialog_set_response_sensitive(
2324 self.as_ref().to_glib_none().0,
2325 response_id.into_glib(),
2326 setting.into_glib(),
2327 );
2328 }
2329 }
2330
2331 /// [`true`] if the dialog uses a [`HeaderBar`][crate::HeaderBar] for action buttons
2332 /// instead of the action-area.
2333 ///
2334 /// For technical reasons, this property is declared as an integer
2335 /// property, but you should only set it to [`true`] or [`false`].
2336 #[doc(alias = "use-header-bar")]
2337 fn use_header_bar(&self) -> i32 {
2338 ObjectExt::property(self.as_ref(), "use-header-bar")
2339 }
2340
2341 /// The ::close signal is a
2342 /// [keybinding signal][GtkBindingSignal]
2343 /// which gets emitted when the user uses a keybinding to close
2344 /// the dialog.
2345 ///
2346 /// The default binding for this signal is the Escape key.
2347 #[doc(alias = "close")]
2348 fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2349 unsafe extern "C" fn close_trampoline<P: IsA<Dialog>, F: Fn(&P) + 'static>(
2350 this: *mut ffi::GtkDialog,
2351 f: glib::ffi::gpointer,
2352 ) {
2353 unsafe {
2354 let f: &F = &*(f as *const F);
2355 f(Dialog::from_glib_borrow(this).unsafe_cast_ref())
2356 }
2357 }
2358 unsafe {
2359 let f: Box_<F> = Box_::new(f);
2360 connect_raw(
2361 self.as_ptr() as *mut _,
2362 c"close".as_ptr(),
2363 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2364 close_trampoline::<Self, F> as *const (),
2365 )),
2366 Box_::into_raw(f),
2367 )
2368 }
2369 }
2370
2371 fn emit_close(&self) {
2372 self.emit_by_name::<()>("close", &[]);
2373 }
2374
2375 /// Emitted when an action widget is clicked, the dialog receives a
2376 /// delete event, or the application programmer calls [`response()`][Self::response()].
2377 /// On a delete event, the response ID is [`ResponseType::DeleteEvent`][crate::ResponseType::DeleteEvent].
2378 /// Otherwise, it depends on which action widget was clicked.
2379 /// ## `response_id`
2380 /// the response ID
2381 #[doc(alias = "response")]
2382 fn connect_response<F: Fn(&Self, ResponseType) + 'static>(&self, f: F) -> SignalHandlerId {
2383 unsafe extern "C" fn response_trampoline<
2384 P: IsA<Dialog>,
2385 F: Fn(&P, ResponseType) + 'static,
2386 >(
2387 this: *mut ffi::GtkDialog,
2388 response_id: ffi::GtkResponseType,
2389 f: glib::ffi::gpointer,
2390 ) {
2391 unsafe {
2392 let f: &F = &*(f as *const F);
2393 f(
2394 Dialog::from_glib_borrow(this).unsafe_cast_ref(),
2395 from_glib(response_id),
2396 )
2397 }
2398 }
2399 unsafe {
2400 let f: Box_<F> = Box_::new(f);
2401 connect_raw(
2402 self.as_ptr() as *mut _,
2403 c"response".as_ptr(),
2404 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2405 response_trampoline::<Self, F> as *const (),
2406 )),
2407 Box_::into_raw(f),
2408 )
2409 }
2410 }
2411}
2412
2413impl<O: IsA<Dialog>> DialogExt for O {}