gtk/auto/window.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 AccelGroup, Align, Application, Bin, Buildable, Container, ResizeMode, Widget, WindowGroup,
7 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 /// A GtkWindow is a toplevel window which can contain other widgets.
19 /// Windows normally have decorations that are under the control
20 /// of the windowing system and allow the user to manipulate the window
21 /// (resize it, move it, close it,...).
22 ///
23 /// # GtkWindow as GtkBuildable
24 ///
25 /// The GtkWindow implementation of the [`Buildable`][crate::Buildable] interface supports a
26 /// custom ``<accel-groups>`` element, which supports any number of ``<group>``
27 /// elements representing the [`AccelGroup`][crate::AccelGroup] objects you want to add to
28 /// your window (synonymous with [`GtkWindowExt::add_accel_group()`][crate::prelude::GtkWindowExt::add_accel_group()].
29 ///
30 /// It also supports the ``<initial-focus>`` element, whose name property names
31 /// the widget to receive the focus when the window is mapped.
32 ///
33 /// An example of a UI definition fragment with accel groups:
34 ///
35 ///
36 ///
37 /// **⚠️ The following code is in xml ⚠️**
38 ///
39 /// ```xml
40 /// <object class="GtkWindow">
41 /// <accel-groups>
42 /// <group name="accelgroup1"/>
43 /// </accel-groups>
44 /// <initial-focus name="thunderclap"/>
45 /// </object>
46 ///
47 /// ...
48 ///
49 /// <object class="GtkAccelGroup" id="accelgroup1"/>
50 /// ```
51 ///
52 /// The GtkWindow implementation of the [`Buildable`][crate::Buildable] interface supports
53 /// setting a child as the titlebar by specifying “titlebar” as the “type”
54 /// attribute of a ``<child>`` element.
55 ///
56 /// # CSS nodes
57 ///
58 ///
59 ///
60 /// **⚠️ The following code is in plain ⚠️**
61 ///
62 /// ```plain
63 /// window.background
64 /// ├── decoration
65 /// ├── <titlebar child>.titlebar [.default-decoration]
66 /// ╰── <child>
67 /// ```
68 ///
69 /// GtkWindow has a main CSS node with name window and style class .background,
70 /// and a subnode with name decoration.
71 ///
72 /// Style classes that are typically used with the main CSS node are .csd (when
73 /// client-side decorations are in use), .solid-csd (for client-side decorations
74 /// without invisible borders), .ssd (used by mutter when rendering server-side
75 /// decorations). GtkWindow also represents window states with the following
76 /// style classes on the main node: .tiled, .maximized, .fullscreen. Specialized
77 /// types of window often add their own discriminating style classes, such as
78 /// .popup or .tooltip.
79 ///
80 /// GtkWindow adds the .titlebar and .default-decoration style classes to the
81 /// widget that is added as a titlebar child.
82 ///
83 /// ## Properties
84 ///
85 ///
86 /// #### `accept-focus`
87 /// Whether the window should receive the input focus.
88 ///
89 /// Readable | Writable
90 ///
91 ///
92 /// #### `application`
93 /// The [`Application`][crate::Application] associated with the window.
94 ///
95 /// The application will be kept alive for at least as long as it
96 /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
97 /// for a way to keep it alive without windows).
98 ///
99 /// Normally, the connection between the application and the window
100 /// will remain until the window is destroyed, but you can explicitly
101 /// remove it by setting the :application property to [`None`].
102 ///
103 /// Readable | Writable
104 ///
105 ///
106 /// #### `attached-to`
107 /// The widget to which this window is attached.
108 /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
109 ///
110 /// Examples of places where specifying this relation is useful are
111 /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
112 /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
113 /// created by [`TreeView`][crate::TreeView].
114 ///
115 /// Readable | Writable | Construct
116 ///
117 ///
118 /// #### `decorated`
119 /// Whether the window should be decorated by the window manager.
120 ///
121 /// Readable | Writable
122 ///
123 ///
124 /// #### `default-height`
125 /// Readable | Writable
126 ///
127 ///
128 /// #### `default-width`
129 /// Readable | Writable
130 ///
131 ///
132 /// #### `deletable`
133 /// Whether the window frame should have a close button.
134 ///
135 /// Readable | Writable
136 ///
137 ///
138 /// #### `destroy-with-parent`
139 /// Readable | Writable
140 ///
141 ///
142 /// #### `focus-on-map`
143 /// Whether the window should receive the input focus when mapped.
144 ///
145 /// Readable | Writable
146 ///
147 ///
148 /// #### `focus-visible`
149 /// Whether 'focus rectangles' are currently visible in this window.
150 ///
151 /// This property is maintained by GTK+ based on user input
152 /// and should not be set by applications.
153 ///
154 /// Readable | Writable
155 ///
156 ///
157 /// #### `gravity`
158 /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
159 /// more details about window gravity.
160 ///
161 /// Readable | Writable
162 ///
163 ///
164 /// #### `has-resize-grip`
165 /// Whether the window has a corner resize grip.
166 ///
167 /// Note that the resize grip is only shown if the window is
168 /// actually resizable and not maximized. Use
169 /// [`resize-grip-visible`][struct@crate::Window#resize-grip-visible] to find out if the resize
170 /// grip is currently shown.
171 ///
172 /// Readable | Writable
173 ///
174 ///
175 /// #### `has-toplevel-focus`
176 /// Readable
177 ///
178 ///
179 /// #### `hide-titlebar-when-maximized`
180 /// Whether the titlebar should be hidden during maximization.
181 ///
182 /// Readable | Writable
183 ///
184 ///
185 /// #### `icon`
186 /// Readable | Writable
187 ///
188 ///
189 /// #### `icon-name`
190 /// The :icon-name property specifies the name of the themed icon to
191 /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
192 ///
193 /// Readable | Writable
194 ///
195 ///
196 /// #### `is-active`
197 /// Readable
198 ///
199 ///
200 /// #### `is-maximized`
201 /// Readable
202 ///
203 ///
204 /// #### `mnemonics-visible`
205 /// Whether mnemonics are currently visible in this window.
206 ///
207 /// This property is maintained by GTK+ based on user input,
208 /// and should not be set by applications.
209 ///
210 /// Readable | Writable
211 ///
212 ///
213 /// #### `modal`
214 /// Readable | Writable
215 ///
216 ///
217 /// #### `resizable`
218 /// Readable | Writable
219 ///
220 ///
221 /// #### `resize-grip-visible`
222 /// Whether a corner resize grip is currently shown.
223 ///
224 /// Readable
225 ///
226 ///
227 /// #### `role`
228 /// Readable | Writable
229 ///
230 ///
231 /// #### `screen`
232 /// Readable | Writable
233 ///
234 ///
235 /// #### `skip-pager-hint`
236 /// Readable | Writable
237 ///
238 ///
239 /// #### `skip-taskbar-hint`
240 /// Readable | Writable
241 ///
242 ///
243 /// #### `startup-id`
244 /// The :startup-id is a write-only property for setting window's
245 /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
246 /// for more details.
247 ///
248 /// Writable
249 ///
250 ///
251 /// #### `title`
252 /// Readable | Writable
253 ///
254 ///
255 /// #### `transient-for`
256 /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
257 /// more details about transient windows.
258 ///
259 /// Readable | Writable | Construct
260 ///
261 ///
262 /// #### `type`
263 /// Readable | Writable | Construct Only
264 ///
265 ///
266 /// #### `type-hint`
267 /// Readable | Writable
268 ///
269 ///
270 /// #### `urgency-hint`
271 /// Readable | Writable
272 ///
273 ///
274 /// #### `window-position`
275 /// Readable | Writable
276 /// <details><summary><h4>Container</h4></summary>
277 ///
278 ///
279 /// #### `border-width`
280 /// Readable | Writable
281 ///
282 ///
283 /// #### `child`
284 /// Writable
285 ///
286 ///
287 /// #### `resize-mode`
288 /// Readable | Writable
289 /// </details>
290 /// <details><summary><h4>Widget</h4></summary>
291 ///
292 ///
293 /// #### `app-paintable`
294 /// Readable | Writable
295 ///
296 ///
297 /// #### `can-default`
298 /// Readable | Writable
299 ///
300 ///
301 /// #### `can-focus`
302 /// Readable | Writable
303 ///
304 ///
305 /// #### `composite-child`
306 /// Readable
307 ///
308 ///
309 /// #### `double-buffered`
310 /// Whether the widget is double buffered.
311 ///
312 /// Readable | Writable
313 ///
314 ///
315 /// #### `events`
316 /// Readable | Writable
317 ///
318 ///
319 /// #### `expand`
320 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
321 ///
322 /// Readable | Writable
323 ///
324 ///
325 /// #### `focus-on-click`
326 /// Whether the widget should grab focus when it is clicked with the mouse.
327 ///
328 /// This property is only relevant for widgets that can take focus.
329 ///
330 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
331 /// GtkComboBox) implemented this property individually.
332 ///
333 /// Readable | Writable
334 ///
335 ///
336 /// #### `halign`
337 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
338 ///
339 /// Readable | Writable
340 ///
341 ///
342 /// #### `has-default`
343 /// Readable | Writable
344 ///
345 ///
346 /// #### `has-focus`
347 /// Readable | Writable
348 ///
349 ///
350 /// #### `has-tooltip`
351 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
352 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
353 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
354 /// whether it will provide a tooltip or not.
355 ///
356 /// Note that setting this property to [`true`] for the first time will change
357 /// the event masks of the GdkWindows of this widget to include leave-notify
358 /// and motion-notify events. This cannot and will not be undone when the
359 /// property is set to [`false`] again.
360 ///
361 /// Readable | Writable
362 ///
363 ///
364 /// #### `height-request`
365 /// Readable | Writable
366 ///
367 ///
368 /// #### `hexpand`
369 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
370 ///
371 /// Readable | Writable
372 ///
373 ///
374 /// #### `hexpand-set`
375 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
376 ///
377 /// Readable | Writable
378 ///
379 ///
380 /// #### `is-focus`
381 /// Readable | Writable
382 ///
383 ///
384 /// #### `margin`
385 /// Sets all four sides' margin at once. If read, returns max
386 /// margin on any side.
387 ///
388 /// Readable | Writable
389 ///
390 ///
391 /// #### `margin-bottom`
392 /// Margin on bottom side of widget.
393 ///
394 /// This property adds margin outside of the widget's normal size
395 /// request, the margin will be added in addition to the size from
396 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
397 ///
398 /// Readable | Writable
399 ///
400 ///
401 /// #### `margin-end`
402 /// Margin on end of widget, horizontally. This property supports
403 /// left-to-right and right-to-left text directions.
404 ///
405 /// This property adds margin outside of the widget's normal size
406 /// request, the margin will be added in addition to the size from
407 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
408 ///
409 /// Readable | Writable
410 ///
411 ///
412 /// #### `margin-left`
413 /// Margin on left side of widget.
414 ///
415 /// This property adds margin outside of the widget's normal size
416 /// request, the margin will be added in addition to the size from
417 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
418 ///
419 /// Readable | Writable
420 ///
421 ///
422 /// #### `margin-right`
423 /// Margin on right side of widget.
424 ///
425 /// This property adds margin outside of the widget's normal size
426 /// request, the margin will be added in addition to the size from
427 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
428 ///
429 /// Readable | Writable
430 ///
431 ///
432 /// #### `margin-start`
433 /// Margin on start of widget, horizontally. This property supports
434 /// left-to-right and right-to-left text directions.
435 ///
436 /// This property adds margin outside of the widget's normal size
437 /// request, the margin will be added in addition to the size from
438 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
439 ///
440 /// Readable | Writable
441 ///
442 ///
443 /// #### `margin-top`
444 /// Margin on top side of widget.
445 ///
446 /// This property adds margin outside of the widget's normal size
447 /// request, the margin will be added in addition to the size from
448 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
449 ///
450 /// Readable | Writable
451 ///
452 ///
453 /// #### `name`
454 /// Readable | Writable
455 ///
456 ///
457 /// #### `no-show-all`
458 /// Readable | Writable
459 ///
460 ///
461 /// #### `opacity`
462 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
463 /// more details about window opacity.
464 ///
465 /// Before 3.8 this was only available in GtkWindow
466 ///
467 /// Readable | Writable
468 ///
469 ///
470 /// #### `parent`
471 /// Readable | Writable
472 ///
473 ///
474 /// #### `receives-default`
475 /// Readable | Writable
476 ///
477 ///
478 /// #### `scale-factor`
479 /// The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
480 /// more details about widget scaling.
481 ///
482 /// Readable
483 ///
484 ///
485 /// #### `sensitive`
486 /// Readable | Writable
487 ///
488 ///
489 /// #### `style`
490 /// The style of the widget, which contains information about how it will look (colors, etc).
491 ///
492 /// Readable | Writable
493 ///
494 ///
495 /// #### `tooltip-markup`
496 /// Sets the text of tooltip to be the given string, which is marked up
497 /// with the [Pango text markup language][PangoMarkupFormat].
498 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
499 ///
500 /// This is a convenience property which will take care of getting the
501 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
502 /// will automatically be set to [`true`] and there will be taken care of
503 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
504 ///
505 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
506 /// are set, the last one wins.
507 ///
508 /// Readable | Writable
509 ///
510 ///
511 /// #### `tooltip-text`
512 /// Sets the text of tooltip to be the given string.
513 ///
514 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
515 ///
516 /// This is a convenience property which will take care of getting the
517 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
518 /// will automatically be set to [`true`] and there will be taken care of
519 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
520 ///
521 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
522 /// are set, the last one wins.
523 ///
524 /// Readable | Writable
525 ///
526 ///
527 /// #### `valign`
528 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
529 ///
530 /// Readable | Writable
531 ///
532 ///
533 /// #### `vexpand`
534 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
535 ///
536 /// Readable | Writable
537 ///
538 ///
539 /// #### `vexpand-set`
540 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
541 ///
542 /// Readable | Writable
543 ///
544 ///
545 /// #### `visible`
546 /// Readable | Writable
547 ///
548 ///
549 /// #### `width-request`
550 /// Readable | Writable
551 ///
552 ///
553 /// #### `window`
554 /// The widget's window if it is realized, [`None`] otherwise.
555 ///
556 /// Readable
557 /// </details>
558 ///
559 /// ## Signals
560 ///
561 ///
562 /// #### `activate-default`
563 /// The ::activate-default signal is a
564 /// [keybinding signal][GtkBindingSignal]
565 /// which gets emitted when the user activates the default widget
566 /// of `window`.
567 ///
568 /// Action
569 ///
570 ///
571 /// #### `activate-focus`
572 /// The ::activate-focus signal is a
573 /// [keybinding signal][GtkBindingSignal]
574 /// which gets emitted when the user activates the currently
575 /// focused widget of `window`.
576 ///
577 /// Action
578 ///
579 ///
580 /// #### `enable-debugging`
581 /// The ::enable-debugging signal is a [keybinding signal][GtkBindingSignal]
582 /// which gets emitted when the user enables or disables interactive
583 /// debugging. When `toggle` is [`true`], interactive debugging is toggled
584 /// on or off, when it is [`false`], the debugger will be pointed at the
585 /// widget under the pointer.
586 ///
587 /// The default bindings for this signal are Ctrl-Shift-I
588 /// and Ctrl-Shift-D.
589 ///
590 /// Action
591 ///
592 ///
593 /// #### `keys-changed`
594 /// The ::keys-changed signal gets emitted when the set of accelerators
595 /// or mnemonics that are associated with `window` changes.
596 ///
597 ///
598 ///
599 ///
600 /// #### `set-focus`
601 /// This signal is emitted whenever the currently focused widget in
602 /// this window changes.
603 ///
604 ///
605 /// <details><summary><h4>Container</h4></summary>
606 ///
607 ///
608 /// #### `add`
609 ///
610 ///
611 ///
612 /// #### `check-resize`
613 ///
614 ///
615 ///
616 /// #### `remove`
617 ///
618 ///
619 ///
620 /// #### `set-focus-child`
621 ///
622 /// </details>
623 /// <details><summary><h4>Widget</h4></summary>
624 ///
625 ///
626 /// #### `accel-closures-changed`
627 ///
628 ///
629 ///
630 /// #### `button-press-event`
631 /// The ::button-press-event signal will be emitted when a button
632 /// (typically from a mouse) is pressed.
633 ///
634 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
635 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
636 ///
637 /// This signal will be sent to the grab widget if there is one.
638 ///
639 ///
640 ///
641 ///
642 /// #### `button-release-event`
643 /// The ::button-release-event signal will be emitted when a button
644 /// (typically from a mouse) is released.
645 ///
646 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
647 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
648 ///
649 /// This signal will be sent to the grab widget if there is one.
650 ///
651 ///
652 ///
653 ///
654 /// #### `can-activate-accel`
655 /// Determines whether an accelerator that activates the signal
656 /// identified by `signal_id` can currently be activated.
657 /// This signal is present to allow applications and derived
658 /// widgets to override the default [`Widget`][crate::Widget] handling
659 /// for determining whether an accelerator can be activated.
660 ///
661 ///
662 ///
663 ///
664 /// #### `child-notify`
665 /// The ::child-notify signal is emitted for each
666 /// [child property][child-properties] that has
667 /// changed on an object. The signal's detail holds the property name.
668 ///
669 /// Detailed
670 ///
671 ///
672 /// #### `composited-changed`
673 /// The ::composited-changed signal is emitted when the composited
674 /// status of `widgets` screen changes.
675 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
676 ///
677 /// Action
678 ///
679 ///
680 /// #### `configure-event`
681 /// The ::configure-event signal will be emitted when the size, position or
682 /// stacking of the `widget`'s window has changed.
683 ///
684 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
685 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
686 /// automatically for all new windows.
687 ///
688 ///
689 ///
690 ///
691 /// #### `damage-event`
692 /// Emitted when a redirected window belonging to `widget` gets drawn into.
693 /// The region/area members of the event shows what area of the redirected
694 /// drawable was drawn into.
695 ///
696 ///
697 ///
698 ///
699 /// #### `delete-event`
700 /// The ::delete-event signal is emitted if a user requests that
701 /// a toplevel window is closed. The default handler for this signal
702 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
703 /// this signal will cause the window to be hidden instead, so that
704 /// it can later be shown again without reconstructing it.
705 ///
706 ///
707 ///
708 ///
709 /// #### `destroy`
710 /// Signals that all holders of a reference to the widget should release
711 /// the reference that they hold. May result in finalization of the widget
712 /// if all references are released.
713 ///
714 /// This signal is not suitable for saving widget state.
715 ///
716 ///
717 ///
718 ///
719 /// #### `destroy-event`
720 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
721 /// You rarely get this signal, because most widgets disconnect themselves
722 /// from their window before they destroy it, so no widget owns the
723 /// window at destroy time.
724 ///
725 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
726 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
727 /// automatically for all new windows.
728 ///
729 ///
730 ///
731 ///
732 /// #### `direction-changed`
733 /// The ::direction-changed signal is emitted when the text direction
734 /// of a widget changes.
735 ///
736 ///
737 ///
738 ///
739 /// #### `drag-begin`
740 /// The ::drag-begin signal is emitted on the drag source when a drag is
741 /// started. A typical reason to connect to this signal is to set up a
742 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
743 ///
744 /// Note that some widgets set up a drag icon in the default handler of
745 /// this signal, so you may have to use `g_signal_connect_after()` to
746 /// override what the default handler did.
747 ///
748 ///
749 ///
750 ///
751 /// #### `drag-data-delete`
752 /// The ::drag-data-delete signal is emitted on the drag source when a drag
753 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
754 /// handler is responsible for deleting the data that has been dropped. What
755 /// "delete" means depends on the context of the drag operation.
756 ///
757 ///
758 ///
759 ///
760 /// #### `drag-data-get`
761 /// The ::drag-data-get signal is emitted on the drag source when the drop
762 /// site requests the data which is dragged. It is the responsibility of
763 /// the signal handler to fill `data` with the data in the format which
764 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
765 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
766 ///
767 ///
768 ///
769 ///
770 /// #### `drag-data-received`
771 /// The ::drag-data-received signal is emitted on the drop site when the
772 /// dragged data has been received. If the data was received in order to
773 /// determine whether the drop will be accepted, the handler is expected
774 /// to call `gdk_drag_status()` and not finish the drag.
775 /// If the data was received in response to a [`drag-drop`][struct@crate::Widget#drag-drop] signal
776 /// (and this is the last target to be received), the handler for this
777 /// signal is expected to process the received data and then call
778 /// `gtk_drag_finish()`, setting the `success` parameter depending on
779 /// whether the data was processed successfully.
780 ///
781 /// Applications must create some means to determine why the signal was emitted
782 /// and therefore whether to call `gdk_drag_status()` or `gtk_drag_finish()`.
783 ///
784 /// The handler may inspect the selected action with
785 /// [`DragContext::selected_action()`][crate::gdk::DragContext::selected_action()] before calling
786 /// `gtk_drag_finish()`, e.g. to implement [`gdk::DragAction::ASK`][crate::gdk::DragAction::ASK] as
787 /// shown in the following example:
788 ///
789 ///
790 /// **⚠️ The following code is in C ⚠️**
791 ///
792 /// ```C
793 /// void
794 /// drag_data_received (GtkWidget *widget,
795 /// GdkDragContext *context,
796 /// gint x,
797 /// gint y,
798 /// GtkSelectionData *data,
799 /// guint info,
800 /// guint time)
801 /// {
802 /// if ((data->length >= 0) && (data->format == 8))
803 /// {
804 /// GdkDragAction action;
805 ///
806 /// // handle data here
807 ///
808 /// action = gdk_drag_context_get_selected_action (context);
809 /// if (action == GDK_ACTION_ASK)
810 /// {
811 /// GtkWidget *dialog;
812 /// gint response;
813 ///
814 /// dialog = gtk_message_dialog_new (NULL,
815 /// GTK_DIALOG_MODAL |
816 /// GTK_DIALOG_DESTROY_WITH_PARENT,
817 /// GTK_MESSAGE_INFO,
818 /// GTK_BUTTONS_YES_NO,
819 /// "Move the data ?\n");
820 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
821 /// gtk_widget_destroy (dialog);
822 ///
823 /// if (response == GTK_RESPONSE_YES)
824 /// action = GDK_ACTION_MOVE;
825 /// else
826 /// action = GDK_ACTION_COPY;
827 /// }
828 ///
829 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
830 /// }
831 /// else
832 /// gtk_drag_finish (context, FALSE, FALSE, time);
833 /// }
834 /// ```
835 ///
836 ///
837 ///
838 ///
839 /// #### `drag-drop`
840 /// The ::drag-drop signal is emitted on the drop site when the user drops
841 /// the data onto the widget. The signal handler must determine whether
842 /// the cursor position is in a drop zone or not. If it is not in a drop
843 /// zone, it returns [`false`] and no further processing is necessary.
844 /// Otherwise, the handler returns [`true`]. In this case, the handler must
845 /// ensure that `gtk_drag_finish()` is called to let the source know that
846 /// the drop is done. The call to `gtk_drag_finish()` can be done either
847 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
848 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
849 /// or more of the supported targets.
850 ///
851 ///
852 ///
853 ///
854 /// #### `drag-end`
855 /// The ::drag-end signal is emitted on the drag source when a drag is
856 /// finished. A typical reason to connect to this signal is to undo
857 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
858 ///
859 ///
860 ///
861 ///
862 /// #### `drag-failed`
863 /// The ::drag-failed signal is emitted on the drag source when a drag has
864 /// failed. The signal handler may hook custom code to handle a failed DnD
865 /// operation based on the type of error, it returns [`true`] is the failure has
866 /// been already handled (not showing the default "drag operation failed"
867 /// animation), otherwise it returns [`false`].
868 ///
869 ///
870 ///
871 ///
872 /// #### `drag-leave`
873 /// The ::drag-leave signal is emitted on the drop site when the cursor
874 /// leaves the widget. A typical reason to connect to this signal is to
875 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
876 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
877 ///
878 ///
879 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
880 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
881 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
882 ///
883 ///
884 ///
885 ///
886 /// #### `drag-motion`
887 /// The ::drag-motion signal is emitted on the drop site when the user
888 /// moves the cursor over the widget during a drag. The signal handler
889 /// must determine whether the cursor position is in a drop zone or not.
890 /// If it is not in a drop zone, it returns [`false`] and no further processing
891 /// is necessary. Otherwise, the handler returns [`true`]. In this case, the
892 /// handler is responsible for providing the necessary information for
893 /// displaying feedback to the user, by calling `gdk_drag_status()`.
894 ///
895 /// If the decision whether the drop will be accepted or rejected can't be
896 /// made based solely on the cursor position and the type of the data, the
897 /// handler may inspect the dragged data by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] and
898 /// defer the `gdk_drag_status()` call to the [`drag-data-received`][struct@crate::Widget#drag-data-received]
899 /// handler. Note that you must pass [`DestDefaults::DROP`][crate::DestDefaults::DROP],
900 /// [`DestDefaults::MOTION`][crate::DestDefaults::MOTION] or [`DestDefaults::ALL`][crate::DestDefaults::ALL] to [`WidgetExtManual::drag_dest_set()`][crate::prelude::WidgetExtManual::drag_dest_set()]
901 /// when using the drag-motion signal that way.
902 ///
903 /// Also note that there is no drag-enter signal. The drag receiver has to
904 /// keep track of whether he has received any drag-motion signals since the
905 /// last [`drag-leave`][struct@crate::Widget#drag-leave] and if not, treat the drag-motion signal as
906 /// an "enter" signal. Upon an "enter", the handler will typically highlight
907 /// the drop site with [`WidgetExt::drag_highlight()`][crate::prelude::WidgetExt::drag_highlight()].
908 ///
909 ///
910 /// **⚠️ The following code is in C ⚠️**
911 ///
912 /// ```C
913 /// static void
914 /// drag_motion (GtkWidget *widget,
915 /// GdkDragContext *context,
916 /// gint x,
917 /// gint y,
918 /// guint time)
919 /// {
920 /// GdkAtom target;
921 ///
922 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
923 ///
924 /// if (!private_data->drag_highlight)
925 /// {
926 /// private_data->drag_highlight = 1;
927 /// gtk_drag_highlight (widget);
928 /// }
929 ///
930 /// target = gtk_drag_dest_find_target (widget, context, NULL);
931 /// if (target == GDK_NONE)
932 /// gdk_drag_status (context, 0, time);
933 /// else
934 /// {
935 /// private_data->pending_status
936 /// = gdk_drag_context_get_suggested_action (context);
937 /// gtk_drag_get_data (widget, context, target, time);
938 /// }
939 ///
940 /// return TRUE;
941 /// }
942 ///
943 /// static void
944 /// drag_data_received (GtkWidget *widget,
945 /// GdkDragContext *context,
946 /// gint x,
947 /// gint y,
948 /// GtkSelectionData *selection_data,
949 /// guint info,
950 /// guint time)
951 /// {
952 /// PrivateData *private_data = GET_PRIVATE_DATA (widget);
953 ///
954 /// if (private_data->suggested_action)
955 /// {
956 /// private_data->suggested_action = 0;
957 ///
958 /// // We are getting this data due to a request in drag_motion,
959 /// // rather than due to a request in drag_drop, so we are just
960 /// // supposed to call gdk_drag_status(), not actually paste in
961 /// // the data.
962 ///
963 /// str = gtk_selection_data_get_text (selection_data);
964 /// if (!data_is_acceptable (str))
965 /// gdk_drag_status (context, 0, time);
966 /// else
967 /// gdk_drag_status (context,
968 /// private_data->suggested_action,
969 /// time);
970 /// }
971 /// else
972 /// {
973 /// // accept the drop
974 /// }
975 /// }
976 /// ```
977 ///
978 ///
979 ///
980 ///
981 /// #### `draw`
982 /// This signal is emitted when a widget is supposed to render itself.
983 /// The `widget`'s top left corner must be painted at the origin of
984 /// the passed in context and be sized to the values returned by
985 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
986 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
987 ///
988 /// Signal handlers connected to this signal can modify the cairo
989 /// context passed as `cr` in any way they like and don't need to
990 /// restore it. The signal emission takes care of calling `cairo_save()`
991 /// before and `cairo_restore()` after invoking the handler.
992 ///
993 /// The signal handler will get a `cr` with a clip region already set to the
994 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
995 /// widgets that want to avoid redrawing themselves completely can get the full
996 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
997 /// get a finer-grained representation of the dirty region with
998 /// `cairo_copy_clip_rectangle_list()`.
999 ///
1000 ///
1001 ///
1002 ///
1003 /// #### `enter-notify-event`
1004 /// The ::enter-notify-event will be emitted when the pointer enters
1005 /// the `widget`'s window.
1006 ///
1007 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1008 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
1009 ///
1010 /// This signal will be sent to the grab widget if there is one.
1011 ///
1012 ///
1013 ///
1014 ///
1015 /// #### `event`
1016 /// The GTK+ main loop will emit three signals for each GDK event delivered
1017 /// to a widget: one generic ::event signal, another, more specific,
1018 /// signal that matches the type of event delivered (e.g.
1019 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
1020 /// [`event-after`][struct@crate::Widget#event-after] signal.
1021 ///
1022 ///
1023 ///
1024 ///
1025 /// #### `event-after`
1026 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
1027 /// the second more specific signal, ::event-after will be emitted
1028 /// regardless of the previous two signals handlers return values.
1029 ///
1030 ///
1031 ///
1032 ///
1033 /// #### `focus`
1034 ///
1035 ///
1036 ///
1037 /// #### `focus-in-event`
1038 /// The ::focus-in-event signal will be emitted when the keyboard focus
1039 /// enters the `widget`'s window.
1040 ///
1041 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1042 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1043 ///
1044 ///
1045 ///
1046 ///
1047 /// #### `focus-out-event`
1048 /// The ::focus-out-event signal will be emitted when the keyboard focus
1049 /// leaves the `widget`'s window.
1050 ///
1051 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1052 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
1053 ///
1054 ///
1055 ///
1056 ///
1057 /// #### `grab-broken-event`
1058 /// Emitted when a pointer or keyboard grab on a window belonging
1059 /// to `widget` gets broken.
1060 ///
1061 /// On X11, this happens when the grab window becomes unviewable
1062 /// (i.e. it or one of its ancestors is unmapped), or if the same
1063 /// application grabs the pointer or keyboard again.
1064 ///
1065 ///
1066 ///
1067 ///
1068 /// #### `grab-focus`
1069 /// Action
1070 ///
1071 ///
1072 /// #### `grab-notify`
1073 /// The ::grab-notify signal is emitted when a widget becomes
1074 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
1075 /// another widget, or when it becomes unshadowed due to a grab
1076 /// being removed.
1077 ///
1078 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
1079 /// grab widget in the grab stack of its window group is not
1080 /// its ancestor.
1081 ///
1082 ///
1083 ///
1084 ///
1085 /// #### `hide`
1086 /// The ::hide signal is emitted when `widget` is hidden, for example with
1087 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
1088 ///
1089 ///
1090 ///
1091 ///
1092 /// #### `hierarchy-changed`
1093 /// The ::hierarchy-changed signal is emitted when the
1094 /// anchored state of a widget changes. A widget is
1095 /// “anchored” when its toplevel
1096 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
1097 /// a widget changes from un-anchored to anchored or vice-versa.
1098 ///
1099 ///
1100 ///
1101 ///
1102 /// #### `key-press-event`
1103 /// The ::key-press-event signal is emitted when a key is pressed. The signal
1104 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
1105 ///
1106 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1107 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
1108 ///
1109 /// This signal will be sent to the grab widget if there is one.
1110 ///
1111 ///
1112 ///
1113 ///
1114 /// #### `key-release-event`
1115 /// The ::key-release-event signal is emitted when a key is released.
1116 ///
1117 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1118 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
1119 ///
1120 /// This signal will be sent to the grab widget if there is one.
1121 ///
1122 ///
1123 ///
1124 ///
1125 /// #### `keynav-failed`
1126 /// Gets emitted if keyboard navigation fails.
1127 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
1128 ///
1129 ///
1130 ///
1131 ///
1132 /// #### `leave-notify-event`
1133 /// The ::leave-notify-event will be emitted when the pointer leaves
1134 /// the `widget`'s window.
1135 ///
1136 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1137 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
1138 ///
1139 /// This signal will be sent to the grab widget if there is one.
1140 ///
1141 ///
1142 ///
1143 ///
1144 /// #### `map`
1145 /// The ::map signal is emitted when `widget` is going to be mapped, that is
1146 /// when the widget is visible (which is controlled with
1147 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
1148 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
1149 /// be emitted.
1150 ///
1151 /// The ::map signal can be used to determine whether a widget will be drawn,
1152 /// for instance it can resume an animation that was stopped during the
1153 /// emission of [`unmap`][struct@crate::Widget#unmap].
1154 ///
1155 ///
1156 ///
1157 ///
1158 /// #### `map-event`
1159 /// The ::map-event signal will be emitted when the `widget`'s window is
1160 /// mapped. A window is mapped when it becomes visible on the screen.
1161 ///
1162 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1163 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1164 /// automatically for all new windows.
1165 ///
1166 ///
1167 ///
1168 ///
1169 /// #### `mnemonic-activate`
1170 /// The default handler for this signal activates `widget` if `group_cycling`
1171 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
1172 ///
1173 ///
1174 ///
1175 ///
1176 /// #### `motion-notify-event`
1177 /// The ::motion-notify-event signal is emitted when the pointer moves
1178 /// over the widget's [`gdk::Window`][crate::gdk::Window].
1179 ///
1180 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
1181 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
1182 ///
1183 /// This signal will be sent to the grab widget if there is one.
1184 ///
1185 ///
1186 ///
1187 ///
1188 /// #### `move-focus`
1189 /// Action
1190 ///
1191 ///
1192 /// #### `parent-set`
1193 /// The ::parent-set signal is emitted when a new parent
1194 /// has been set on a widget.
1195 ///
1196 ///
1197 ///
1198 ///
1199 /// #### `popup-menu`
1200 /// This signal gets emitted whenever a widget should pop up a context
1201 /// menu. This usually happens through the standard key binding mechanism;
1202 /// by pressing a certain key while a widget is focused, the user can cause
1203 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
1204 /// a menu with clipboard commands. See the
1205 /// [Popup Menu Migration Checklist][checklist-popup-menu]
1206 /// for an example of how to use this signal.
1207 ///
1208 /// Action
1209 ///
1210 ///
1211 /// #### `property-notify-event`
1212 /// The ::property-notify-event signal will be emitted when a property on
1213 /// the `widget`'s window has been changed or deleted.
1214 ///
1215 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1216 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
1217 ///
1218 ///
1219 ///
1220 ///
1221 /// #### `proximity-in-event`
1222 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1223 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
1224 ///
1225 /// This signal will be sent to the grab widget if there is one.
1226 ///
1227 ///
1228 ///
1229 ///
1230 /// #### `proximity-out-event`
1231 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1232 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
1233 ///
1234 /// This signal will be sent to the grab widget if there is one.
1235 ///
1236 ///
1237 ///
1238 ///
1239 /// #### `query-tooltip`
1240 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
1241 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
1242 /// focus in keyboard mode.
1243 ///
1244 /// Using the given coordinates, the signal handler should determine
1245 /// whether a tooltip should be shown for `widget`. If this is the case
1246 /// [`true`] should be returned, [`false`] otherwise. Note that if
1247 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
1248 /// should not be used.
1249 ///
1250 /// The signal handler is free to manipulate `tooltip` with the therefore
1251 /// destined function calls.
1252 ///
1253 ///
1254 ///
1255 ///
1256 /// #### `realize`
1257 /// The ::realize signal is emitted when `widget` is associated with a
1258 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
1259 /// widget has been mapped (that is, it is going to be drawn).
1260 ///
1261 ///
1262 ///
1263 ///
1264 /// #### `screen-changed`
1265 /// The ::screen-changed signal gets emitted when the
1266 /// screen of a widget has changed.
1267 ///
1268 ///
1269 ///
1270 ///
1271 /// #### `scroll-event`
1272 /// The ::scroll-event signal is emitted when a button in the 4 to 7
1273 /// range is pressed. Wheel mice are usually configured to generate
1274 /// button press events for buttons 4 and 5 when the wheel is turned.
1275 ///
1276 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1277 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
1278 ///
1279 /// This signal will be sent to the grab widget if there is one.
1280 ///
1281 ///
1282 ///
1283 ///
1284 /// #### `selection-clear-event`
1285 /// The ::selection-clear-event signal will be emitted when the
1286 /// the `widget`'s window has lost ownership of a selection.
1287 ///
1288 ///
1289 ///
1290 ///
1291 /// #### `selection-get`
1292 ///
1293 ///
1294 ///
1295 /// #### `selection-notify-event`
1296 ///
1297 ///
1298 ///
1299 /// #### `selection-received`
1300 ///
1301 ///
1302 ///
1303 /// #### `selection-request-event`
1304 /// The ::selection-request-event signal will be emitted when
1305 /// another client requests ownership of the selection owned by
1306 /// the `widget`'s window.
1307 ///
1308 ///
1309 ///
1310 ///
1311 /// #### `show`
1312 /// The ::show signal is emitted when `widget` is shown, for example with
1313 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
1314 ///
1315 ///
1316 ///
1317 ///
1318 /// #### `show-help`
1319 /// Action
1320 ///
1321 ///
1322 /// #### `size-allocate`
1323 ///
1324 ///
1325 ///
1326 /// #### `state-changed`
1327 /// The ::state-changed signal is emitted when the widget state changes.
1328 /// See `gtk_widget_get_state()`.
1329 ///
1330 ///
1331 ///
1332 ///
1333 /// #### `state-flags-changed`
1334 /// The ::state-flags-changed signal is emitted when the widget state
1335 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
1336 ///
1337 ///
1338 ///
1339 ///
1340 /// #### `style-set`
1341 /// The ::style-set signal is emitted when a new style has been set
1342 /// on a widget. Note that style-modifying functions like
1343 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
1344 ///
1345 /// Note that this signal is emitted for changes to the deprecated
1346 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
1347 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
1348 ///
1349 ///
1350 ///
1351 ///
1352 /// #### `style-updated`
1353 /// The ::style-updated signal is a convenience signal that is emitted when the
1354 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
1355 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
1356 ///
1357 /// Note that style-modifying functions like `gtk_widget_override_color()` also
1358 /// cause this signal to be emitted.
1359 ///
1360 ///
1361 ///
1362 ///
1363 /// #### `touch-event`
1364 ///
1365 ///
1366 ///
1367 /// #### `unmap`
1368 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
1369 /// means that either it or any of its parents up to the toplevel widget have
1370 /// been set as hidden.
1371 ///
1372 /// As ::unmap indicates that a widget will not be shown any longer, it can be
1373 /// used to, for example, stop an animation on the widget.
1374 ///
1375 ///
1376 ///
1377 ///
1378 /// #### `unmap-event`
1379 /// The ::unmap-event signal will be emitted when the `widget`'s window is
1380 /// unmapped. A window is unmapped when it becomes invisible on the screen.
1381 ///
1382 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1383 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
1384 /// automatically for all new windows.
1385 ///
1386 ///
1387 ///
1388 ///
1389 /// #### `unrealize`
1390 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
1391 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
1392 /// called or the widget has been unmapped (that is, it is going to be
1393 /// hidden).
1394 ///
1395 ///
1396 ///
1397 ///
1398 /// #### `visibility-notify-event`
1399 /// The ::visibility-notify-event will be emitted when the `widget`'s
1400 /// window is obscured or unobscured.
1401 ///
1402 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
1403 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
1404 ///
1405 ///
1406 ///
1407 ///
1408 /// #### `window-state-event`
1409 /// The ::window-state-event will be emitted when the state of the
1410 /// toplevel window associated to the `widget` changes.
1411 ///
1412 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
1413 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
1414 /// this mask automatically for all new windows.
1415 ///
1416 ///
1417 /// </details>
1418 ///
1419 /// # Implements
1420 ///
1421 /// [`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], [`GtkWindowExtManual`][trait@crate::prelude::GtkWindowExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
1422 #[doc(alias = "GtkWindow")]
1423 pub struct Window(Object<ffi::GtkWindow, ffi::GtkWindowClass>) @extends Bin, Container, Widget, @implements Buildable;
1424
1425 match fn {
1426 type_ => || ffi::gtk_window_get_type(),
1427 }
1428}
1429
1430impl Window {
1431 pub const NONE: Option<&'static Window> = None;
1432
1433 /// Creates a new [`Window`][crate::Window], which is a toplevel window that can
1434 /// contain other widgets. Nearly always, the type of the window should
1435 /// be [`WindowType::Toplevel`][crate::WindowType::Toplevel]. If you’re implementing something like a
1436 /// popup menu from scratch (which is a bad idea, just use [`Menu`][crate::Menu]),
1437 /// you might use [`WindowType::Popup`][crate::WindowType::Popup]. [`WindowType::Popup`][crate::WindowType::Popup] is not for
1438 /// dialogs, though in some other toolkits dialogs are called “popups”.
1439 /// In GTK+, [`WindowType::Popup`][crate::WindowType::Popup] means a pop-up menu or pop-up tooltip.
1440 /// On X11, popup windows are not controlled by the
1441 /// [window manager][gtk-X11-arch].
1442 ///
1443 /// If you simply want an undecorated window (no window borders), use
1444 /// [`GtkWindowExt::set_decorated()`][crate::prelude::GtkWindowExt::set_decorated()], don’t use [`WindowType::Popup`][crate::WindowType::Popup].
1445 ///
1446 /// All top-level windows created by [`new()`][Self::new()] are stored in
1447 /// an internal top-level window list. This list can be obtained from
1448 /// [`list_toplevels()`][Self::list_toplevels()]. Due to Gtk+ keeping a reference to
1449 /// the window internally, [`new()`][Self::new()] does not return a reference
1450 /// to the caller.
1451 ///
1452 /// To delete a [`Window`][crate::Window], call `gtk_widget_destroy()`.
1453 /// ## `type_`
1454 /// type of window
1455 ///
1456 /// # Returns
1457 ///
1458 /// a new [`Window`][crate::Window].
1459 #[doc(alias = "gtk_window_new")]
1460 pub fn new(type_: WindowType) -> Window {
1461 assert_initialized_main_thread!();
1462 unsafe { Widget::from_glib_none(ffi::gtk_window_new(type_.into_glib())).unsafe_cast() }
1463 }
1464
1465 // rustdoc-stripper-ignore-next
1466 /// Creates a new builder-pattern struct instance to construct [`Window`] objects.
1467 ///
1468 /// This method returns an instance of [`WindowBuilder`](crate::builders::WindowBuilder) which can be used to create [`Window`] objects.
1469 pub fn builder() -> WindowBuilder {
1470 WindowBuilder::new()
1471 }
1472
1473 /// Gets the value set by [`set_default_icon_list()`][Self::set_default_icon_list()].
1474 /// The list is a copy and should be freed with `g_list_free()`,
1475 /// but the pixbufs in the list have not had their reference count
1476 /// incremented.
1477 ///
1478 /// # Returns
1479 ///
1480 /// copy of default icon list
1481 #[doc(alias = "gtk_window_get_default_icon_list")]
1482 #[doc(alias = "get_default_icon_list")]
1483 pub fn default_icon_list() -> Vec<gdk_pixbuf::Pixbuf> {
1484 assert_initialized_main_thread!();
1485 unsafe {
1486 FromGlibPtrContainer::from_glib_container(ffi::gtk_window_get_default_icon_list())
1487 }
1488 }
1489
1490 /// Returns the fallback icon name for windows that has been set
1491 /// with [`set_default_icon_name()`][Self::set_default_icon_name()]. The returned
1492 /// string is owned by GTK+ and should not be modified. It
1493 /// is only valid until the next call to
1494 /// [`set_default_icon_name()`][Self::set_default_icon_name()].
1495 ///
1496 /// # Returns
1497 ///
1498 /// the fallback icon name for windows
1499 #[doc(alias = "gtk_window_get_default_icon_name")]
1500 #[doc(alias = "get_default_icon_name")]
1501 pub fn default_icon_name() -> Option<glib::GString> {
1502 assert_initialized_main_thread!();
1503 unsafe { from_glib_none(ffi::gtk_window_get_default_icon_name()) }
1504 }
1505
1506 /// Returns a list of all existing toplevel windows. The widgets
1507 /// in the list are not individually referenced. If you want
1508 /// to iterate through the list and perform actions involving
1509 /// callbacks that might destroy the widgets, you must call
1510 /// `g_list_foreach (result, (GFunc)g_object_ref, NULL)` first, and
1511 /// then unref all the widgets afterwards.
1512 ///
1513 /// # Returns
1514 ///
1515 /// list of toplevel widgets
1516 #[doc(alias = "gtk_window_list_toplevels")]
1517 pub fn list_toplevels() -> Vec<Widget> {
1518 assert_initialized_main_thread!();
1519 unsafe { FromGlibPtrContainer::from_glib_container(ffi::gtk_window_list_toplevels()) }
1520 }
1521
1522 /// By default, after showing the first [`Window`][crate::Window], GTK+ calls
1523 /// `gdk_notify_startup_complete()`. Call this function to disable
1524 /// the automatic startup notification. You might do this if your
1525 /// first window is a splash screen, and you want to delay notification
1526 /// until after your real main window has been shown, for example.
1527 ///
1528 /// In that example, you would disable startup notification
1529 /// temporarily, show your splash screen, then re-enable it so that
1530 /// showing the main window would automatically result in notification.
1531 /// ## `setting`
1532 /// [`true`] to automatically do startup notification
1533 #[doc(alias = "gtk_window_set_auto_startup_notification")]
1534 pub fn set_auto_startup_notification(setting: bool) {
1535 assert_initialized_main_thread!();
1536 unsafe {
1537 ffi::gtk_window_set_auto_startup_notification(setting.into_glib());
1538 }
1539 }
1540
1541 /// Sets an icon to be used as fallback for windows that haven't
1542 /// had [`GtkWindowExt::set_icon()`][crate::prelude::GtkWindowExt::set_icon()] called on them from a pixbuf.
1543 /// ## `icon`
1544 /// the icon
1545 #[doc(alias = "gtk_window_set_default_icon")]
1546 pub fn set_default_icon(icon: &gdk_pixbuf::Pixbuf) {
1547 assert_initialized_main_thread!();
1548 unsafe {
1549 ffi::gtk_window_set_default_icon(icon.to_glib_none().0);
1550 }
1551 }
1552
1553 /// Sets an icon to be used as fallback for windows that haven't
1554 /// had [`GtkWindowExt::set_icon_list()`][crate::prelude::GtkWindowExt::set_icon_list()] called on them from a file
1555 /// on disk. Warns on failure if `err` is [`None`].
1556 /// ## `filename`
1557 /// location of icon file
1558 ///
1559 /// # Returns
1560 ///
1561 /// [`true`] if setting the icon succeeded.
1562 #[doc(alias = "gtk_window_set_default_icon_from_file")]
1563 pub fn set_default_icon_from_file(
1564 filename: impl AsRef<std::path::Path>,
1565 ) -> Result<(), glib::Error> {
1566 assert_initialized_main_thread!();
1567 unsafe {
1568 let mut error = std::ptr::null_mut();
1569 let is_ok = ffi::gtk_window_set_default_icon_from_file(
1570 filename.as_ref().to_glib_none().0,
1571 &mut error,
1572 );
1573 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
1574 if error.is_null() {
1575 Ok(())
1576 } else {
1577 Err(from_glib_full(error))
1578 }
1579 }
1580 }
1581
1582 /// Sets an icon list to be used as fallback for windows that haven't
1583 /// had [`GtkWindowExt::set_icon_list()`][crate::prelude::GtkWindowExt::set_icon_list()] called on them to set up a
1584 /// window-specific icon list. This function allows you to set up the
1585 /// icon for all windows in your app at once.
1586 ///
1587 /// See [`GtkWindowExt::set_icon_list()`][crate::prelude::GtkWindowExt::set_icon_list()] for more details.
1588 /// ## `list`
1589 /// a list of [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf]
1590 #[doc(alias = "gtk_window_set_default_icon_list")]
1591 pub fn set_default_icon_list(list: &[gdk_pixbuf::Pixbuf]) {
1592 assert_initialized_main_thread!();
1593 unsafe {
1594 ffi::gtk_window_set_default_icon_list(list.to_glib_container().0);
1595 }
1596 }
1597
1598 /// Sets an icon to be used as fallback for windows that haven't
1599 /// had [`GtkWindowExt::set_icon_list()`][crate::prelude::GtkWindowExt::set_icon_list()] called on them from a named
1600 /// themed icon, see [`GtkWindowExt::set_icon_name()`][crate::prelude::GtkWindowExt::set_icon_name()].
1601 /// ## `name`
1602 /// the name of the themed icon
1603 #[doc(alias = "gtk_window_set_default_icon_name")]
1604 pub fn set_default_icon_name(name: &str) {
1605 assert_initialized_main_thread!();
1606 unsafe {
1607 ffi::gtk_window_set_default_icon_name(name.to_glib_none().0);
1608 }
1609 }
1610
1611 /// Opens or closes the [interactive debugger][interactive-debugging],
1612 /// which offers access to the widget hierarchy of the application
1613 /// and to useful debugging tools.
1614 /// ## `enable`
1615 /// [`true`] to enable interactive debugging
1616 #[doc(alias = "gtk_window_set_interactive_debugging")]
1617 pub fn set_interactive_debugging(enable: bool) {
1618 assert_initialized_main_thread!();
1619 unsafe {
1620 ffi::gtk_window_set_interactive_debugging(enable.into_glib());
1621 }
1622 }
1623}
1624
1625impl Default for Window {
1626 fn default() -> Self {
1627 glib::object::Object::new::<Self>()
1628 }
1629}
1630
1631// rustdoc-stripper-ignore-next
1632/// A [builder-pattern] type to construct [`Window`] objects.
1633///
1634/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
1635#[must_use = "The builder must be built to be used"]
1636pub struct WindowBuilder {
1637 builder: glib::object::ObjectBuilder<'static, Window>,
1638}
1639
1640impl WindowBuilder {
1641 fn new() -> Self {
1642 Self {
1643 builder: glib::object::Object::builder(),
1644 }
1645 }
1646
1647 /// Whether the window should receive the input focus.
1648 pub fn accept_focus(self, accept_focus: bool) -> Self {
1649 Self {
1650 builder: self.builder.property("accept-focus", accept_focus),
1651 }
1652 }
1653
1654 /// The [`Application`][crate::Application] associated with the window.
1655 ///
1656 /// The application will be kept alive for at least as long as it
1657 /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
1658 /// for a way to keep it alive without windows).
1659 ///
1660 /// Normally, the connection between the application and the window
1661 /// will remain until the window is destroyed, but you can explicitly
1662 /// remove it by setting the :application property to [`None`].
1663 pub fn application(self, application: &impl IsA<Application>) -> Self {
1664 Self {
1665 builder: self
1666 .builder
1667 .property("application", application.clone().upcast()),
1668 }
1669 }
1670
1671 /// The widget to which this window is attached.
1672 /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
1673 ///
1674 /// Examples of places where specifying this relation is useful are
1675 /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
1676 /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
1677 /// created by [`TreeView`][crate::TreeView].
1678 pub fn attached_to(self, attached_to: &impl IsA<Widget>) -> Self {
1679 Self {
1680 builder: self
1681 .builder
1682 .property("attached-to", attached_to.clone().upcast()),
1683 }
1684 }
1685
1686 /// Whether the window should be decorated by the window manager.
1687 pub fn decorated(self, decorated: bool) -> Self {
1688 Self {
1689 builder: self.builder.property("decorated", decorated),
1690 }
1691 }
1692
1693 pub fn default_height(self, default_height: i32) -> Self {
1694 Self {
1695 builder: self.builder.property("default-height", default_height),
1696 }
1697 }
1698
1699 pub fn default_width(self, default_width: i32) -> Self {
1700 Self {
1701 builder: self.builder.property("default-width", default_width),
1702 }
1703 }
1704
1705 /// Whether the window frame should have a close button.
1706 pub fn deletable(self, deletable: bool) -> Self {
1707 Self {
1708 builder: self.builder.property("deletable", deletable),
1709 }
1710 }
1711
1712 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
1713 Self {
1714 builder: self
1715 .builder
1716 .property("destroy-with-parent", destroy_with_parent),
1717 }
1718 }
1719
1720 /// Whether the window should receive the input focus when mapped.
1721 pub fn focus_on_map(self, focus_on_map: bool) -> Self {
1722 Self {
1723 builder: self.builder.property("focus-on-map", focus_on_map),
1724 }
1725 }
1726
1727 /// Whether 'focus rectangles' are currently visible in this window.
1728 ///
1729 /// This property is maintained by GTK+ based on user input
1730 /// and should not be set by applications.
1731 pub fn focus_visible(self, focus_visible: bool) -> Self {
1732 Self {
1733 builder: self.builder.property("focus-visible", focus_visible),
1734 }
1735 }
1736
1737 /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
1738 /// more details about window gravity.
1739 pub fn gravity(self, gravity: gdk::Gravity) -> Self {
1740 Self {
1741 builder: self.builder.property("gravity", gravity),
1742 }
1743 }
1744
1745 /// Whether the titlebar should be hidden during maximization.
1746 pub fn hide_titlebar_when_maximized(self, hide_titlebar_when_maximized: bool) -> Self {
1747 Self {
1748 builder: self
1749 .builder
1750 .property("hide-titlebar-when-maximized", hide_titlebar_when_maximized),
1751 }
1752 }
1753
1754 pub fn icon(self, icon: &gdk_pixbuf::Pixbuf) -> Self {
1755 Self {
1756 builder: self.builder.property("icon", icon.clone()),
1757 }
1758 }
1759
1760 /// The :icon-name property specifies the name of the themed icon to
1761 /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
1762 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1763 Self {
1764 builder: self.builder.property("icon-name", icon_name.into()),
1765 }
1766 }
1767
1768 /// Whether mnemonics are currently visible in this window.
1769 ///
1770 /// This property is maintained by GTK+ based on user input,
1771 /// and should not be set by applications.
1772 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
1773 Self {
1774 builder: self
1775 .builder
1776 .property("mnemonics-visible", mnemonics_visible),
1777 }
1778 }
1779
1780 pub fn modal(self, modal: bool) -> Self {
1781 Self {
1782 builder: self.builder.property("modal", modal),
1783 }
1784 }
1785
1786 pub fn resizable(self, resizable: bool) -> Self {
1787 Self {
1788 builder: self.builder.property("resizable", resizable),
1789 }
1790 }
1791
1792 pub fn role(self, role: impl Into<glib::GString>) -> Self {
1793 Self {
1794 builder: self.builder.property("role", role.into()),
1795 }
1796 }
1797
1798 pub fn screen(self, screen: &gdk::Screen) -> Self {
1799 Self {
1800 builder: self.builder.property("screen", screen.clone()),
1801 }
1802 }
1803
1804 pub fn skip_pager_hint(self, skip_pager_hint: bool) -> Self {
1805 Self {
1806 builder: self.builder.property("skip-pager-hint", skip_pager_hint),
1807 }
1808 }
1809
1810 pub fn skip_taskbar_hint(self, skip_taskbar_hint: bool) -> Self {
1811 Self {
1812 builder: self
1813 .builder
1814 .property("skip-taskbar-hint", skip_taskbar_hint),
1815 }
1816 }
1817
1818 /// The :startup-id is a write-only property for setting window's
1819 /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
1820 /// for more details.
1821 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
1822 Self {
1823 builder: self.builder.property("startup-id", startup_id.into()),
1824 }
1825 }
1826
1827 pub fn title(self, title: impl Into<glib::GString>) -> Self {
1828 Self {
1829 builder: self.builder.property("title", title.into()),
1830 }
1831 }
1832
1833 /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
1834 /// more details about transient windows.
1835 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
1836 Self {
1837 builder: self
1838 .builder
1839 .property("transient-for", transient_for.clone().upcast()),
1840 }
1841 }
1842
1843 pub fn type_(self, type_: WindowType) -> Self {
1844 Self {
1845 builder: self.builder.property("type", type_),
1846 }
1847 }
1848
1849 pub fn type_hint(self, type_hint: gdk::WindowTypeHint) -> Self {
1850 Self {
1851 builder: self.builder.property("type-hint", type_hint),
1852 }
1853 }
1854
1855 pub fn urgency_hint(self, urgency_hint: bool) -> Self {
1856 Self {
1857 builder: self.builder.property("urgency-hint", urgency_hint),
1858 }
1859 }
1860
1861 pub fn window_position(self, window_position: WindowPosition) -> Self {
1862 Self {
1863 builder: self.builder.property("window-position", window_position),
1864 }
1865 }
1866
1867 pub fn border_width(self, border_width: u32) -> Self {
1868 Self {
1869 builder: self.builder.property("border-width", border_width),
1870 }
1871 }
1872
1873 pub fn child(self, child: &impl IsA<Widget>) -> Self {
1874 Self {
1875 builder: self.builder.property("child", child.clone().upcast()),
1876 }
1877 }
1878
1879 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
1880 Self {
1881 builder: self.builder.property("resize-mode", resize_mode),
1882 }
1883 }
1884
1885 pub fn app_paintable(self, app_paintable: bool) -> Self {
1886 Self {
1887 builder: self.builder.property("app-paintable", app_paintable),
1888 }
1889 }
1890
1891 pub fn can_default(self, can_default: bool) -> Self {
1892 Self {
1893 builder: self.builder.property("can-default", can_default),
1894 }
1895 }
1896
1897 pub fn can_focus(self, can_focus: bool) -> Self {
1898 Self {
1899 builder: self.builder.property("can-focus", can_focus),
1900 }
1901 }
1902
1903 pub fn events(self, events: gdk::EventMask) -> Self {
1904 Self {
1905 builder: self.builder.property("events", events),
1906 }
1907 }
1908
1909 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
1910 pub fn expand(self, expand: bool) -> Self {
1911 Self {
1912 builder: self.builder.property("expand", expand),
1913 }
1914 }
1915
1916 /// Whether the widget should grab focus when it is clicked with the mouse.
1917 ///
1918 /// This property is only relevant for widgets that can take focus.
1919 ///
1920 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
1921 /// GtkComboBox) implemented this property individually.
1922 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1923 Self {
1924 builder: self.builder.property("focus-on-click", focus_on_click),
1925 }
1926 }
1927
1928 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
1929 pub fn halign(self, halign: Align) -> Self {
1930 Self {
1931 builder: self.builder.property("halign", halign),
1932 }
1933 }
1934
1935 pub fn has_default(self, has_default: bool) -> Self {
1936 Self {
1937 builder: self.builder.property("has-default", has_default),
1938 }
1939 }
1940
1941 pub fn has_focus(self, has_focus: bool) -> Self {
1942 Self {
1943 builder: self.builder.property("has-focus", has_focus),
1944 }
1945 }
1946
1947 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
1948 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
1949 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
1950 /// whether it will provide a tooltip or not.
1951 ///
1952 /// Note that setting this property to [`true`] for the first time will change
1953 /// the event masks of the GdkWindows of this widget to include leave-notify
1954 /// and motion-notify events. This cannot and will not be undone when the
1955 /// property is set to [`false`] again.
1956 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1957 Self {
1958 builder: self.builder.property("has-tooltip", has_tooltip),
1959 }
1960 }
1961
1962 pub fn height_request(self, height_request: i32) -> Self {
1963 Self {
1964 builder: self.builder.property("height-request", height_request),
1965 }
1966 }
1967
1968 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
1969 pub fn hexpand(self, hexpand: bool) -> Self {
1970 Self {
1971 builder: self.builder.property("hexpand", hexpand),
1972 }
1973 }
1974
1975 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
1976 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1977 Self {
1978 builder: self.builder.property("hexpand-set", hexpand_set),
1979 }
1980 }
1981
1982 pub fn is_focus(self, is_focus: bool) -> Self {
1983 Self {
1984 builder: self.builder.property("is-focus", is_focus),
1985 }
1986 }
1987
1988 /// Sets all four sides' margin at once. If read, returns max
1989 /// margin on any side.
1990 pub fn margin(self, margin: i32) -> Self {
1991 Self {
1992 builder: self.builder.property("margin", margin),
1993 }
1994 }
1995
1996 /// Margin on bottom side of widget.
1997 ///
1998 /// This property adds margin outside of the widget's normal size
1999 /// request, the margin will be added in addition to the size from
2000 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2001 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
2002 Self {
2003 builder: self.builder.property("margin-bottom", margin_bottom),
2004 }
2005 }
2006
2007 /// Margin on end of widget, horizontally. This property supports
2008 /// left-to-right and right-to-left text directions.
2009 ///
2010 /// This property adds margin outside of the widget's normal size
2011 /// request, the margin will be added in addition to the size from
2012 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2013 pub fn margin_end(self, margin_end: i32) -> Self {
2014 Self {
2015 builder: self.builder.property("margin-end", margin_end),
2016 }
2017 }
2018
2019 /// Margin on start of widget, horizontally. This property supports
2020 /// left-to-right and right-to-left text directions.
2021 ///
2022 /// This property adds margin outside of the widget's normal size
2023 /// request, the margin will be added in addition to the size from
2024 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2025 pub fn margin_start(self, margin_start: i32) -> Self {
2026 Self {
2027 builder: self.builder.property("margin-start", margin_start),
2028 }
2029 }
2030
2031 /// Margin on top side of widget.
2032 ///
2033 /// This property adds margin outside of the widget's normal size
2034 /// request, the margin will be added in addition to the size from
2035 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
2036 pub fn margin_top(self, margin_top: i32) -> Self {
2037 Self {
2038 builder: self.builder.property("margin-top", margin_top),
2039 }
2040 }
2041
2042 pub fn name(self, name: impl Into<glib::GString>) -> Self {
2043 Self {
2044 builder: self.builder.property("name", name.into()),
2045 }
2046 }
2047
2048 pub fn no_show_all(self, no_show_all: bool) -> Self {
2049 Self {
2050 builder: self.builder.property("no-show-all", no_show_all),
2051 }
2052 }
2053
2054 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
2055 /// more details about window opacity.
2056 ///
2057 /// Before 3.8 this was only available in GtkWindow
2058 pub fn opacity(self, opacity: f64) -> Self {
2059 Self {
2060 builder: self.builder.property("opacity", opacity),
2061 }
2062 }
2063
2064 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
2065 Self {
2066 builder: self.builder.property("parent", parent.clone().upcast()),
2067 }
2068 }
2069
2070 pub fn receives_default(self, receives_default: bool) -> Self {
2071 Self {
2072 builder: self.builder.property("receives-default", receives_default),
2073 }
2074 }
2075
2076 pub fn sensitive(self, sensitive: bool) -> Self {
2077 Self {
2078 builder: self.builder.property("sensitive", sensitive),
2079 }
2080 }
2081
2082 /// Sets the text of tooltip to be the given string, which is marked up
2083 /// with the [Pango text markup language][PangoMarkupFormat].
2084 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
2085 ///
2086 /// This is a convenience property which will take care of getting the
2087 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
2088 /// will automatically be set to [`true`] and there will be taken care of
2089 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
2090 ///
2091 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
2092 /// are set, the last one wins.
2093 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
2094 Self {
2095 builder: self
2096 .builder
2097 .property("tooltip-markup", tooltip_markup.into()),
2098 }
2099 }
2100
2101 /// Sets the text of tooltip to be the given string.
2102 ///
2103 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
2104 ///
2105 /// This is a convenience property which will take care of getting the
2106 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
2107 /// will automatically be set to [`true`] and there will be taken care of
2108 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
2109 ///
2110 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
2111 /// are set, the last one wins.
2112 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
2113 Self {
2114 builder: self.builder.property("tooltip-text", tooltip_text.into()),
2115 }
2116 }
2117
2118 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
2119 pub fn valign(self, valign: Align) -> Self {
2120 Self {
2121 builder: self.builder.property("valign", valign),
2122 }
2123 }
2124
2125 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
2126 pub fn vexpand(self, vexpand: bool) -> Self {
2127 Self {
2128 builder: self.builder.property("vexpand", vexpand),
2129 }
2130 }
2131
2132 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
2133 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
2134 Self {
2135 builder: self.builder.property("vexpand-set", vexpand_set),
2136 }
2137 }
2138
2139 pub fn visible(self, visible: bool) -> Self {
2140 Self {
2141 builder: self.builder.property("visible", visible),
2142 }
2143 }
2144
2145 pub fn width_request(self, width_request: i32) -> Self {
2146 Self {
2147 builder: self.builder.property("width-request", width_request),
2148 }
2149 }
2150
2151 // rustdoc-stripper-ignore-next
2152 /// Build the [`Window`].
2153 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
2154 pub fn build(self) -> Window {
2155 assert_initialized_main_thread!();
2156 self.builder.build()
2157 }
2158}
2159
2160/// Trait containing all [`struct@Window`] methods.
2161///
2162/// # Implementors
2163///
2164/// [`ApplicationWindow`][struct@crate::ApplicationWindow], [`Assistant`][struct@crate::Assistant], [`Dialog`][struct@crate::Dialog], [`OffscreenWindow`][struct@crate::OffscreenWindow], [`Plug`][struct@crate::Plug], [`ShortcutsWindow`][struct@crate::ShortcutsWindow], [`Window`][struct@crate::Window]
2165pub trait GtkWindowExt: IsA<Window> + 'static {
2166 /// Activates the default widget for the window, unless the current
2167 /// focused widget has been configured to receive the default action
2168 /// (see [`WidgetExt::set_receives_default()`][crate::prelude::WidgetExt::set_receives_default()]), in which case the
2169 /// focused widget is activated.
2170 ///
2171 /// # Returns
2172 ///
2173 /// [`true`] if a widget got activated.
2174 #[doc(alias = "gtk_window_activate_default")]
2175 fn activate_default(&self) -> bool {
2176 unsafe {
2177 from_glib(ffi::gtk_window_activate_default(
2178 self.as_ref().to_glib_none().0,
2179 ))
2180 }
2181 }
2182
2183 /// Activates the current focused widget within the window.
2184 ///
2185 /// # Returns
2186 ///
2187 /// [`true`] if a widget got activated.
2188 #[doc(alias = "gtk_window_activate_focus")]
2189 fn activate_focus(&self) -> bool {
2190 unsafe {
2191 from_glib(ffi::gtk_window_activate_focus(
2192 self.as_ref().to_glib_none().0,
2193 ))
2194 }
2195 }
2196
2197 /// Activates mnemonics and accelerators for this [`Window`][crate::Window]. This is normally
2198 /// called by the default ::key_press_event handler for toplevel windows,
2199 /// however in some cases it may be useful to call this directly when
2200 /// overriding the standard key handling for a toplevel window.
2201 /// ## `event`
2202 /// a [`gdk::EventKey`][crate::gdk::EventKey]
2203 ///
2204 /// # Returns
2205 ///
2206 /// [`true`] if a mnemonic or accelerator was found and activated.
2207 #[doc(alias = "gtk_window_activate_key")]
2208 fn activate_key(&self, event: &gdk::EventKey) -> bool {
2209 unsafe {
2210 from_glib(ffi::gtk_window_activate_key(
2211 self.as_ref().to_glib_none().0,
2212 mut_override(event.to_glib_none().0),
2213 ))
2214 }
2215 }
2216
2217 /// Associate `accel_group` with `self`, such that calling
2218 /// [`accel_groups_activate()`][crate::accel_groups_activate()] on `self` will activate accelerators
2219 /// in `accel_group`.
2220 /// ## `accel_group`
2221 /// a [`AccelGroup`][crate::AccelGroup]
2222 #[doc(alias = "gtk_window_add_accel_group")]
2223 fn add_accel_group(&self, accel_group: &impl IsA<AccelGroup>) {
2224 unsafe {
2225 ffi::gtk_window_add_accel_group(
2226 self.as_ref().to_glib_none().0,
2227 accel_group.as_ref().to_glib_none().0,
2228 );
2229 }
2230 }
2231
2232 /// Adds a mnemonic to this window.
2233 /// ## `keyval`
2234 /// the mnemonic
2235 /// ## `target`
2236 /// the widget that gets activated by the mnemonic
2237 #[doc(alias = "gtk_window_add_mnemonic")]
2238 fn add_mnemonic(&self, keyval: u32, target: &impl IsA<Widget>) {
2239 unsafe {
2240 ffi::gtk_window_add_mnemonic(
2241 self.as_ref().to_glib_none().0,
2242 keyval,
2243 target.as_ref().to_glib_none().0,
2244 );
2245 }
2246 }
2247
2248 /// Starts moving a window. This function is used if an application has
2249 /// window movement grips. When GDK can support it, the window movement
2250 /// will be done using the standard mechanism for the
2251 /// [window manager][gtk-X11-arch] or windowing
2252 /// system. Otherwise, GDK will try to emulate window movement,
2253 /// potentially not all that well, depending on the windowing system.
2254 /// ## `button`
2255 /// mouse button that initiated the drag
2256 /// ## `root_x`
2257 /// X position where the user clicked to initiate the drag, in root window coordinates
2258 /// ## `root_y`
2259 /// Y position where the user clicked to initiate the drag
2260 /// ## `timestamp`
2261 /// timestamp from the click event that initiated the drag
2262 #[doc(alias = "gtk_window_begin_move_drag")]
2263 fn begin_move_drag(&self, button: i32, root_x: i32, root_y: i32, timestamp: u32) {
2264 unsafe {
2265 ffi::gtk_window_begin_move_drag(
2266 self.as_ref().to_glib_none().0,
2267 button,
2268 root_x,
2269 root_y,
2270 timestamp,
2271 );
2272 }
2273 }
2274
2275 /// Starts resizing a window. This function is used if an application
2276 /// has window resizing controls. When GDK can support it, the resize
2277 /// will be done using the standard mechanism for the
2278 /// [window manager][gtk-X11-arch] or windowing
2279 /// system. Otherwise, GDK will try to emulate window resizing,
2280 /// potentially not all that well, depending on the windowing system.
2281 /// ## `edge`
2282 /// position of the resize control
2283 /// ## `button`
2284 /// mouse button that initiated the drag
2285 /// ## `root_x`
2286 /// X position where the user clicked to initiate the drag, in root window coordinates
2287 /// ## `root_y`
2288 /// Y position where the user clicked to initiate the drag
2289 /// ## `timestamp`
2290 /// timestamp from the click event that initiated the drag
2291 #[doc(alias = "gtk_window_begin_resize_drag")]
2292 fn begin_resize_drag(
2293 &self,
2294 edge: gdk::WindowEdge,
2295 button: i32,
2296 root_x: i32,
2297 root_y: i32,
2298 timestamp: u32,
2299 ) {
2300 unsafe {
2301 ffi::gtk_window_begin_resize_drag(
2302 self.as_ref().to_glib_none().0,
2303 edge.into_glib(),
2304 button,
2305 root_x,
2306 root_y,
2307 timestamp,
2308 );
2309 }
2310 }
2311
2312 /// Requests that the window is closed, similar to what happens
2313 /// when a window manager close button is clicked.
2314 ///
2315 /// This function can be used with close buttons in custom
2316 /// titlebars.
2317 #[doc(alias = "gtk_window_close")]
2318 fn close(&self) {
2319 unsafe {
2320 ffi::gtk_window_close(self.as_ref().to_glib_none().0);
2321 }
2322 }
2323
2324 /// Asks to deiconify (i.e. unminimize) the specified `self`. Note
2325 /// that you shouldn’t assume the window is definitely deiconified
2326 /// afterward, because other entities (e.g. the user or
2327 /// [window manager][gtk-X11-arch])) could iconify it
2328 /// again before your code which assumes deiconification gets to run.
2329 ///
2330 /// You can track iconification via the “window-state-event” signal
2331 /// on [`Widget`][crate::Widget].
2332 #[doc(alias = "gtk_window_deiconify")]
2333 fn deiconify(&self) {
2334 unsafe {
2335 ffi::gtk_window_deiconify(self.as_ref().to_glib_none().0);
2336 }
2337 }
2338
2339 /// Asks to place `self` in the fullscreen state. Note that you
2340 /// shouldn’t assume the window is definitely full screen afterward,
2341 /// because other entities (e.g. the user or
2342 /// [window manager][gtk-X11-arch]) could unfullscreen it
2343 /// again, and not all window managers honor requests to fullscreen
2344 /// windows. But normally the window will end up fullscreen. Just
2345 /// don’t write code that crashes if not.
2346 ///
2347 /// You can track the fullscreen state via the “window-state-event” signal
2348 /// on [`Widget`][crate::Widget].
2349 #[doc(alias = "gtk_window_fullscreen")]
2350 fn fullscreen(&self) {
2351 unsafe {
2352 ffi::gtk_window_fullscreen(self.as_ref().to_glib_none().0);
2353 }
2354 }
2355
2356 /// Asks to place `self` in the fullscreen state. Note that you shouldn't assume
2357 /// the window is definitely full screen afterward.
2358 ///
2359 /// You can track the fullscreen state via the "window-state-event" signal
2360 /// on [`Widget`][crate::Widget].
2361 /// ## `screen`
2362 /// a [`gdk::Screen`][crate::gdk::Screen] to draw to
2363 /// ## `monitor`
2364 /// which monitor to go fullscreen on
2365 #[doc(alias = "gtk_window_fullscreen_on_monitor")]
2366 fn fullscreen_on_monitor(&self, screen: &gdk::Screen, monitor: i32) {
2367 unsafe {
2368 ffi::gtk_window_fullscreen_on_monitor(
2369 self.as_ref().to_glib_none().0,
2370 screen.to_glib_none().0,
2371 monitor,
2372 );
2373 }
2374 }
2375
2376 /// Gets the value set by [`set_accept_focus()`][Self::set_accept_focus()].
2377 ///
2378 /// # Returns
2379 ///
2380 /// [`true`] if window should receive the input focus
2381 #[doc(alias = "gtk_window_get_accept_focus")]
2382 #[doc(alias = "get_accept_focus")]
2383 #[doc(alias = "accept-focus")]
2384 fn accepts_focus(&self) -> bool {
2385 unsafe {
2386 from_glib(ffi::gtk_window_get_accept_focus(
2387 self.as_ref().to_glib_none().0,
2388 ))
2389 }
2390 }
2391
2392 /// Gets the [`Application`][crate::Application] associated with the window (if any).
2393 ///
2394 /// # Returns
2395 ///
2396 /// a [`Application`][crate::Application], or [`None`]
2397 #[doc(alias = "gtk_window_get_application")]
2398 #[doc(alias = "get_application")]
2399 fn application(&self) -> Option<Application> {
2400 unsafe {
2401 from_glib_none(ffi::gtk_window_get_application(
2402 self.as_ref().to_glib_none().0,
2403 ))
2404 }
2405 }
2406
2407 /// Fetches the attach widget for this window. See
2408 /// [`set_attached_to()`][Self::set_attached_to()].
2409 ///
2410 /// # Returns
2411 ///
2412 /// the widget where the window
2413 /// is attached, or [`None`] if the window is not attached to any widget.
2414 #[doc(alias = "gtk_window_get_attached_to")]
2415 #[doc(alias = "get_attached_to")]
2416 #[doc(alias = "attached-to")]
2417 fn attached_to(&self) -> Option<Widget> {
2418 unsafe {
2419 from_glib_none(ffi::gtk_window_get_attached_to(
2420 self.as_ref().to_glib_none().0,
2421 ))
2422 }
2423 }
2424
2425 /// Returns whether the window has been set to have decorations
2426 /// such as a title bar via [`set_decorated()`][Self::set_decorated()].
2427 ///
2428 /// # Returns
2429 ///
2430 /// [`true`] if the window has been set to have decorations
2431 #[doc(alias = "gtk_window_get_decorated")]
2432 #[doc(alias = "get_decorated")]
2433 #[doc(alias = "decorated")]
2434 fn is_decorated(&self) -> bool {
2435 unsafe {
2436 from_glib(ffi::gtk_window_get_decorated(
2437 self.as_ref().to_glib_none().0,
2438 ))
2439 }
2440 }
2441
2442 /// Gets the default size of the window. A value of -1 for the width or
2443 /// height indicates that a default size has not been explicitly set
2444 /// for that dimension, so the “natural” size of the window will be
2445 /// used.
2446 ///
2447 /// # Returns
2448 ///
2449 ///
2450 /// ## `width`
2451 /// location to store the default width, or [`None`]
2452 ///
2453 /// ## `height`
2454 /// location to store the default height, or [`None`]
2455 #[doc(alias = "gtk_window_get_default_size")]
2456 #[doc(alias = "get_default_size")]
2457 fn default_size(&self) -> (i32, i32) {
2458 unsafe {
2459 let mut width = std::mem::MaybeUninit::uninit();
2460 let mut height = std::mem::MaybeUninit::uninit();
2461 ffi::gtk_window_get_default_size(
2462 self.as_ref().to_glib_none().0,
2463 width.as_mut_ptr(),
2464 height.as_mut_ptr(),
2465 );
2466 (width.assume_init(), height.assume_init())
2467 }
2468 }
2469
2470 /// Returns the default widget for `self`. See
2471 /// [`set_default()`][Self::set_default()] for more details.
2472 ///
2473 /// # Returns
2474 ///
2475 /// the default widget, or [`None`]
2476 /// if there is none.
2477 #[doc(alias = "gtk_window_get_default_widget")]
2478 #[doc(alias = "get_default_widget")]
2479 fn default_widget(&self) -> Option<Widget> {
2480 unsafe {
2481 from_glib_none(ffi::gtk_window_get_default_widget(
2482 self.as_ref().to_glib_none().0,
2483 ))
2484 }
2485 }
2486
2487 /// Returns whether the window has been set to have a close button
2488 /// via [`set_deletable()`][Self::set_deletable()].
2489 ///
2490 /// # Returns
2491 ///
2492 /// [`true`] if the window has been set to have a close button
2493 #[doc(alias = "gtk_window_get_deletable")]
2494 #[doc(alias = "get_deletable")]
2495 #[doc(alias = "deletable")]
2496 fn is_deletable(&self) -> bool {
2497 unsafe {
2498 from_glib(ffi::gtk_window_get_deletable(
2499 self.as_ref().to_glib_none().0,
2500 ))
2501 }
2502 }
2503
2504 /// Returns whether the window will be destroyed with its transient parent. See
2505 /// gtk_window_set_destroy_with_parent ().
2506 ///
2507 /// # Returns
2508 ///
2509 /// [`true`] if the window will be destroyed with its transient parent.
2510 #[doc(alias = "gtk_window_get_destroy_with_parent")]
2511 #[doc(alias = "get_destroy_with_parent")]
2512 #[doc(alias = "destroy-with-parent")]
2513 fn must_destroy_with_parent(&self) -> bool {
2514 unsafe {
2515 from_glib(ffi::gtk_window_get_destroy_with_parent(
2516 self.as_ref().to_glib_none().0,
2517 ))
2518 }
2519 }
2520
2521 /// Retrieves the current focused widget within the window.
2522 /// Note that this is the widget that would have the focus
2523 /// if the toplevel window focused; if the toplevel window
2524 /// is not focused then `gtk_widget_has_focus (widget)` will
2525 /// not be [`true`] for the widget.
2526 ///
2527 /// # Returns
2528 ///
2529 /// the currently focused widget,
2530 /// or [`None`] if there is none.
2531 #[doc(alias = "gtk_window_get_focus")]
2532 #[doc(alias = "get_focus")]
2533 fn focused_widget(&self) -> Option<Widget> {
2534 unsafe { from_glib_none(ffi::gtk_window_get_focus(self.as_ref().to_glib_none().0)) }
2535 }
2536
2537 /// Gets the value set by [`set_focus_on_map()`][Self::set_focus_on_map()].
2538 ///
2539 /// # Returns
2540 ///
2541 /// [`true`] if window should receive the input focus when
2542 /// mapped.
2543 #[doc(alias = "gtk_window_get_focus_on_map")]
2544 #[doc(alias = "get_focus_on_map")]
2545 #[doc(alias = "focus-on-map")]
2546 fn gets_focus_on_map(&self) -> bool {
2547 unsafe {
2548 from_glib(ffi::gtk_window_get_focus_on_map(
2549 self.as_ref().to_glib_none().0,
2550 ))
2551 }
2552 }
2553
2554 /// Gets the value of the [`focus-visible`][struct@crate::Window#focus-visible] property.
2555 ///
2556 /// # Returns
2557 ///
2558 /// [`true`] if “focus rectangles” are supposed to be visible
2559 /// in this window.
2560 #[doc(alias = "gtk_window_get_focus_visible")]
2561 #[doc(alias = "get_focus_visible")]
2562 #[doc(alias = "focus-visible")]
2563 fn gets_focus_visible(&self) -> bool {
2564 unsafe {
2565 from_glib(ffi::gtk_window_get_focus_visible(
2566 self.as_ref().to_glib_none().0,
2567 ))
2568 }
2569 }
2570
2571 /// Gets the value set by [`set_gravity()`][Self::set_gravity()].
2572 ///
2573 /// # Returns
2574 ///
2575 /// window gravity
2576 #[doc(alias = "gtk_window_get_gravity")]
2577 #[doc(alias = "get_gravity")]
2578 fn gravity(&self) -> gdk::Gravity {
2579 unsafe { from_glib(ffi::gtk_window_get_gravity(self.as_ref().to_glib_none().0)) }
2580 }
2581
2582 /// Returns the group for `self` or the default group, if
2583 /// `self` is [`None`] or if `self` does not have an explicit
2584 /// window group.
2585 ///
2586 /// # Returns
2587 ///
2588 /// the [`WindowGroup`][crate::WindowGroup] for a window or the default group
2589 #[doc(alias = "gtk_window_get_group")]
2590 #[doc(alias = "get_group")]
2591 fn group(&self) -> Option<WindowGroup> {
2592 unsafe { from_glib_none(ffi::gtk_window_get_group(self.as_ref().to_glib_none().0)) }
2593 }
2594
2595 /// Returns whether the window has requested to have its titlebar hidden
2596 /// when maximized. See gtk_window_set_hide_titlebar_when_maximized ().
2597 ///
2598 /// # Returns
2599 ///
2600 /// [`true`] if the window has requested to have its titlebar
2601 /// hidden when maximized
2602 #[doc(alias = "gtk_window_get_hide_titlebar_when_maximized")]
2603 #[doc(alias = "get_hide_titlebar_when_maximized")]
2604 #[doc(alias = "hide-titlebar-when-maximized")]
2605 fn hides_titlebar_when_maximized(&self) -> bool {
2606 unsafe {
2607 from_glib(ffi::gtk_window_get_hide_titlebar_when_maximized(
2608 self.as_ref().to_glib_none().0,
2609 ))
2610 }
2611 }
2612
2613 /// Gets the value set by [`set_icon()`][Self::set_icon()] (or if you've
2614 /// called [`set_icon_list()`][Self::set_icon_list()], gets the first icon in
2615 /// the icon list).
2616 ///
2617 /// # Returns
2618 ///
2619 /// icon for window or [`None`] if none
2620 #[doc(alias = "gtk_window_get_icon")]
2621 #[doc(alias = "get_icon")]
2622 fn icon(&self) -> Option<gdk_pixbuf::Pixbuf> {
2623 unsafe { from_glib_none(ffi::gtk_window_get_icon(self.as_ref().to_glib_none().0)) }
2624 }
2625
2626 /// Retrieves the list of icons set by [`set_icon_list()`][Self::set_icon_list()].
2627 /// The list is copied, but the reference count on each
2628 /// member won’t be incremented.
2629 ///
2630 /// # Returns
2631 ///
2632 /// copy of window’s icon list
2633 #[doc(alias = "gtk_window_get_icon_list")]
2634 #[doc(alias = "get_icon_list")]
2635 fn icon_list(&self) -> Vec<gdk_pixbuf::Pixbuf> {
2636 unsafe {
2637 FromGlibPtrContainer::from_glib_container(ffi::gtk_window_get_icon_list(
2638 self.as_ref().to_glib_none().0,
2639 ))
2640 }
2641 }
2642
2643 /// Returns the name of the themed icon for the window,
2644 /// see [`set_icon_name()`][Self::set_icon_name()].
2645 ///
2646 /// # Returns
2647 ///
2648 /// the icon name or [`None`] if the window has
2649 /// no themed icon
2650 #[doc(alias = "gtk_window_get_icon_name")]
2651 #[doc(alias = "get_icon_name")]
2652 #[doc(alias = "icon-name")]
2653 fn icon_name(&self) -> Option<glib::GString> {
2654 unsafe {
2655 from_glib_none(ffi::gtk_window_get_icon_name(
2656 self.as_ref().to_glib_none().0,
2657 ))
2658 }
2659 }
2660
2661 /// Returns the mnemonic modifier for this window. See
2662 /// [`set_mnemonic_modifier()`][Self::set_mnemonic_modifier()].
2663 ///
2664 /// # Returns
2665 ///
2666 /// the modifier mask used to activate
2667 /// mnemonics on this window.
2668 #[doc(alias = "gtk_window_get_mnemonic_modifier")]
2669 #[doc(alias = "get_mnemonic_modifier")]
2670 fn mnemonic_modifier(&self) -> gdk::ModifierType {
2671 unsafe {
2672 from_glib(ffi::gtk_window_get_mnemonic_modifier(
2673 self.as_ref().to_glib_none().0,
2674 ))
2675 }
2676 }
2677
2678 /// Gets the value of the [`mnemonics-visible`][struct@crate::Window#mnemonics-visible] property.
2679 ///
2680 /// # Returns
2681 ///
2682 /// [`true`] if mnemonics are supposed to be visible
2683 /// in this window.
2684 #[doc(alias = "gtk_window_get_mnemonics_visible")]
2685 #[doc(alias = "get_mnemonics_visible")]
2686 #[doc(alias = "mnemonics-visible")]
2687 fn is_mnemonics_visible(&self) -> bool {
2688 unsafe {
2689 from_glib(ffi::gtk_window_get_mnemonics_visible(
2690 self.as_ref().to_glib_none().0,
2691 ))
2692 }
2693 }
2694
2695 /// Returns whether the window is modal. See [`set_modal()`][Self::set_modal()].
2696 ///
2697 /// # Returns
2698 ///
2699 /// [`true`] if the window is set to be modal and
2700 /// establishes a grab when shown
2701 #[doc(alias = "gtk_window_get_modal")]
2702 #[doc(alias = "get_modal")]
2703 #[doc(alias = "modal")]
2704 fn is_modal(&self) -> bool {
2705 unsafe { from_glib(ffi::gtk_window_get_modal(self.as_ref().to_glib_none().0)) }
2706 }
2707
2708 /// This function returns the position you need to pass to
2709 /// [`move_()`][Self::move_()] to keep `self` in its current position.
2710 /// This means that the meaning of the returned value varies with
2711 /// window gravity. See [`move_()`][Self::move_()] for more details.
2712 ///
2713 /// The reliability of this function depends on the windowing system
2714 /// currently in use. Some windowing systems, such as Wayland, do not
2715 /// support a global coordinate system, and thus the position of the
2716 /// window will always be (0, 0). Others, like X11, do not have a reliable
2717 /// way to obtain the geometry of the decorations of a window if they are
2718 /// provided by the window manager. Additionally, on X11, window manager
2719 /// have been known to mismanage window gravity, which result in windows
2720 /// moving even if you use the coordinates of the current position as
2721 /// returned by this function.
2722 ///
2723 /// If you haven’t changed the window gravity, its gravity will be
2724 /// [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest]. This means that [`position()`][Self::position()]
2725 /// gets the position of the top-left corner of the window manager
2726 /// frame for the window. [`move_()`][Self::move_()] sets the position of this
2727 /// same top-left corner.
2728 ///
2729 /// If a window has gravity [`gdk::Gravity::Static`][crate::gdk::Gravity::Static] the window manager
2730 /// frame is not relevant, and thus [`position()`][Self::position()] will
2731 /// always produce accurate results. However you can’t use static
2732 /// gravity to do things like place a window in a corner of the screen,
2733 /// because static gravity ignores the window manager decorations.
2734 ///
2735 /// Ideally, this function should return appropriate values if the
2736 /// window has client side decorations, assuming that the windowing
2737 /// system supports global coordinates.
2738 ///
2739 /// In practice, saving the window position should not be left to
2740 /// applications, as they lack enough knowledge of the windowing
2741 /// system and the window manager state to effectively do so. The
2742 /// appropriate way to implement saving the window position is to
2743 /// use a platform-specific protocol, wherever that is available.
2744 ///
2745 /// # Returns
2746 ///
2747 ///
2748 /// ## `root_x`
2749 /// return location for X coordinate of
2750 /// gravity-determined reference point, or [`None`]
2751 ///
2752 /// ## `root_y`
2753 /// return location for Y coordinate of
2754 /// gravity-determined reference point, or [`None`]
2755 #[doc(alias = "gtk_window_get_position")]
2756 #[doc(alias = "get_position")]
2757 fn position(&self) -> (i32, i32) {
2758 unsafe {
2759 let mut root_x = std::mem::MaybeUninit::uninit();
2760 let mut root_y = std::mem::MaybeUninit::uninit();
2761 ffi::gtk_window_get_position(
2762 self.as_ref().to_glib_none().0,
2763 root_x.as_mut_ptr(),
2764 root_y.as_mut_ptr(),
2765 );
2766 (root_x.assume_init(), root_y.assume_init())
2767 }
2768 }
2769
2770 /// Gets the value set by [`set_resizable()`][Self::set_resizable()].
2771 ///
2772 /// # Returns
2773 ///
2774 /// [`true`] if the user can resize the window
2775 #[doc(alias = "gtk_window_get_resizable")]
2776 #[doc(alias = "get_resizable")]
2777 #[doc(alias = "resizable")]
2778 fn is_resizable(&self) -> bool {
2779 unsafe {
2780 from_glib(ffi::gtk_window_get_resizable(
2781 self.as_ref().to_glib_none().0,
2782 ))
2783 }
2784 }
2785
2786 /// Returns the role of the window. See [`set_role()`][Self::set_role()] for
2787 /// further explanation.
2788 ///
2789 /// # Returns
2790 ///
2791 /// the role of the window if set, or [`None`]. The
2792 /// returned is owned by the widget and must not be modified or freed.
2793 #[doc(alias = "gtk_window_get_role")]
2794 #[doc(alias = "get_role")]
2795 fn role(&self) -> Option<glib::GString> {
2796 unsafe { from_glib_none(ffi::gtk_window_get_role(self.as_ref().to_glib_none().0)) }
2797 }
2798
2799 /// Returns the [`gdk::Screen`][crate::gdk::Screen] associated with `self`.
2800 ///
2801 /// # Returns
2802 ///
2803 /// a [`gdk::Screen`][crate::gdk::Screen].
2804 #[doc(alias = "gtk_window_get_screen")]
2805 #[doc(alias = "get_screen")]
2806 fn screen(&self) -> Option<gdk::Screen> {
2807 unsafe { from_glib_none(ffi::gtk_window_get_screen(self.as_ref().to_glib_none().0)) }
2808 }
2809
2810 /// Obtains the current size of `self`.
2811 ///
2812 /// If `self` is not visible on screen, this function return the size GTK+
2813 /// will suggest to the [window manager][gtk-X11-arch] for the initial window
2814 /// size (but this is not reliably the same as the size the window manager
2815 /// will actually select). See: [`set_default_size()`][Self::set_default_size()].
2816 ///
2817 /// Depending on the windowing system and the window manager constraints,
2818 /// the size returned by this function may not match the size set using
2819 /// [`resize()`][Self::resize()]; additionally, since [`resize()`][Self::resize()] may be
2820 /// implemented as an asynchronous operation, GTK+ cannot guarantee in any
2821 /// way that this code:
2822 ///
2823 ///
2824 ///
2825 /// **⚠️ The following code is in C ⚠️**
2826 ///
2827 /// ```C
2828 /// // width and height are set elsewhere
2829 /// gtk_window_resize (window, width, height);
2830 ///
2831 /// int new_width, new_height;
2832 /// gtk_window_get_size (window, &new_width, &new_height);
2833 /// ```
2834 ///
2835 /// will result in `new_width` and `new_height` matching `width` and
2836 /// `height`, respectively.
2837 ///
2838 /// This function will return the logical size of the [`Window`][crate::Window],
2839 /// excluding the widgets used in client side decorations; there is,
2840 /// however, no guarantee that the result will be completely accurate
2841 /// because client side decoration may include widgets that depend on
2842 /// the user preferences and that may not be visibile at the time you
2843 /// call this function.
2844 ///
2845 /// The dimensions returned by this function are suitable for being
2846 /// stored across sessions; use [`set_default_size()`][Self::set_default_size()] to
2847 /// restore them when before showing the window.
2848 ///
2849 /// To avoid potential race conditions, you should only call this
2850 /// function in response to a size change notification, for instance
2851 /// inside a handler for the [`size-allocate`][struct@crate::Widget#size-allocate] signal, or
2852 /// inside a handler for the [`configure-event`][struct@crate::Widget#configure-event] signal:
2853 ///
2854 ///
2855 ///
2856 /// **⚠️ The following code is in C ⚠️**
2857 ///
2858 /// ```C
2859 /// static void
2860 /// on_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
2861 /// {
2862 /// int new_width, new_height;
2863 ///
2864 /// gtk_window_get_size (GTK_WINDOW (widget), &new_width, &new_height);
2865 ///
2866 /// ...
2867 /// }
2868 /// ```
2869 ///
2870 /// Note that, if you connect to the [`size-allocate`][struct@crate::Widget#size-allocate] signal,
2871 /// you should not use the dimensions of the `GtkAllocation` passed to
2872 /// the signal handler, as the allocation may contain client side
2873 /// decorations added by GTK+, depending on the windowing system in
2874 /// use.
2875 ///
2876 /// If you are getting a window size in order to position the window
2877 /// on the screen, you should, instead, simply set the window’s semantic
2878 /// type with [`set_type_hint()`][Self::set_type_hint()], which allows the window manager
2879 /// to e.g. center dialogs. Also, if you set the transient parent of
2880 /// dialogs with [`set_transient_for()`][Self::set_transient_for()] window managers will
2881 /// often center the dialog over its parent window. It's much preferred
2882 /// to let the window manager handle these cases rather than doing it
2883 /// yourself, because all apps will behave consistently and according to
2884 /// user or system preferences, if the window manager handles it. Also,
2885 /// the window manager can take into account the size of the window
2886 /// decorations and border that it may add, and of which GTK+ has no
2887 /// knowledge. Additionally, positioning windows in global screen coordinates
2888 /// may not be allowed by the windowing system. For more information,
2889 /// see: [`set_position()`][Self::set_position()].
2890 ///
2891 /// # Returns
2892 ///
2893 ///
2894 /// ## `width`
2895 /// return location for width, or [`None`]
2896 ///
2897 /// ## `height`
2898 /// return location for height, or [`None`]
2899 #[doc(alias = "gtk_window_get_size")]
2900 #[doc(alias = "get_size")]
2901 fn size(&self) -> (i32, i32) {
2902 unsafe {
2903 let mut width = std::mem::MaybeUninit::uninit();
2904 let mut height = std::mem::MaybeUninit::uninit();
2905 ffi::gtk_window_get_size(
2906 self.as_ref().to_glib_none().0,
2907 width.as_mut_ptr(),
2908 height.as_mut_ptr(),
2909 );
2910 (width.assume_init(), height.assume_init())
2911 }
2912 }
2913
2914 /// Gets the value set by [`set_skip_pager_hint()`][Self::set_skip_pager_hint()].
2915 ///
2916 /// # Returns
2917 ///
2918 /// [`true`] if window shouldn’t be in pager
2919 #[doc(alias = "gtk_window_get_skip_pager_hint")]
2920 #[doc(alias = "get_skip_pager_hint")]
2921 #[doc(alias = "skip-pager-hint")]
2922 fn skips_pager_hint(&self) -> bool {
2923 unsafe {
2924 from_glib(ffi::gtk_window_get_skip_pager_hint(
2925 self.as_ref().to_glib_none().0,
2926 ))
2927 }
2928 }
2929
2930 /// Gets the value set by [`set_skip_taskbar_hint()`][Self::set_skip_taskbar_hint()]
2931 ///
2932 /// # Returns
2933 ///
2934 /// [`true`] if window shouldn’t be in taskbar
2935 #[doc(alias = "gtk_window_get_skip_taskbar_hint")]
2936 #[doc(alias = "get_skip_taskbar_hint")]
2937 #[doc(alias = "skip-taskbar-hint")]
2938 fn skips_taskbar_hint(&self) -> bool {
2939 unsafe {
2940 from_glib(ffi::gtk_window_get_skip_taskbar_hint(
2941 self.as_ref().to_glib_none().0,
2942 ))
2943 }
2944 }
2945
2946 /// Retrieves the title of the window. See [`set_title()`][Self::set_title()].
2947 ///
2948 /// # Returns
2949 ///
2950 /// the title of the window, or [`None`] if none has
2951 /// been set explicitly. The returned string is owned by the widget
2952 /// and must not be modified or freed.
2953 #[doc(alias = "gtk_window_get_title")]
2954 #[doc(alias = "get_title")]
2955 fn title(&self) -> Option<glib::GString> {
2956 unsafe { from_glib_none(ffi::gtk_window_get_title(self.as_ref().to_glib_none().0)) }
2957 }
2958
2959 /// Returns the custom titlebar that has been set with
2960 /// [`set_titlebar()`][Self::set_titlebar()].
2961 ///
2962 /// # Returns
2963 ///
2964 /// the custom titlebar, or [`None`]
2965 #[doc(alias = "gtk_window_get_titlebar")]
2966 #[doc(alias = "get_titlebar")]
2967 fn titlebar(&self) -> Option<Widget> {
2968 unsafe { from_glib_none(ffi::gtk_window_get_titlebar(self.as_ref().to_glib_none().0)) }
2969 }
2970
2971 /// Fetches the transient parent for this window. See
2972 /// [`set_transient_for()`][Self::set_transient_for()].
2973 ///
2974 /// # Returns
2975 ///
2976 /// the transient parent for this
2977 /// window, or [`None`] if no transient parent has been set.
2978 #[doc(alias = "gtk_window_get_transient_for")]
2979 #[doc(alias = "get_transient_for")]
2980 #[doc(alias = "transient-for")]
2981 #[must_use]
2982 fn transient_for(&self) -> Option<Window> {
2983 unsafe {
2984 from_glib_none(ffi::gtk_window_get_transient_for(
2985 self.as_ref().to_glib_none().0,
2986 ))
2987 }
2988 }
2989
2990 /// Gets the type hint for this window. See [`set_type_hint()`][Self::set_type_hint()].
2991 ///
2992 /// # Returns
2993 ///
2994 /// the type hint for `self`.
2995 #[doc(alias = "gtk_window_get_type_hint")]
2996 #[doc(alias = "get_type_hint")]
2997 #[doc(alias = "type-hint")]
2998 fn type_hint(&self) -> gdk::WindowTypeHint {
2999 unsafe {
3000 from_glib(ffi::gtk_window_get_type_hint(
3001 self.as_ref().to_glib_none().0,
3002 ))
3003 }
3004 }
3005
3006 /// Gets the value set by [`set_urgency_hint()`][Self::set_urgency_hint()]
3007 ///
3008 /// # Returns
3009 ///
3010 /// [`true`] if window is urgent
3011 #[doc(alias = "gtk_window_get_urgency_hint")]
3012 #[doc(alias = "get_urgency_hint")]
3013 #[doc(alias = "urgency-hint")]
3014 fn is_urgency_hint(&self) -> bool {
3015 unsafe {
3016 from_glib(ffi::gtk_window_get_urgency_hint(
3017 self.as_ref().to_glib_none().0,
3018 ))
3019 }
3020 }
3021
3022 /// Gets the type of the window. See [`WindowType`][crate::WindowType].
3023 ///
3024 /// # Returns
3025 ///
3026 /// the type of the window
3027 #[doc(alias = "gtk_window_get_window_type")]
3028 #[doc(alias = "get_window_type")]
3029 fn window_type(&self) -> WindowType {
3030 unsafe {
3031 from_glib(ffi::gtk_window_get_window_type(
3032 self.as_ref().to_glib_none().0,
3033 ))
3034 }
3035 }
3036
3037 /// Returns whether `self` has an explicit window group.
3038 ///
3039 /// # Returns
3040 ///
3041 /// [`true`] if `self` has an explicit window group.
3042 ///
3043 /// Since 2.22
3044 #[doc(alias = "gtk_window_has_group")]
3045 fn has_group(&self) -> bool {
3046 unsafe { from_glib(ffi::gtk_window_has_group(self.as_ref().to_glib_none().0)) }
3047 }
3048
3049 /// Returns whether the input focus is within this GtkWindow.
3050 /// For real toplevel windows, this is identical to [`is_active()`][Self::is_active()],
3051 /// but for embedded windows, like [`Plug`][crate::Plug], the results will differ.
3052 ///
3053 /// # Returns
3054 ///
3055 /// [`true`] if the input focus is within this GtkWindow
3056 #[doc(alias = "gtk_window_has_toplevel_focus")]
3057 #[doc(alias = "has-toplevel-focus")]
3058 fn has_toplevel_focus(&self) -> bool {
3059 unsafe {
3060 from_glib(ffi::gtk_window_has_toplevel_focus(
3061 self.as_ref().to_glib_none().0,
3062 ))
3063 }
3064 }
3065
3066 /// Asks to iconify (i.e. minimize) the specified `self`. Note that
3067 /// you shouldn’t assume the window is definitely iconified afterward,
3068 /// because other entities (e.g. the user or
3069 /// [window manager][gtk-X11-arch]) could deiconify it
3070 /// again, or there may not be a window manager in which case
3071 /// iconification isn’t possible, etc. But normally the window will end
3072 /// up iconified. Just don’t write code that crashes if not.
3073 ///
3074 /// It’s permitted to call this function before showing a window,
3075 /// in which case the window will be iconified before it ever appears
3076 /// onscreen.
3077 ///
3078 /// You can track iconification via the “window-state-event” signal
3079 /// on [`Widget`][crate::Widget].
3080 #[doc(alias = "gtk_window_iconify")]
3081 fn iconify(&self) {
3082 unsafe {
3083 ffi::gtk_window_iconify(self.as_ref().to_glib_none().0);
3084 }
3085 }
3086
3087 /// Returns whether the window is part of the current active toplevel.
3088 /// (That is, the toplevel window receiving keystrokes.)
3089 /// The return value is [`true`] if the window is active toplevel
3090 /// itself, but also if it is, say, a [`Plug`][crate::Plug] embedded in the active toplevel.
3091 /// You might use this function if you wanted to draw a widget
3092 /// differently in an active window from a widget in an inactive window.
3093 /// See [`has_toplevel_focus()`][Self::has_toplevel_focus()]
3094 ///
3095 /// # Returns
3096 ///
3097 /// [`true`] if the window part of the current active window.
3098 #[doc(alias = "gtk_window_is_active")]
3099 #[doc(alias = "is-active")]
3100 fn is_active(&self) -> bool {
3101 unsafe { from_glib(ffi::gtk_window_is_active(self.as_ref().to_glib_none().0)) }
3102 }
3103
3104 /// Retrieves the current maximized state of `self`.
3105 ///
3106 /// Note that since maximization is ultimately handled by the window
3107 /// manager and happens asynchronously to an application request, you
3108 /// shouldn’t assume the return value of this function changing
3109 /// immediately (or at all), as an effect of calling
3110 /// [`maximize()`][Self::maximize()] or [`unmaximize()`][Self::unmaximize()].
3111 ///
3112 /// # Returns
3113 ///
3114 /// whether the window has a maximized state.
3115 #[doc(alias = "gtk_window_is_maximized")]
3116 #[doc(alias = "is-maximized")]
3117 fn is_maximized(&self) -> bool {
3118 unsafe { from_glib(ffi::gtk_window_is_maximized(self.as_ref().to_glib_none().0)) }
3119 }
3120
3121 /// Asks to maximize `self`, so that it becomes full-screen. Note that
3122 /// you shouldn’t assume the window is definitely maximized afterward,
3123 /// because other entities (e.g. the user or
3124 /// [window manager][gtk-X11-arch]) could unmaximize it
3125 /// again, and not all window managers support maximization. But
3126 /// normally the window will end up maximized. Just don’t write code
3127 /// that crashes if not.
3128 ///
3129 /// It’s permitted to call this function before showing a window,
3130 /// in which case the window will be maximized when it appears onscreen
3131 /// initially.
3132 ///
3133 /// You can track maximization via the “window-state-event” signal
3134 /// on [`Widget`][crate::Widget], or by listening to notifications on the
3135 /// [`is-maximized`][struct@crate::Window#is-maximized] property.
3136 #[doc(alias = "gtk_window_maximize")]
3137 fn maximize(&self) {
3138 unsafe {
3139 ffi::gtk_window_maximize(self.as_ref().to_glib_none().0);
3140 }
3141 }
3142
3143 /// Activates the targets associated with the mnemonic.
3144 /// ## `keyval`
3145 /// the mnemonic
3146 /// ## `modifier`
3147 /// the modifiers
3148 ///
3149 /// # Returns
3150 ///
3151 /// [`true`] if the activation is done.
3152 #[doc(alias = "gtk_window_mnemonic_activate")]
3153 fn mnemonic_activate(&self, keyval: u32, modifier: gdk::ModifierType) -> bool {
3154 unsafe {
3155 from_glib(ffi::gtk_window_mnemonic_activate(
3156 self.as_ref().to_glib_none().0,
3157 keyval,
3158 modifier.into_glib(),
3159 ))
3160 }
3161 }
3162
3163 /// Asks the [window manager][gtk-X11-arch] to move
3164 /// `self` to the given position. Window managers are free to ignore
3165 /// this; most window managers ignore requests for initial window
3166 /// positions (instead using a user-defined placement algorithm) and
3167 /// honor requests after the window has already been shown.
3168 ///
3169 /// Note: the position is the position of the gravity-determined
3170 /// reference point for the window. The gravity determines two things:
3171 /// first, the location of the reference point in root window
3172 /// coordinates; and second, which point on the window is positioned at
3173 /// the reference point.
3174 ///
3175 /// By default the gravity is [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest], so the reference
3176 /// point is simply the `x`, `y` supplied to [`move_()`][Self::move_()]. The
3177 /// top-left corner of the window decorations (aka window frame or
3178 /// border) will be placed at `x`, `y`. Therefore, to position a window
3179 /// at the top left of the screen, you want to use the default gravity
3180 /// (which is [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest]) and move the window to 0,0.
3181 ///
3182 /// To position a window at the bottom right corner of the screen, you
3183 /// would set [`gdk::Gravity::SouthEast`][crate::gdk::Gravity::SouthEast], which means that the reference
3184 /// point is at `x` + the window width and `y` + the window height, and
3185 /// the bottom-right corner of the window border will be placed at that
3186 /// reference point. So, to place a window in the bottom right corner
3187 /// you would first set gravity to south east, then write:
3188 /// `gtk_window_move (window, gdk_screen_width () - window_width,
3189 /// gdk_screen_height () - window_height)` (note that this
3190 /// example does not take multi-head scenarios into account).
3191 ///
3192 /// The [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec)
3193 /// has a nice table of gravities in the “implementation notes” section.
3194 ///
3195 /// The [`position()`][Self::position()] documentation may also be relevant.
3196 /// ## `x`
3197 /// X coordinate to move window to
3198 /// ## `y`
3199 /// Y coordinate to move window to
3200 #[doc(alias = "gtk_window_move")]
3201 #[doc(alias = "move")]
3202 fn move_(&self, x: i32, y: i32) {
3203 unsafe {
3204 ffi::gtk_window_move(self.as_ref().to_glib_none().0, x, y);
3205 }
3206 }
3207
3208 /// Presents a window to the user. This function should not be used
3209 /// as when it is called, it is too late to gather a valid timestamp
3210 /// to allow focus stealing prevention to work correctly.
3211 #[doc(alias = "gtk_window_present")]
3212 fn present(&self) {
3213 unsafe {
3214 ffi::gtk_window_present(self.as_ref().to_glib_none().0);
3215 }
3216 }
3217
3218 /// Presents a window to the user. This may mean raising the window
3219 /// in the stacking order, deiconifying it, moving it to the current
3220 /// desktop, and/or giving it the keyboard focus, possibly dependent
3221 /// on the user’s platform, window manager, and preferences.
3222 ///
3223 /// If `self` is hidden, this function calls [`WidgetExt::show()`][crate::prelude::WidgetExt::show()]
3224 /// as well.
3225 ///
3226 /// This function should be used when the user tries to open a window
3227 /// that’s already open. Say for example the preferences dialog is
3228 /// currently open, and the user chooses Preferences from the menu
3229 /// a second time; use [`present()`][Self::present()] to move the already-open dialog
3230 /// where the user can see it.
3231 ///
3232 /// Presents a window to the user in response to a user interaction. The
3233 /// timestamp should be gathered when the window was requested to be shown
3234 /// (when clicking a link for example), rather than once the window is
3235 /// ready to be shown.
3236 /// ## `timestamp`
3237 /// the timestamp of the user interaction (typically a
3238 /// button or key press event) which triggered this call
3239 #[doc(alias = "gtk_window_present_with_time")]
3240 fn present_with_time(&self, timestamp: u32) {
3241 unsafe {
3242 ffi::gtk_window_present_with_time(self.as_ref().to_glib_none().0, timestamp);
3243 }
3244 }
3245
3246 /// Propagate a key press or release event to the focus widget and
3247 /// up the focus container chain until a widget handles `event`.
3248 /// This is normally called by the default ::key_press_event and
3249 /// ::key_release_event handlers for toplevel windows,
3250 /// however in some cases it may be useful to call this directly when
3251 /// overriding the standard key handling for a toplevel window.
3252 /// ## `event`
3253 /// a [`gdk::EventKey`][crate::gdk::EventKey]
3254 ///
3255 /// # Returns
3256 ///
3257 /// [`true`] if a widget in the focus chain handled the event.
3258 #[doc(alias = "gtk_window_propagate_key_event")]
3259 fn propagate_key_event(&self, event: &gdk::EventKey) -> bool {
3260 unsafe {
3261 from_glib(ffi::gtk_window_propagate_key_event(
3262 self.as_ref().to_glib_none().0,
3263 mut_override(event.to_glib_none().0),
3264 ))
3265 }
3266 }
3267
3268 /// Reverses the effects of [`add_accel_group()`][Self::add_accel_group()].
3269 /// ## `accel_group`
3270 /// a [`AccelGroup`][crate::AccelGroup]
3271 #[doc(alias = "gtk_window_remove_accel_group")]
3272 fn remove_accel_group(&self, accel_group: &impl IsA<AccelGroup>) {
3273 unsafe {
3274 ffi::gtk_window_remove_accel_group(
3275 self.as_ref().to_glib_none().0,
3276 accel_group.as_ref().to_glib_none().0,
3277 );
3278 }
3279 }
3280
3281 /// Removes a mnemonic from this window.
3282 /// ## `keyval`
3283 /// the mnemonic
3284 /// ## `target`
3285 /// the widget that gets activated by the mnemonic
3286 #[doc(alias = "gtk_window_remove_mnemonic")]
3287 fn remove_mnemonic(&self, keyval: u32, target: &impl IsA<Widget>) {
3288 unsafe {
3289 ffi::gtk_window_remove_mnemonic(
3290 self.as_ref().to_glib_none().0,
3291 keyval,
3292 target.as_ref().to_glib_none().0,
3293 );
3294 }
3295 }
3296
3297 /// Resizes the window as if the user had done so, obeying geometry
3298 /// constraints. The default geometry constraint is that windows may
3299 /// not be smaller than their size request; to override this
3300 /// constraint, call [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] to set the window's
3301 /// request to a smaller value.
3302 ///
3303 /// If [`resize()`][Self::resize()] is called before showing a window for the
3304 /// first time, it overrides any default size set with
3305 /// [`set_default_size()`][Self::set_default_size()].
3306 ///
3307 /// Windows may not be resized smaller than 1 by 1 pixels.
3308 ///
3309 /// When using client side decorations, GTK+ will do its best to adjust
3310 /// the given size so that the resulting window size matches the
3311 /// requested size without the title bar, borders and shadows added for
3312 /// the client side decorations, but there is no guarantee that the
3313 /// result will be totally accurate because these widgets added for
3314 /// client side decorations depend on the theme and may not be realized
3315 /// or visible at the time [`resize()`][Self::resize()] is issued.
3316 ///
3317 /// If the GtkWindow has a titlebar widget (see [`set_titlebar()`][Self::set_titlebar()]), then
3318 /// typically, [`resize()`][Self::resize()] will compensate for the height of the titlebar
3319 /// widget only if the height is known when the resulting GtkWindow configuration
3320 /// is issued.
3321 /// For example, if new widgets are added after the GtkWindow configuration
3322 /// and cause the titlebar widget to grow in height, this will result in a
3323 /// window content smaller that specified by [`resize()`][Self::resize()] and not
3324 /// a larger window.
3325 /// ## `width`
3326 /// width in pixels to resize the window to
3327 /// ## `height`
3328 /// height in pixels to resize the window to
3329 #[doc(alias = "gtk_window_resize")]
3330 fn resize(&self, width: i32, height: i32) {
3331 unsafe {
3332 ffi::gtk_window_resize(self.as_ref().to_glib_none().0, width, height);
3333 }
3334 }
3335
3336 /// Windows may set a hint asking the desktop environment not to receive
3337 /// the input focus. This function sets this hint.
3338 /// ## `setting`
3339 /// [`true`] to let this window receive input focus
3340 #[doc(alias = "gtk_window_set_accept_focus")]
3341 #[doc(alias = "accept-focus")]
3342 fn set_accept_focus(&self, setting: bool) {
3343 unsafe {
3344 ffi::gtk_window_set_accept_focus(self.as_ref().to_glib_none().0, setting.into_glib());
3345 }
3346 }
3347
3348 /// Sets or unsets the [`Application`][crate::Application] associated with the window.
3349 ///
3350 /// The application will be kept alive for at least as long as it has any windows
3351 /// associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()] for a way to keep it alive
3352 /// without windows).
3353 ///
3354 /// Normally, the connection between the application and the window will remain
3355 /// until the window is destroyed, but you can explicitly remove it by setting
3356 /// the `application` to [`None`].
3357 ///
3358 /// This is equivalent to calling [`GtkApplicationExt::remove_window()`][crate::prelude::GtkApplicationExt::remove_window()] and/or
3359 /// [`GtkApplicationExt::add_window()`][crate::prelude::GtkApplicationExt::add_window()] on the old/new applications as relevant.
3360 /// ## `application`
3361 /// a [`Application`][crate::Application], or [`None`] to unset
3362 #[doc(alias = "gtk_window_set_application")]
3363 #[doc(alias = "application")]
3364 fn set_application(&self, application: Option<&impl IsA<Application>>) {
3365 unsafe {
3366 ffi::gtk_window_set_application(
3367 self.as_ref().to_glib_none().0,
3368 application.map(|p| p.as_ref()).to_glib_none().0,
3369 );
3370 }
3371 }
3372
3373 /// Marks `self` as attached to `attach_widget`. This creates a logical binding
3374 /// between the window and the widget it belongs to, which is used by GTK+ to
3375 /// propagate information such as styling or accessibility to `self` as if it
3376 /// was a children of `attach_widget`.
3377 ///
3378 /// Examples of places where specifying this relation is useful are for instance
3379 /// a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion popup window
3380 /// created by [`Entry`][crate::Entry] or a typeahead search entry created by [`TreeView`][crate::TreeView].
3381 ///
3382 /// Note that this function should not be confused with
3383 /// [`set_transient_for()`][Self::set_transient_for()], which specifies a window manager relation
3384 /// between two toplevels instead.
3385 ///
3386 /// Passing [`None`] for `attach_widget` detaches the window.
3387 /// ## `attach_widget`
3388 /// a [`Widget`][crate::Widget], or [`None`]
3389 #[doc(alias = "gtk_window_set_attached_to")]
3390 #[doc(alias = "attached-to")]
3391 fn set_attached_to(&self, attach_widget: Option<&impl IsA<Widget>>) {
3392 unsafe {
3393 ffi::gtk_window_set_attached_to(
3394 self.as_ref().to_glib_none().0,
3395 attach_widget.map(|p| p.as_ref()).to_glib_none().0,
3396 );
3397 }
3398 }
3399
3400 /// By default, windows are decorated with a title bar, resize
3401 /// controls, etc. Some [window managers][gtk-X11-arch]
3402 /// allow GTK+ to disable these decorations, creating a
3403 /// borderless window. If you set the decorated property to [`false`]
3404 /// using this function, GTK+ will do its best to convince the window
3405 /// manager not to decorate the window. Depending on the system, this
3406 /// function may not have any effect when called on a window that is
3407 /// already visible, so you should call it before calling [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
3408 ///
3409 /// On Windows, this function always works, since there’s no window manager
3410 /// policy involved.
3411 /// ## `setting`
3412 /// [`true`] to decorate the window
3413 #[doc(alias = "gtk_window_set_decorated")]
3414 #[doc(alias = "decorated")]
3415 fn set_decorated(&self, setting: bool) {
3416 unsafe {
3417 ffi::gtk_window_set_decorated(self.as_ref().to_glib_none().0, setting.into_glib());
3418 }
3419 }
3420
3421 /// The default widget is the widget that’s activated when the user
3422 /// presses Enter in a dialog (for example). This function sets or
3423 /// unsets the default widget for a [`Window`][crate::Window]. When setting (rather
3424 /// than unsetting) the default widget it’s generally easier to call
3425 /// [`WidgetExt::grab_default()`][crate::prelude::WidgetExt::grab_default()] on the widget. Before making a widget
3426 /// the default widget, you must call [`WidgetExt::set_can_default()`][crate::prelude::WidgetExt::set_can_default()] on
3427 /// the widget you’d like to make the default.
3428 /// ## `default_widget`
3429 /// widget to be the default, or [`None`]
3430 /// to unset the default widget for the toplevel
3431 #[doc(alias = "gtk_window_set_default")]
3432 fn set_default(&self, default_widget: Option<&impl IsA<Widget>>) {
3433 unsafe {
3434 ffi::gtk_window_set_default(
3435 self.as_ref().to_glib_none().0,
3436 default_widget.map(|p| p.as_ref()).to_glib_none().0,
3437 );
3438 }
3439 }
3440
3441 /// Sets the default size of a window. If the window’s “natural” size
3442 /// (its size request) is larger than the default, the default will be
3443 /// ignored. More generally, if the default size does not obey the
3444 /// geometry hints for the window ([`set_geometry_hints()`][Self::set_geometry_hints()] can
3445 /// be used to set these explicitly), the default size will be clamped
3446 /// to the nearest permitted size.
3447 ///
3448 /// Unlike [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()], which sets a size request for
3449 /// a widget and thus would keep users from shrinking the window, this
3450 /// function only sets the initial size, just as if the user had
3451 /// resized the window themselves. Users can still shrink the window
3452 /// again as they normally would. Setting a default size of -1 means to
3453 /// use the “natural” default size (the size request of the window).
3454 ///
3455 /// For more control over a window’s initial size and how resizing works,
3456 /// investigate [`set_geometry_hints()`][Self::set_geometry_hints()].
3457 ///
3458 /// For some uses, [`resize()`][Self::resize()] is a more appropriate function.
3459 /// [`resize()`][Self::resize()] changes the current size of the window, rather
3460 /// than the size to be used on initial display. [`resize()`][Self::resize()] always
3461 /// affects the window itself, not the geometry widget.
3462 ///
3463 /// The default size of a window only affects the first time a window is
3464 /// shown; if a window is hidden and re-shown, it will remember the size
3465 /// it had prior to hiding, rather than using the default size.
3466 ///
3467 /// Windows can’t actually be 0x0 in size, they must be at least 1x1, but
3468 /// passing 0 for `width` and `height` is OK, resulting in a 1x1 default size.
3469 ///
3470 /// If you use this function to reestablish a previously saved window size,
3471 /// note that the appropriate size to save is the one returned by
3472 /// [`size()`][Self::size()]. Using the window allocation directly will not
3473 /// work in all circumstances and can lead to growing or shrinking windows.
3474 /// ## `width`
3475 /// width in pixels, or -1 to unset the default width
3476 /// ## `height`
3477 /// height in pixels, or -1 to unset the default height
3478 #[doc(alias = "gtk_window_set_default_size")]
3479 fn set_default_size(&self, width: i32, height: i32) {
3480 unsafe {
3481 ffi::gtk_window_set_default_size(self.as_ref().to_glib_none().0, width, height);
3482 }
3483 }
3484
3485 /// By default, windows have a close button in the window frame. Some
3486 /// [window managers][gtk-X11-arch] allow GTK+ to
3487 /// disable this button. If you set the deletable property to [`false`]
3488 /// using this function, GTK+ will do its best to convince the window
3489 /// manager not to show a close button. Depending on the system, this
3490 /// function may not have any effect when called on a window that is
3491 /// already visible, so you should call it before calling [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
3492 ///
3493 /// On Windows, this function always works, since there’s no window manager
3494 /// policy involved.
3495 /// ## `setting`
3496 /// [`true`] to decorate the window as deletable
3497 #[doc(alias = "gtk_window_set_deletable")]
3498 #[doc(alias = "deletable")]
3499 fn set_deletable(&self, setting: bool) {
3500 unsafe {
3501 ffi::gtk_window_set_deletable(self.as_ref().to_glib_none().0, setting.into_glib());
3502 }
3503 }
3504
3505 /// If `setting` is [`true`], then destroying the transient parent of `self`
3506 /// will also destroy `self` itself. This is useful for dialogs that
3507 /// shouldn’t persist beyond the lifetime of the main window they're
3508 /// associated with, for example.
3509 /// ## `setting`
3510 /// whether to destroy `self` with its transient parent
3511 #[doc(alias = "gtk_window_set_destroy_with_parent")]
3512 #[doc(alias = "destroy-with-parent")]
3513 fn set_destroy_with_parent(&self, setting: bool) {
3514 unsafe {
3515 ffi::gtk_window_set_destroy_with_parent(
3516 self.as_ref().to_glib_none().0,
3517 setting.into_glib(),
3518 );
3519 }
3520 }
3521
3522 /// If `focus` is not the current focus widget, and is focusable, sets
3523 /// it as the focus widget for the window. If `focus` is [`None`], unsets
3524 /// the focus widget for this window. To set the focus to a particular
3525 /// widget in the toplevel, it is usually more convenient to use
3526 /// [`WidgetExt::grab_focus()`][crate::prelude::WidgetExt::grab_focus()] instead of this function.
3527 /// ## `focus`
3528 /// widget to be the new focus widget, or [`None`] to unset
3529 /// any focus widget for the toplevel window.
3530 #[doc(alias = "gtk_window_set_focus")]
3531 fn set_focus(&self, focus: Option<&impl IsA<Widget>>) {
3532 unsafe {
3533 ffi::gtk_window_set_focus(
3534 self.as_ref().to_glib_none().0,
3535 focus.map(|p| p.as_ref()).to_glib_none().0,
3536 );
3537 }
3538 }
3539
3540 /// Windows may set a hint asking the desktop environment not to receive
3541 /// the input focus when the window is mapped. This function sets this
3542 /// hint.
3543 /// ## `setting`
3544 /// [`true`] to let this window receive input focus on map
3545 #[doc(alias = "gtk_window_set_focus_on_map")]
3546 #[doc(alias = "focus-on-map")]
3547 fn set_focus_on_map(&self, setting: bool) {
3548 unsafe {
3549 ffi::gtk_window_set_focus_on_map(self.as_ref().to_glib_none().0, setting.into_glib());
3550 }
3551 }
3552
3553 /// Sets the [`focus-visible`][struct@crate::Window#focus-visible] property.
3554 /// ## `setting`
3555 /// the new value
3556 #[doc(alias = "gtk_window_set_focus_visible")]
3557 #[doc(alias = "focus-visible")]
3558 fn set_focus_visible(&self, setting: bool) {
3559 unsafe {
3560 ffi::gtk_window_set_focus_visible(self.as_ref().to_glib_none().0, setting.into_glib());
3561 }
3562 }
3563
3564 /// This function sets up hints about how a window can be resized by
3565 /// the user. You can set a minimum and maximum size; allowed resize
3566 /// increments (e.g. for xterm, you can only resize by the size of a
3567 /// character); aspect ratios; and more. See the [`gdk::Geometry`][crate::gdk::Geometry] struct.
3568 /// ## `geometry_widget`
3569 /// widget the geometry hints used to be applied to
3570 /// or [`None`]. Since 3.20 this argument is ignored and GTK behaves as if [`None`] was
3571 /// set.
3572 /// ## `geometry`
3573 /// struct containing geometry information or [`None`]
3574 /// ## `geom_mask`
3575 /// mask indicating which struct fields should be paid attention to
3576 #[doc(alias = "gtk_window_set_geometry_hints")]
3577 fn set_geometry_hints(
3578 &self,
3579 geometry_widget: Option<&impl IsA<Widget>>,
3580 geometry: Option<&gdk::Geometry>,
3581 geom_mask: gdk::WindowHints,
3582 ) {
3583 unsafe {
3584 ffi::gtk_window_set_geometry_hints(
3585 self.as_ref().to_glib_none().0,
3586 geometry_widget.map(|p| p.as_ref()).to_glib_none().0,
3587 mut_override(geometry.to_glib_none().0),
3588 geom_mask.into_glib(),
3589 );
3590 }
3591 }
3592
3593 /// Window gravity defines the meaning of coordinates passed to
3594 /// [`move_()`][Self::move_()]. See [`move_()`][Self::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
3595 /// more details.
3596 ///
3597 /// The default window gravity is [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] which will
3598 /// typically “do what you mean.”
3599 /// ## `gravity`
3600 /// window gravity
3601 #[doc(alias = "gtk_window_set_gravity")]
3602 #[doc(alias = "gravity")]
3603 fn set_gravity(&self, gravity: gdk::Gravity) {
3604 unsafe {
3605 ffi::gtk_window_set_gravity(self.as_ref().to_glib_none().0, gravity.into_glib());
3606 }
3607 }
3608
3609 /// Tells GTK+ whether to drop its extra reference to the window
3610 /// when `gtk_widget_destroy()` is called.
3611 ///
3612 /// This function is only exported for the benefit of language
3613 /// bindings which may need to keep the window alive until their
3614 /// wrapper object is garbage collected. There is no justification
3615 /// for ever calling this function in an application.
3616 /// ## `setting`
3617 /// the new value
3618 #[doc(alias = "gtk_window_set_has_user_ref_count")]
3619 fn set_has_user_ref_count(&self, setting: bool) {
3620 unsafe {
3621 ffi::gtk_window_set_has_user_ref_count(
3622 self.as_ref().to_glib_none().0,
3623 setting.into_glib(),
3624 );
3625 }
3626 }
3627
3628 /// If `setting` is [`true`], then `self` will request that it’s titlebar
3629 /// should be hidden when maximized.
3630 /// This is useful for windows that don’t convey any information other
3631 /// than the application name in the titlebar, to put the available
3632 /// screen space to better use. If the underlying window system does not
3633 /// support the request, the setting will not have any effect.
3634 ///
3635 /// Note that custom titlebars set with [`set_titlebar()`][Self::set_titlebar()] are
3636 /// not affected by this. The application is in full control of their
3637 /// content and visibility anyway.
3638 /// ## `setting`
3639 /// whether to hide the titlebar when `self` is maximized
3640 #[doc(alias = "gtk_window_set_hide_titlebar_when_maximized")]
3641 #[doc(alias = "hide-titlebar-when-maximized")]
3642 fn set_hide_titlebar_when_maximized(&self, setting: bool) {
3643 unsafe {
3644 ffi::gtk_window_set_hide_titlebar_when_maximized(
3645 self.as_ref().to_glib_none().0,
3646 setting.into_glib(),
3647 );
3648 }
3649 }
3650
3651 /// Sets up the icon representing a [`Window`][crate::Window]. This icon is used when
3652 /// the window is minimized (also known as iconified). Some window
3653 /// managers or desktop environments may also place it in the window
3654 /// frame, or display it in other contexts. On others, the icon is not
3655 /// used at all, so your mileage may vary.
3656 ///
3657 /// The icon should be provided in whatever size it was naturally
3658 /// drawn; that is, don’t scale the image before passing it to
3659 /// GTK+. Scaling is postponed until the last minute, when the desired
3660 /// final size is known, to allow best quality.
3661 ///
3662 /// If you have your icon hand-drawn in multiple sizes, use
3663 /// [`set_icon_list()`][Self::set_icon_list()]. Then the best size will be used.
3664 ///
3665 /// This function is equivalent to calling [`set_icon_list()`][Self::set_icon_list()]
3666 /// with a 1-element list.
3667 ///
3668 /// See also [`Window::set_default_icon_list()`][crate::Window::set_default_icon_list()] to set the icon
3669 /// for all windows in your application in one go.
3670 /// ## `icon`
3671 /// icon image, or [`None`]
3672 #[doc(alias = "gtk_window_set_icon")]
3673 #[doc(alias = "icon")]
3674 fn set_icon(&self, icon: Option<&gdk_pixbuf::Pixbuf>) {
3675 unsafe {
3676 ffi::gtk_window_set_icon(self.as_ref().to_glib_none().0, icon.to_glib_none().0);
3677 }
3678 }
3679
3680 /// Sets the icon for `self`.
3681 /// Warns on failure if `err` is [`None`].
3682 ///
3683 /// This function is equivalent to calling [`set_icon()`][Self::set_icon()]
3684 /// with a pixbuf created by loading the image from `filename`.
3685 /// ## `filename`
3686 /// location of icon file
3687 ///
3688 /// # Returns
3689 ///
3690 /// [`true`] if setting the icon succeeded.
3691 #[doc(alias = "gtk_window_set_icon_from_file")]
3692 fn set_icon_from_file(&self, filename: impl AsRef<std::path::Path>) -> Result<(), glib::Error> {
3693 unsafe {
3694 let mut error = std::ptr::null_mut();
3695 let is_ok = ffi::gtk_window_set_icon_from_file(
3696 self.as_ref().to_glib_none().0,
3697 filename.as_ref().to_glib_none().0,
3698 &mut error,
3699 );
3700 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
3701 if error.is_null() {
3702 Ok(())
3703 } else {
3704 Err(from_glib_full(error))
3705 }
3706 }
3707 }
3708
3709 /// Sets up the icon representing a [`Window`][crate::Window]. The icon is used when
3710 /// the window is minimized (also known as iconified). Some window
3711 /// managers or desktop environments may also place it in the window
3712 /// frame, or display it in other contexts. On others, the icon is not
3713 /// used at all, so your mileage may vary.
3714 ///
3715 /// [`set_icon_list()`][Self::set_icon_list()] allows you to pass in the same icon in
3716 /// several hand-drawn sizes. The list should contain the natural sizes
3717 /// your icon is available in; that is, don’t scale the image before
3718 /// passing it to GTK+. Scaling is postponed until the last minute,
3719 /// when the desired final size is known, to allow best quality.
3720 ///
3721 /// By passing several sizes, you may improve the final image quality
3722 /// of the icon, by reducing or eliminating automatic image scaling.
3723 ///
3724 /// Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and
3725 /// larger images (64x64, 128x128) if you have them.
3726 ///
3727 /// See also [`Window::set_default_icon_list()`][crate::Window::set_default_icon_list()] to set the icon
3728 /// for all windows in your application in one go.
3729 ///
3730 /// Note that transient windows (those who have been set transient for another
3731 /// window using [`set_transient_for()`][Self::set_transient_for()]) will inherit their
3732 /// icon from their transient parent. So there’s no need to explicitly
3733 /// set the icon on transient windows.
3734 /// ## `list`
3735 /// list of [`gdk_pixbuf::Pixbuf`][crate::gdk_pixbuf::Pixbuf]
3736 #[doc(alias = "gtk_window_set_icon_list")]
3737 fn set_icon_list(&self, list: &[gdk_pixbuf::Pixbuf]) {
3738 unsafe {
3739 ffi::gtk_window_set_icon_list(self.as_ref().to_glib_none().0, list.to_glib_none().0);
3740 }
3741 }
3742
3743 /// Sets the icon for the window from a named themed icon.
3744 /// See the docs for [`IconTheme`][crate::IconTheme] for more details.
3745 /// On some platforms, the window icon is not used at all.
3746 ///
3747 /// Note that this has nothing to do with the WM_ICON_NAME
3748 /// property which is mentioned in the ICCCM.
3749 /// ## `name`
3750 /// the name of the themed icon
3751 #[doc(alias = "gtk_window_set_icon_name")]
3752 #[doc(alias = "icon-name")]
3753 fn set_icon_name(&self, name: Option<&str>) {
3754 unsafe {
3755 ffi::gtk_window_set_icon_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
3756 }
3757 }
3758
3759 /// Asks to keep `self` above, so that it stays on top. Note that
3760 /// you shouldn’t assume the window is definitely above afterward,
3761 /// because other entities (e.g. the user or
3762 /// [window manager][gtk-X11-arch]) could not keep it above,
3763 /// and not all window managers support keeping windows above. But
3764 /// normally the window will end kept above. Just don’t write code
3765 /// that crashes if not.
3766 ///
3767 /// It’s permitted to call this function before showing a window,
3768 /// in which case the window will be kept above when it appears onscreen
3769 /// initially.
3770 ///
3771 /// You can track the above state via the “window-state-event” signal
3772 /// on [`Widget`][crate::Widget].
3773 ///
3774 /// Note that, according to the
3775 /// [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec),
3776 /// the above state is mainly meant for user preferences and should not
3777 /// be used by applications e.g. for drawing attention to their
3778 /// dialogs.
3779 /// ## `setting`
3780 /// whether to keep `self` above other windows
3781 #[doc(alias = "gtk_window_set_keep_above")]
3782 fn set_keep_above(&self, setting: bool) {
3783 unsafe {
3784 ffi::gtk_window_set_keep_above(self.as_ref().to_glib_none().0, setting.into_glib());
3785 }
3786 }
3787
3788 /// Asks to keep `self` below, so that it stays in bottom. Note that
3789 /// you shouldn’t assume the window is definitely below afterward,
3790 /// because other entities (e.g. the user or
3791 /// [window manager][gtk-X11-arch]) could not keep it below,
3792 /// and not all window managers support putting windows below. But
3793 /// normally the window will be kept below. Just don’t write code
3794 /// that crashes if not.
3795 ///
3796 /// It’s permitted to call this function before showing a window,
3797 /// in which case the window will be kept below when it appears onscreen
3798 /// initially.
3799 ///
3800 /// You can track the below state via the “window-state-event” signal
3801 /// on [`Widget`][crate::Widget].
3802 ///
3803 /// Note that, according to the
3804 /// [Extended Window Manager Hints Specification](http://www.freedesktop.org/Standards/wm-spec),
3805 /// the above state is mainly meant for user preferences and should not
3806 /// be used by applications e.g. for drawing attention to their
3807 /// dialogs.
3808 /// ## `setting`
3809 /// whether to keep `self` below other windows
3810 #[doc(alias = "gtk_window_set_keep_below")]
3811 fn set_keep_below(&self, setting: bool) {
3812 unsafe {
3813 ffi::gtk_window_set_keep_below(self.as_ref().to_glib_none().0, setting.into_glib());
3814 }
3815 }
3816
3817 /// Sets the mnemonic modifier for this window.
3818 /// ## `modifier`
3819 /// the modifier mask used to activate
3820 /// mnemonics on this window.
3821 #[doc(alias = "gtk_window_set_mnemonic_modifier")]
3822 fn set_mnemonic_modifier(&self, modifier: gdk::ModifierType) {
3823 unsafe {
3824 ffi::gtk_window_set_mnemonic_modifier(
3825 self.as_ref().to_glib_none().0,
3826 modifier.into_glib(),
3827 );
3828 }
3829 }
3830
3831 /// Sets the [`mnemonics-visible`][struct@crate::Window#mnemonics-visible] property.
3832 /// ## `setting`
3833 /// the new value
3834 #[doc(alias = "gtk_window_set_mnemonics_visible")]
3835 #[doc(alias = "mnemonics-visible")]
3836 fn set_mnemonics_visible(&self, setting: bool) {
3837 unsafe {
3838 ffi::gtk_window_set_mnemonics_visible(
3839 self.as_ref().to_glib_none().0,
3840 setting.into_glib(),
3841 );
3842 }
3843 }
3844
3845 /// Sets a window modal or non-modal. Modal windows prevent interaction
3846 /// with other windows in the same application. To keep modal dialogs
3847 /// on top of main application windows, use
3848 /// [`set_transient_for()`][Self::set_transient_for()] to make the dialog transient for the
3849 /// parent; most [window managers][gtk-X11-arch]
3850 /// will then disallow lowering the dialog below the parent.
3851 /// ## `modal`
3852 /// whether the window is modal
3853 #[doc(alias = "gtk_window_set_modal")]
3854 #[doc(alias = "modal")]
3855 fn set_modal(&self, modal: bool) {
3856 unsafe {
3857 ffi::gtk_window_set_modal(self.as_ref().to_glib_none().0, modal.into_glib());
3858 }
3859 }
3860
3861 /// Sets a position constraint for this window. If the old or new
3862 /// constraint is [`WindowPosition::CenterAlways`][crate::WindowPosition::CenterAlways], this will also cause
3863 /// the window to be repositioned to satisfy the new constraint.
3864 /// ## `position`
3865 /// a position constraint.
3866 #[doc(alias = "gtk_window_set_position")]
3867 fn set_position(&self, position: WindowPosition) {
3868 unsafe {
3869 ffi::gtk_window_set_position(self.as_ref().to_glib_none().0, position.into_glib());
3870 }
3871 }
3872
3873 /// Sets whether the user can resize a window. Windows are user resizable
3874 /// by default.
3875 /// ## `resizable`
3876 /// [`true`] if the user can resize this window
3877 #[doc(alias = "gtk_window_set_resizable")]
3878 #[doc(alias = "resizable")]
3879 fn set_resizable(&self, resizable: bool) {
3880 unsafe {
3881 ffi::gtk_window_set_resizable(self.as_ref().to_glib_none().0, resizable.into_glib());
3882 }
3883 }
3884
3885 /// This function is only useful on X11, not with other GTK+ targets.
3886 ///
3887 /// In combination with the window title, the window role allows a
3888 /// [window manager][gtk-X11-arch] to identify "the
3889 /// same" window when an application is restarted. So for example you
3890 /// might set the “toolbox” role on your app’s toolbox window, so that
3891 /// when the user restarts their session, the window manager can put
3892 /// the toolbox back in the same place.
3893 ///
3894 /// If a window already has a unique title, you don’t need to set the
3895 /// role, since the WM can use the title to identify the window when
3896 /// restoring the session.
3897 /// ## `role`
3898 /// unique identifier for the window to be used when restoring a session
3899 #[doc(alias = "gtk_window_set_role")]
3900 #[doc(alias = "role")]
3901 fn set_role(&self, role: &str) {
3902 unsafe {
3903 ffi::gtk_window_set_role(self.as_ref().to_glib_none().0, role.to_glib_none().0);
3904 }
3905 }
3906
3907 /// Sets the [`gdk::Screen`][crate::gdk::Screen] where the `self` is displayed; if
3908 /// the window is already mapped, it will be unmapped, and
3909 /// then remapped on the new screen.
3910 /// ## `screen`
3911 /// a [`gdk::Screen`][crate::gdk::Screen].
3912 #[doc(alias = "gtk_window_set_screen")]
3913 #[doc(alias = "screen")]
3914 fn set_screen(&self, screen: &gdk::Screen) {
3915 unsafe {
3916 ffi::gtk_window_set_screen(self.as_ref().to_glib_none().0, screen.to_glib_none().0);
3917 }
3918 }
3919
3920 /// Windows may set a hint asking the desktop environment not to display
3921 /// the window in the pager. This function sets this hint.
3922 /// (A "pager" is any desktop navigation tool such as a workspace
3923 /// switcher that displays a thumbnail representation of the windows
3924 /// on the screen.)
3925 /// ## `setting`
3926 /// [`true`] to keep this window from appearing in the pager
3927 #[doc(alias = "gtk_window_set_skip_pager_hint")]
3928 #[doc(alias = "skip-pager-hint")]
3929 fn set_skip_pager_hint(&self, setting: bool) {
3930 unsafe {
3931 ffi::gtk_window_set_skip_pager_hint(
3932 self.as_ref().to_glib_none().0,
3933 setting.into_glib(),
3934 );
3935 }
3936 }
3937
3938 /// Windows may set a hint asking the desktop environment not to display
3939 /// the window in the task bar. This function sets this hint.
3940 /// ## `setting`
3941 /// [`true`] to keep this window from appearing in the task bar
3942 #[doc(alias = "gtk_window_set_skip_taskbar_hint")]
3943 #[doc(alias = "skip-taskbar-hint")]
3944 fn set_skip_taskbar_hint(&self, setting: bool) {
3945 unsafe {
3946 ffi::gtk_window_set_skip_taskbar_hint(
3947 self.as_ref().to_glib_none().0,
3948 setting.into_glib(),
3949 );
3950 }
3951 }
3952
3953 /// Startup notification identifiers are used by desktop environment to
3954 /// track application startup, to provide user feedback and other
3955 /// features. This function changes the corresponding property on the
3956 /// underlying GdkWindow. Normally, startup identifier is managed
3957 /// automatically and you should only use this function in special cases
3958 /// like transferring focus from other processes. You should use this
3959 /// function before calling [`present()`][Self::present()] or any equivalent
3960 /// function generating a window map event.
3961 ///
3962 /// This function is only useful on X11, not with other GTK+ targets.
3963 /// ## `startup_id`
3964 /// a string with startup-notification identifier
3965 #[doc(alias = "gtk_window_set_startup_id")]
3966 #[doc(alias = "startup-id")]
3967 fn set_startup_id(&self, startup_id: &str) {
3968 unsafe {
3969 ffi::gtk_window_set_startup_id(
3970 self.as_ref().to_glib_none().0,
3971 startup_id.to_glib_none().0,
3972 );
3973 }
3974 }
3975
3976 /// Sets the title of the [`Window`][crate::Window]. The title of a window will be
3977 /// displayed in its title bar; on the X Window System, the title bar
3978 /// is rendered by the [window manager][gtk-X11-arch],
3979 /// so exactly how the title appears to users may vary
3980 /// according to a user’s exact configuration. The title should help a
3981 /// user distinguish this window from other windows they may have
3982 /// open. A good title might include the application name and current
3983 /// document filename, for example.
3984 /// ## `title`
3985 /// title of the window
3986 #[doc(alias = "gtk_window_set_title")]
3987 #[doc(alias = "title")]
3988 fn set_title(&self, title: &str) {
3989 unsafe {
3990 ffi::gtk_window_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
3991 }
3992 }
3993
3994 /// Sets a custom titlebar for `self`.
3995 ///
3996 /// A typical widget used here is [`HeaderBar`][crate::HeaderBar], as it provides various features
3997 /// expected of a titlebar while allowing the addition of child widgets to it.
3998 ///
3999 /// If you set a custom titlebar, GTK+ will do its best to convince
4000 /// the window manager not to put its own titlebar on the window.
4001 /// Depending on the system, this function may not work for a window
4002 /// that is already visible, so you set the titlebar before calling
4003 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
4004 /// ## `titlebar`
4005 /// the widget to use as titlebar
4006 #[doc(alias = "gtk_window_set_titlebar")]
4007 fn set_titlebar(&self, titlebar: Option<&impl IsA<Widget>>) {
4008 unsafe {
4009 ffi::gtk_window_set_titlebar(
4010 self.as_ref().to_glib_none().0,
4011 titlebar.map(|p| p.as_ref()).to_glib_none().0,
4012 );
4013 }
4014 }
4015
4016 /// Dialog windows should be set transient for the main application
4017 /// window they were spawned from. This allows
4018 /// [window managers][gtk-X11-arch] to e.g. keep the
4019 /// dialog on top of the main window, or center the dialog over the
4020 /// main window. `gtk_dialog_new_with_buttons()` and other convenience
4021 /// functions in GTK+ will sometimes call
4022 /// [`set_transient_for()`][Self::set_transient_for()] on your behalf.
4023 ///
4024 /// Passing [`None`] for `parent` unsets the current transient window.
4025 ///
4026 /// On Wayland, this function can also be used to attach a new
4027 /// [`WindowType::Popup`][crate::WindowType::Popup] to a [`WindowType::Toplevel`][crate::WindowType::Toplevel] parent already mapped
4028 /// on screen so that the [`WindowType::Popup`][crate::WindowType::Popup] will be created as a
4029 /// subsurface-based window `GDK_WINDOW_SUBSURFACE` which can be
4030 /// positioned at will relatively to the [`WindowType::Toplevel`][crate::WindowType::Toplevel] surface.
4031 ///
4032 /// On Windows, this function puts the child window on top of the parent,
4033 /// much as the window manager would have done on X.
4034 /// ## `parent`
4035 /// parent window, or [`None`]
4036 #[doc(alias = "gtk_window_set_transient_for")]
4037 #[doc(alias = "transient-for")]
4038 fn set_transient_for(&self, parent: Option<&impl IsA<Window>>) {
4039 unsafe {
4040 ffi::gtk_window_set_transient_for(
4041 self.as_ref().to_glib_none().0,
4042 parent.map(|p| p.as_ref()).to_glib_none().0,
4043 );
4044 }
4045 }
4046
4047 /// By setting the type hint for the window, you allow the window
4048 /// manager to decorate and handle the window in a way which is
4049 /// suitable to the function of the window in your application.
4050 ///
4051 /// This function should be called before the window becomes visible.
4052 ///
4053 /// `gtk_dialog_new_with_buttons()` and other convenience functions in GTK+
4054 /// will sometimes call [`set_type_hint()`][Self::set_type_hint()] on your behalf.
4055 /// ## `hint`
4056 /// the window type
4057 #[doc(alias = "gtk_window_set_type_hint")]
4058 #[doc(alias = "type-hint")]
4059 fn set_type_hint(&self, hint: gdk::WindowTypeHint) {
4060 unsafe {
4061 ffi::gtk_window_set_type_hint(self.as_ref().to_glib_none().0, hint.into_glib());
4062 }
4063 }
4064
4065 /// Windows may set a hint asking the desktop environment to draw
4066 /// the users attention to the window. This function sets this hint.
4067 /// ## `setting`
4068 /// [`true`] to mark this window as urgent
4069 #[doc(alias = "gtk_window_set_urgency_hint")]
4070 #[doc(alias = "urgency-hint")]
4071 fn set_urgency_hint(&self, setting: bool) {
4072 unsafe {
4073 ffi::gtk_window_set_urgency_hint(self.as_ref().to_glib_none().0, setting.into_glib());
4074 }
4075 }
4076
4077 /// Asks to stick `self`, which means that it will appear on all user
4078 /// desktops. Note that you shouldn’t assume the window is definitely
4079 /// stuck afterward, because other entities (e.g. the user or
4080 /// [window manager][gtk-X11-arch] could unstick it
4081 /// again, and some window managers do not support sticking
4082 /// windows. But normally the window will end up stuck. Just don't
4083 /// write code that crashes if not.
4084 ///
4085 /// It’s permitted to call this function before showing a window.
4086 ///
4087 /// You can track stickiness via the “window-state-event” signal
4088 /// on [`Widget`][crate::Widget].
4089 #[doc(alias = "gtk_window_stick")]
4090 fn stick(&self) {
4091 unsafe {
4092 ffi::gtk_window_stick(self.as_ref().to_glib_none().0);
4093 }
4094 }
4095
4096 /// Asks to toggle off the fullscreen state for `self`. Note that you
4097 /// shouldn’t assume the window is definitely not full screen
4098 /// afterward, because other entities (e.g. the user or
4099 /// [window manager][gtk-X11-arch]) could fullscreen it
4100 /// again, and not all window managers honor requests to unfullscreen
4101 /// windows. But normally the window will end up restored to its normal
4102 /// state. Just don’t write code that crashes if not.
4103 ///
4104 /// You can track the fullscreen state via the “window-state-event” signal
4105 /// on [`Widget`][crate::Widget].
4106 #[doc(alias = "gtk_window_unfullscreen")]
4107 fn unfullscreen(&self) {
4108 unsafe {
4109 ffi::gtk_window_unfullscreen(self.as_ref().to_glib_none().0);
4110 }
4111 }
4112
4113 /// Asks to unmaximize `self`. Note that you shouldn’t assume the
4114 /// window is definitely unmaximized afterward, because other entities
4115 /// (e.g. the user or [window manager][gtk-X11-arch])
4116 /// could maximize it again, and not all window
4117 /// managers honor requests to unmaximize. But normally the window will
4118 /// end up unmaximized. Just don’t write code that crashes if not.
4119 ///
4120 /// You can track maximization via the “window-state-event” signal
4121 /// on [`Widget`][crate::Widget].
4122 #[doc(alias = "gtk_window_unmaximize")]
4123 fn unmaximize(&self) {
4124 unsafe {
4125 ffi::gtk_window_unmaximize(self.as_ref().to_glib_none().0);
4126 }
4127 }
4128
4129 /// Asks to unstick `self`, which means that it will appear on only
4130 /// one of the user’s desktops. Note that you shouldn’t assume the
4131 /// window is definitely unstuck afterward, because other entities
4132 /// (e.g. the user or [window manager][gtk-X11-arch]) could
4133 /// stick it again. But normally the window will
4134 /// end up unstuck. Just don’t write code that crashes if not.
4135 ///
4136 /// You can track stickiness via the “window-state-event” signal
4137 /// on [`Widget`][crate::Widget].
4138 #[doc(alias = "gtk_window_unstick")]
4139 fn unstick(&self) {
4140 unsafe {
4141 ffi::gtk_window_unstick(self.as_ref().to_glib_none().0);
4142 }
4143 }
4144
4145 #[doc(alias = "default-height")]
4146 fn default_height(&self) -> i32 {
4147 ObjectExt::property(self.as_ref(), "default-height")
4148 }
4149
4150 #[doc(alias = "default-height")]
4151 fn set_default_height(&self, default_height: i32) {
4152 ObjectExt::set_property(self.as_ref(), "default-height", default_height)
4153 }
4154
4155 #[doc(alias = "default-width")]
4156 fn default_width(&self) -> i32 {
4157 ObjectExt::property(self.as_ref(), "default-width")
4158 }
4159
4160 #[doc(alias = "default-width")]
4161 fn set_default_width(&self, default_width: i32) {
4162 ObjectExt::set_property(self.as_ref(), "default-width", default_width)
4163 }
4164
4165 #[doc(alias = "window-position")]
4166 fn window_position(&self) -> WindowPosition {
4167 ObjectExt::property(self.as_ref(), "window-position")
4168 }
4169
4170 #[doc(alias = "window-position")]
4171 fn set_window_position(&self, window_position: WindowPosition) {
4172 ObjectExt::set_property(self.as_ref(), "window-position", window_position)
4173 }
4174
4175 /// The ::activate-default signal is a
4176 /// [keybinding signal][GtkBindingSignal]
4177 /// which gets emitted when the user activates the default widget
4178 /// of `window`.
4179 #[doc(alias = "activate-default")]
4180 fn connect_activate_default<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4181 unsafe extern "C" fn activate_default_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4182 this: *mut ffi::GtkWindow,
4183 f: glib::ffi::gpointer,
4184 ) {
4185 unsafe {
4186 let f: &F = &*(f as *const F);
4187 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4188 }
4189 }
4190 unsafe {
4191 let f: Box_<F> = Box_::new(f);
4192 connect_raw(
4193 self.as_ptr() as *mut _,
4194 c"activate-default".as_ptr(),
4195 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4196 activate_default_trampoline::<Self, F> as *const (),
4197 )),
4198 Box_::into_raw(f),
4199 )
4200 }
4201 }
4202
4203 fn emit_activate_default(&self) {
4204 self.emit_by_name::<()>("activate-default", &[]);
4205 }
4206
4207 /// The ::activate-focus signal is a
4208 /// [keybinding signal][GtkBindingSignal]
4209 /// which gets emitted when the user activates the currently
4210 /// focused widget of `window`.
4211 #[doc(alias = "activate-focus")]
4212 fn connect_activate_focus<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4213 unsafe extern "C" fn activate_focus_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4214 this: *mut ffi::GtkWindow,
4215 f: glib::ffi::gpointer,
4216 ) {
4217 unsafe {
4218 let f: &F = &*(f as *const F);
4219 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4220 }
4221 }
4222 unsafe {
4223 let f: Box_<F> = Box_::new(f);
4224 connect_raw(
4225 self.as_ptr() as *mut _,
4226 c"activate-focus".as_ptr(),
4227 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4228 activate_focus_trampoline::<Self, F> as *const (),
4229 )),
4230 Box_::into_raw(f),
4231 )
4232 }
4233 }
4234
4235 fn emit_activate_focus(&self) {
4236 self.emit_by_name::<()>("activate-focus", &[]);
4237 }
4238
4239 /// The ::enable-debugging signal is a [keybinding signal][GtkBindingSignal]
4240 /// which gets emitted when the user enables or disables interactive
4241 /// debugging. When `toggle` is [`true`], interactive debugging is toggled
4242 /// on or off, when it is [`false`], the debugger will be pointed at the
4243 /// widget under the pointer.
4244 ///
4245 /// The default bindings for this signal are Ctrl-Shift-I
4246 /// and Ctrl-Shift-D.
4247 /// ## `toggle`
4248 /// toggle the debugger
4249 ///
4250 /// # Returns
4251 ///
4252 /// [`true`] if the key binding was handled
4253 #[doc(alias = "enable-debugging")]
4254 fn connect_enable_debugging<F: Fn(&Self, bool) -> bool + 'static>(
4255 &self,
4256 f: F,
4257 ) -> SignalHandlerId {
4258 unsafe extern "C" fn enable_debugging_trampoline<
4259 P: IsA<Window>,
4260 F: Fn(&P, bool) -> bool + 'static,
4261 >(
4262 this: *mut ffi::GtkWindow,
4263 toggle: glib::ffi::gboolean,
4264 f: glib::ffi::gpointer,
4265 ) -> glib::ffi::gboolean {
4266 unsafe {
4267 let f: &F = &*(f as *const F);
4268 f(
4269 Window::from_glib_borrow(this).unsafe_cast_ref(),
4270 from_glib(toggle),
4271 )
4272 .into_glib()
4273 }
4274 }
4275 unsafe {
4276 let f: Box_<F> = Box_::new(f);
4277 connect_raw(
4278 self.as_ptr() as *mut _,
4279 c"enable-debugging".as_ptr(),
4280 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4281 enable_debugging_trampoline::<Self, F> as *const (),
4282 )),
4283 Box_::into_raw(f),
4284 )
4285 }
4286 }
4287
4288 fn emit_enable_debugging(&self, toggle: bool) -> bool {
4289 self.emit_by_name("enable-debugging", &[&toggle])
4290 }
4291
4292 /// The ::keys-changed signal gets emitted when the set of accelerators
4293 /// or mnemonics that are associated with `window` changes.
4294 #[doc(alias = "keys-changed")]
4295 fn connect_keys_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4296 unsafe extern "C" fn keys_changed_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4297 this: *mut ffi::GtkWindow,
4298 f: glib::ffi::gpointer,
4299 ) {
4300 unsafe {
4301 let f: &F = &*(f as *const F);
4302 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4303 }
4304 }
4305 unsafe {
4306 let f: Box_<F> = Box_::new(f);
4307 connect_raw(
4308 self.as_ptr() as *mut _,
4309 c"keys-changed".as_ptr(),
4310 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4311 keys_changed_trampoline::<Self, F> as *const (),
4312 )),
4313 Box_::into_raw(f),
4314 )
4315 }
4316 }
4317
4318 /// This signal is emitted whenever the currently focused widget in
4319 /// this window changes.
4320 /// ## `widget`
4321 /// the newly focused widget (or [`None`] for no focus)
4322 #[doc(alias = "set-focus")]
4323 fn connect_set_focus<F: Fn(&Self, Option<&Widget>) + 'static>(&self, f: F) -> SignalHandlerId {
4324 unsafe extern "C" fn set_focus_trampoline<
4325 P: IsA<Window>,
4326 F: Fn(&P, Option<&Widget>) + 'static,
4327 >(
4328 this: *mut ffi::GtkWindow,
4329 widget: *mut ffi::GtkWidget,
4330 f: glib::ffi::gpointer,
4331 ) {
4332 unsafe {
4333 let f: &F = &*(f as *const F);
4334 f(
4335 Window::from_glib_borrow(this).unsafe_cast_ref(),
4336 Option::<Widget>::from_glib_borrow(widget).as_ref().as_ref(),
4337 )
4338 }
4339 }
4340 unsafe {
4341 let f: Box_<F> = Box_::new(f);
4342 connect_raw(
4343 self.as_ptr() as *mut _,
4344 c"set-focus".as_ptr(),
4345 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4346 set_focus_trampoline::<Self, F> as *const (),
4347 )),
4348 Box_::into_raw(f),
4349 )
4350 }
4351 }
4352
4353 #[doc(alias = "accept-focus")]
4354 fn connect_accept_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4355 unsafe extern "C" fn notify_accept_focus_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4356 this: *mut ffi::GtkWindow,
4357 _param_spec: glib::ffi::gpointer,
4358 f: glib::ffi::gpointer,
4359 ) {
4360 unsafe {
4361 let f: &F = &*(f as *const F);
4362 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4363 }
4364 }
4365 unsafe {
4366 let f: Box_<F> = Box_::new(f);
4367 connect_raw(
4368 self.as_ptr() as *mut _,
4369 c"notify::accept-focus".as_ptr(),
4370 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4371 notify_accept_focus_trampoline::<Self, F> as *const (),
4372 )),
4373 Box_::into_raw(f),
4374 )
4375 }
4376 }
4377
4378 #[doc(alias = "application")]
4379 fn connect_application_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4380 unsafe extern "C" fn notify_application_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4381 this: *mut ffi::GtkWindow,
4382 _param_spec: glib::ffi::gpointer,
4383 f: glib::ffi::gpointer,
4384 ) {
4385 unsafe {
4386 let f: &F = &*(f as *const F);
4387 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4388 }
4389 }
4390 unsafe {
4391 let f: Box_<F> = Box_::new(f);
4392 connect_raw(
4393 self.as_ptr() as *mut _,
4394 c"notify::application".as_ptr(),
4395 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4396 notify_application_trampoline::<Self, F> as *const (),
4397 )),
4398 Box_::into_raw(f),
4399 )
4400 }
4401 }
4402
4403 #[doc(alias = "attached-to")]
4404 fn connect_attached_to_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4405 unsafe extern "C" fn notify_attached_to_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4406 this: *mut ffi::GtkWindow,
4407 _param_spec: glib::ffi::gpointer,
4408 f: glib::ffi::gpointer,
4409 ) {
4410 unsafe {
4411 let f: &F = &*(f as *const F);
4412 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4413 }
4414 }
4415 unsafe {
4416 let f: Box_<F> = Box_::new(f);
4417 connect_raw(
4418 self.as_ptr() as *mut _,
4419 c"notify::attached-to".as_ptr(),
4420 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4421 notify_attached_to_trampoline::<Self, F> as *const (),
4422 )),
4423 Box_::into_raw(f),
4424 )
4425 }
4426 }
4427
4428 #[doc(alias = "decorated")]
4429 fn connect_decorated_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4430 unsafe extern "C" fn notify_decorated_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4431 this: *mut ffi::GtkWindow,
4432 _param_spec: glib::ffi::gpointer,
4433 f: glib::ffi::gpointer,
4434 ) {
4435 unsafe {
4436 let f: &F = &*(f as *const F);
4437 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4438 }
4439 }
4440 unsafe {
4441 let f: Box_<F> = Box_::new(f);
4442 connect_raw(
4443 self.as_ptr() as *mut _,
4444 c"notify::decorated".as_ptr(),
4445 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4446 notify_decorated_trampoline::<Self, F> as *const (),
4447 )),
4448 Box_::into_raw(f),
4449 )
4450 }
4451 }
4452
4453 #[doc(alias = "default-height")]
4454 fn connect_default_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4455 unsafe extern "C" fn notify_default_height_trampoline<
4456 P: IsA<Window>,
4457 F: Fn(&P) + 'static,
4458 >(
4459 this: *mut ffi::GtkWindow,
4460 _param_spec: glib::ffi::gpointer,
4461 f: glib::ffi::gpointer,
4462 ) {
4463 unsafe {
4464 let f: &F = &*(f as *const F);
4465 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4466 }
4467 }
4468 unsafe {
4469 let f: Box_<F> = Box_::new(f);
4470 connect_raw(
4471 self.as_ptr() as *mut _,
4472 c"notify::default-height".as_ptr(),
4473 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4474 notify_default_height_trampoline::<Self, F> as *const (),
4475 )),
4476 Box_::into_raw(f),
4477 )
4478 }
4479 }
4480
4481 #[doc(alias = "default-width")]
4482 fn connect_default_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4483 unsafe extern "C" fn notify_default_width_trampoline<
4484 P: IsA<Window>,
4485 F: Fn(&P) + 'static,
4486 >(
4487 this: *mut ffi::GtkWindow,
4488 _param_spec: glib::ffi::gpointer,
4489 f: glib::ffi::gpointer,
4490 ) {
4491 unsafe {
4492 let f: &F = &*(f as *const F);
4493 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4494 }
4495 }
4496 unsafe {
4497 let f: Box_<F> = Box_::new(f);
4498 connect_raw(
4499 self.as_ptr() as *mut _,
4500 c"notify::default-width".as_ptr(),
4501 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4502 notify_default_width_trampoline::<Self, F> as *const (),
4503 )),
4504 Box_::into_raw(f),
4505 )
4506 }
4507 }
4508
4509 #[doc(alias = "deletable")]
4510 fn connect_deletable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4511 unsafe extern "C" fn notify_deletable_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4512 this: *mut ffi::GtkWindow,
4513 _param_spec: glib::ffi::gpointer,
4514 f: glib::ffi::gpointer,
4515 ) {
4516 unsafe {
4517 let f: &F = &*(f as *const F);
4518 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4519 }
4520 }
4521 unsafe {
4522 let f: Box_<F> = Box_::new(f);
4523 connect_raw(
4524 self.as_ptr() as *mut _,
4525 c"notify::deletable".as_ptr(),
4526 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4527 notify_deletable_trampoline::<Self, F> as *const (),
4528 )),
4529 Box_::into_raw(f),
4530 )
4531 }
4532 }
4533
4534 #[doc(alias = "destroy-with-parent")]
4535 fn connect_destroy_with_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4536 unsafe extern "C" fn notify_destroy_with_parent_trampoline<
4537 P: IsA<Window>,
4538 F: Fn(&P) + 'static,
4539 >(
4540 this: *mut ffi::GtkWindow,
4541 _param_spec: glib::ffi::gpointer,
4542 f: glib::ffi::gpointer,
4543 ) {
4544 unsafe {
4545 let f: &F = &*(f as *const F);
4546 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4547 }
4548 }
4549 unsafe {
4550 let f: Box_<F> = Box_::new(f);
4551 connect_raw(
4552 self.as_ptr() as *mut _,
4553 c"notify::destroy-with-parent".as_ptr(),
4554 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4555 notify_destroy_with_parent_trampoline::<Self, F> as *const (),
4556 )),
4557 Box_::into_raw(f),
4558 )
4559 }
4560 }
4561
4562 #[doc(alias = "focus-on-map")]
4563 fn connect_focus_on_map_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4564 unsafe extern "C" fn notify_focus_on_map_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4565 this: *mut ffi::GtkWindow,
4566 _param_spec: glib::ffi::gpointer,
4567 f: glib::ffi::gpointer,
4568 ) {
4569 unsafe {
4570 let f: &F = &*(f as *const F);
4571 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4572 }
4573 }
4574 unsafe {
4575 let f: Box_<F> = Box_::new(f);
4576 connect_raw(
4577 self.as_ptr() as *mut _,
4578 c"notify::focus-on-map".as_ptr(),
4579 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4580 notify_focus_on_map_trampoline::<Self, F> as *const (),
4581 )),
4582 Box_::into_raw(f),
4583 )
4584 }
4585 }
4586
4587 #[doc(alias = "focus-visible")]
4588 fn connect_focus_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4589 unsafe extern "C" fn notify_focus_visible_trampoline<
4590 P: IsA<Window>,
4591 F: Fn(&P) + 'static,
4592 >(
4593 this: *mut ffi::GtkWindow,
4594 _param_spec: glib::ffi::gpointer,
4595 f: glib::ffi::gpointer,
4596 ) {
4597 unsafe {
4598 let f: &F = &*(f as *const F);
4599 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4600 }
4601 }
4602 unsafe {
4603 let f: Box_<F> = Box_::new(f);
4604 connect_raw(
4605 self.as_ptr() as *mut _,
4606 c"notify::focus-visible".as_ptr(),
4607 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4608 notify_focus_visible_trampoline::<Self, F> as *const (),
4609 )),
4610 Box_::into_raw(f),
4611 )
4612 }
4613 }
4614
4615 #[doc(alias = "gravity")]
4616 fn connect_gravity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4617 unsafe extern "C" fn notify_gravity_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4618 this: *mut ffi::GtkWindow,
4619 _param_spec: glib::ffi::gpointer,
4620 f: glib::ffi::gpointer,
4621 ) {
4622 unsafe {
4623 let f: &F = &*(f as *const F);
4624 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4625 }
4626 }
4627 unsafe {
4628 let f: Box_<F> = Box_::new(f);
4629 connect_raw(
4630 self.as_ptr() as *mut _,
4631 c"notify::gravity".as_ptr(),
4632 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4633 notify_gravity_trampoline::<Self, F> as *const (),
4634 )),
4635 Box_::into_raw(f),
4636 )
4637 }
4638 }
4639
4640 #[doc(alias = "has-toplevel-focus")]
4641 fn connect_has_toplevel_focus_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4642 unsafe extern "C" fn notify_has_toplevel_focus_trampoline<
4643 P: IsA<Window>,
4644 F: Fn(&P) + 'static,
4645 >(
4646 this: *mut ffi::GtkWindow,
4647 _param_spec: glib::ffi::gpointer,
4648 f: glib::ffi::gpointer,
4649 ) {
4650 unsafe {
4651 let f: &F = &*(f as *const F);
4652 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4653 }
4654 }
4655 unsafe {
4656 let f: Box_<F> = Box_::new(f);
4657 connect_raw(
4658 self.as_ptr() as *mut _,
4659 c"notify::has-toplevel-focus".as_ptr(),
4660 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4661 notify_has_toplevel_focus_trampoline::<Self, F> as *const (),
4662 )),
4663 Box_::into_raw(f),
4664 )
4665 }
4666 }
4667
4668 #[doc(alias = "hide-titlebar-when-maximized")]
4669 fn connect_hide_titlebar_when_maximized_notify<F: Fn(&Self) + 'static>(
4670 &self,
4671 f: F,
4672 ) -> SignalHandlerId {
4673 unsafe extern "C" fn notify_hide_titlebar_when_maximized_trampoline<
4674 P: IsA<Window>,
4675 F: Fn(&P) + 'static,
4676 >(
4677 this: *mut ffi::GtkWindow,
4678 _param_spec: glib::ffi::gpointer,
4679 f: glib::ffi::gpointer,
4680 ) {
4681 unsafe {
4682 let f: &F = &*(f as *const F);
4683 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4684 }
4685 }
4686 unsafe {
4687 let f: Box_<F> = Box_::new(f);
4688 connect_raw(
4689 self.as_ptr() as *mut _,
4690 c"notify::hide-titlebar-when-maximized".as_ptr(),
4691 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4692 notify_hide_titlebar_when_maximized_trampoline::<Self, F> as *const (),
4693 )),
4694 Box_::into_raw(f),
4695 )
4696 }
4697 }
4698
4699 #[doc(alias = "icon")]
4700 fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4701 unsafe extern "C" fn notify_icon_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4702 this: *mut ffi::GtkWindow,
4703 _param_spec: glib::ffi::gpointer,
4704 f: glib::ffi::gpointer,
4705 ) {
4706 unsafe {
4707 let f: &F = &*(f as *const F);
4708 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4709 }
4710 }
4711 unsafe {
4712 let f: Box_<F> = Box_::new(f);
4713 connect_raw(
4714 self.as_ptr() as *mut _,
4715 c"notify::icon".as_ptr(),
4716 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4717 notify_icon_trampoline::<Self, F> as *const (),
4718 )),
4719 Box_::into_raw(f),
4720 )
4721 }
4722 }
4723
4724 #[doc(alias = "icon-name")]
4725 fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4726 unsafe extern "C" fn notify_icon_name_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4727 this: *mut ffi::GtkWindow,
4728 _param_spec: glib::ffi::gpointer,
4729 f: glib::ffi::gpointer,
4730 ) {
4731 unsafe {
4732 let f: &F = &*(f as *const F);
4733 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4734 }
4735 }
4736 unsafe {
4737 let f: Box_<F> = Box_::new(f);
4738 connect_raw(
4739 self.as_ptr() as *mut _,
4740 c"notify::icon-name".as_ptr(),
4741 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4742 notify_icon_name_trampoline::<Self, F> as *const (),
4743 )),
4744 Box_::into_raw(f),
4745 )
4746 }
4747 }
4748
4749 #[doc(alias = "is-active")]
4750 fn connect_is_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4751 unsafe extern "C" fn notify_is_active_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4752 this: *mut ffi::GtkWindow,
4753 _param_spec: glib::ffi::gpointer,
4754 f: glib::ffi::gpointer,
4755 ) {
4756 unsafe {
4757 let f: &F = &*(f as *const F);
4758 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4759 }
4760 }
4761 unsafe {
4762 let f: Box_<F> = Box_::new(f);
4763 connect_raw(
4764 self.as_ptr() as *mut _,
4765 c"notify::is-active".as_ptr(),
4766 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4767 notify_is_active_trampoline::<Self, F> as *const (),
4768 )),
4769 Box_::into_raw(f),
4770 )
4771 }
4772 }
4773
4774 #[doc(alias = "is-maximized")]
4775 fn connect_is_maximized_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4776 unsafe extern "C" fn notify_is_maximized_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4777 this: *mut ffi::GtkWindow,
4778 _param_spec: glib::ffi::gpointer,
4779 f: glib::ffi::gpointer,
4780 ) {
4781 unsafe {
4782 let f: &F = &*(f as *const F);
4783 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4784 }
4785 }
4786 unsafe {
4787 let f: Box_<F> = Box_::new(f);
4788 connect_raw(
4789 self.as_ptr() as *mut _,
4790 c"notify::is-maximized".as_ptr(),
4791 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4792 notify_is_maximized_trampoline::<Self, F> as *const (),
4793 )),
4794 Box_::into_raw(f),
4795 )
4796 }
4797 }
4798
4799 #[doc(alias = "mnemonics-visible")]
4800 fn connect_mnemonics_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4801 unsafe extern "C" fn notify_mnemonics_visible_trampoline<
4802 P: IsA<Window>,
4803 F: Fn(&P) + 'static,
4804 >(
4805 this: *mut ffi::GtkWindow,
4806 _param_spec: glib::ffi::gpointer,
4807 f: glib::ffi::gpointer,
4808 ) {
4809 unsafe {
4810 let f: &F = &*(f as *const F);
4811 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4812 }
4813 }
4814 unsafe {
4815 let f: Box_<F> = Box_::new(f);
4816 connect_raw(
4817 self.as_ptr() as *mut _,
4818 c"notify::mnemonics-visible".as_ptr(),
4819 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4820 notify_mnemonics_visible_trampoline::<Self, F> as *const (),
4821 )),
4822 Box_::into_raw(f),
4823 )
4824 }
4825 }
4826
4827 #[doc(alias = "modal")]
4828 fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4829 unsafe extern "C" fn notify_modal_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4830 this: *mut ffi::GtkWindow,
4831 _param_spec: glib::ffi::gpointer,
4832 f: glib::ffi::gpointer,
4833 ) {
4834 unsafe {
4835 let f: &F = &*(f as *const F);
4836 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4837 }
4838 }
4839 unsafe {
4840 let f: Box_<F> = Box_::new(f);
4841 connect_raw(
4842 self.as_ptr() as *mut _,
4843 c"notify::modal".as_ptr(),
4844 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4845 notify_modal_trampoline::<Self, F> as *const (),
4846 )),
4847 Box_::into_raw(f),
4848 )
4849 }
4850 }
4851
4852 #[doc(alias = "resizable")]
4853 fn connect_resizable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4854 unsafe extern "C" fn notify_resizable_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4855 this: *mut ffi::GtkWindow,
4856 _param_spec: glib::ffi::gpointer,
4857 f: glib::ffi::gpointer,
4858 ) {
4859 unsafe {
4860 let f: &F = &*(f as *const F);
4861 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4862 }
4863 }
4864 unsafe {
4865 let f: Box_<F> = Box_::new(f);
4866 connect_raw(
4867 self.as_ptr() as *mut _,
4868 c"notify::resizable".as_ptr(),
4869 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4870 notify_resizable_trampoline::<Self, F> as *const (),
4871 )),
4872 Box_::into_raw(f),
4873 )
4874 }
4875 }
4876
4877 #[doc(alias = "role")]
4878 fn connect_role_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4879 unsafe extern "C" fn notify_role_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4880 this: *mut ffi::GtkWindow,
4881 _param_spec: glib::ffi::gpointer,
4882 f: glib::ffi::gpointer,
4883 ) {
4884 unsafe {
4885 let f: &F = &*(f as *const F);
4886 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4887 }
4888 }
4889 unsafe {
4890 let f: Box_<F> = Box_::new(f);
4891 connect_raw(
4892 self.as_ptr() as *mut _,
4893 c"notify::role".as_ptr(),
4894 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4895 notify_role_trampoline::<Self, F> as *const (),
4896 )),
4897 Box_::into_raw(f),
4898 )
4899 }
4900 }
4901
4902 #[doc(alias = "screen")]
4903 fn connect_screen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4904 unsafe extern "C" fn notify_screen_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4905 this: *mut ffi::GtkWindow,
4906 _param_spec: glib::ffi::gpointer,
4907 f: glib::ffi::gpointer,
4908 ) {
4909 unsafe {
4910 let f: &F = &*(f as *const F);
4911 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4912 }
4913 }
4914 unsafe {
4915 let f: Box_<F> = Box_::new(f);
4916 connect_raw(
4917 self.as_ptr() as *mut _,
4918 c"notify::screen".as_ptr(),
4919 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4920 notify_screen_trampoline::<Self, F> as *const (),
4921 )),
4922 Box_::into_raw(f),
4923 )
4924 }
4925 }
4926
4927 #[doc(alias = "skip-pager-hint")]
4928 fn connect_skip_pager_hint_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4929 unsafe extern "C" fn notify_skip_pager_hint_trampoline<
4930 P: IsA<Window>,
4931 F: Fn(&P) + 'static,
4932 >(
4933 this: *mut ffi::GtkWindow,
4934 _param_spec: glib::ffi::gpointer,
4935 f: glib::ffi::gpointer,
4936 ) {
4937 unsafe {
4938 let f: &F = &*(f as *const F);
4939 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4940 }
4941 }
4942 unsafe {
4943 let f: Box_<F> = Box_::new(f);
4944 connect_raw(
4945 self.as_ptr() as *mut _,
4946 c"notify::skip-pager-hint".as_ptr(),
4947 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4948 notify_skip_pager_hint_trampoline::<Self, F> as *const (),
4949 )),
4950 Box_::into_raw(f),
4951 )
4952 }
4953 }
4954
4955 #[doc(alias = "skip-taskbar-hint")]
4956 fn connect_skip_taskbar_hint_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4957 unsafe extern "C" fn notify_skip_taskbar_hint_trampoline<
4958 P: IsA<Window>,
4959 F: Fn(&P) + 'static,
4960 >(
4961 this: *mut ffi::GtkWindow,
4962 _param_spec: glib::ffi::gpointer,
4963 f: glib::ffi::gpointer,
4964 ) {
4965 unsafe {
4966 let f: &F = &*(f as *const F);
4967 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4968 }
4969 }
4970 unsafe {
4971 let f: Box_<F> = Box_::new(f);
4972 connect_raw(
4973 self.as_ptr() as *mut _,
4974 c"notify::skip-taskbar-hint".as_ptr(),
4975 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
4976 notify_skip_taskbar_hint_trampoline::<Self, F> as *const (),
4977 )),
4978 Box_::into_raw(f),
4979 )
4980 }
4981 }
4982
4983 #[doc(alias = "startup-id")]
4984 fn connect_startup_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
4985 unsafe extern "C" fn notify_startup_id_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
4986 this: *mut ffi::GtkWindow,
4987 _param_spec: glib::ffi::gpointer,
4988 f: glib::ffi::gpointer,
4989 ) {
4990 unsafe {
4991 let f: &F = &*(f as *const F);
4992 f(Window::from_glib_borrow(this).unsafe_cast_ref())
4993 }
4994 }
4995 unsafe {
4996 let f: Box_<F> = Box_::new(f);
4997 connect_raw(
4998 self.as_ptr() as *mut _,
4999 c"notify::startup-id".as_ptr(),
5000 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5001 notify_startup_id_trampoline::<Self, F> as *const (),
5002 )),
5003 Box_::into_raw(f),
5004 )
5005 }
5006 }
5007
5008 #[doc(alias = "title")]
5009 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5010 unsafe extern "C" fn notify_title_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
5011 this: *mut ffi::GtkWindow,
5012 _param_spec: glib::ffi::gpointer,
5013 f: glib::ffi::gpointer,
5014 ) {
5015 unsafe {
5016 let f: &F = &*(f as *const F);
5017 f(Window::from_glib_borrow(this).unsafe_cast_ref())
5018 }
5019 }
5020 unsafe {
5021 let f: Box_<F> = Box_::new(f);
5022 connect_raw(
5023 self.as_ptr() as *mut _,
5024 c"notify::title".as_ptr(),
5025 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5026 notify_title_trampoline::<Self, F> as *const (),
5027 )),
5028 Box_::into_raw(f),
5029 )
5030 }
5031 }
5032
5033 #[doc(alias = "transient-for")]
5034 fn connect_transient_for_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5035 unsafe extern "C" fn notify_transient_for_trampoline<
5036 P: IsA<Window>,
5037 F: Fn(&P) + 'static,
5038 >(
5039 this: *mut ffi::GtkWindow,
5040 _param_spec: glib::ffi::gpointer,
5041 f: glib::ffi::gpointer,
5042 ) {
5043 unsafe {
5044 let f: &F = &*(f as *const F);
5045 f(Window::from_glib_borrow(this).unsafe_cast_ref())
5046 }
5047 }
5048 unsafe {
5049 let f: Box_<F> = Box_::new(f);
5050 connect_raw(
5051 self.as_ptr() as *mut _,
5052 c"notify::transient-for".as_ptr(),
5053 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5054 notify_transient_for_trampoline::<Self, F> as *const (),
5055 )),
5056 Box_::into_raw(f),
5057 )
5058 }
5059 }
5060
5061 #[doc(alias = "type-hint")]
5062 fn connect_type_hint_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5063 unsafe extern "C" fn notify_type_hint_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
5064 this: *mut ffi::GtkWindow,
5065 _param_spec: glib::ffi::gpointer,
5066 f: glib::ffi::gpointer,
5067 ) {
5068 unsafe {
5069 let f: &F = &*(f as *const F);
5070 f(Window::from_glib_borrow(this).unsafe_cast_ref())
5071 }
5072 }
5073 unsafe {
5074 let f: Box_<F> = Box_::new(f);
5075 connect_raw(
5076 self.as_ptr() as *mut _,
5077 c"notify::type-hint".as_ptr(),
5078 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5079 notify_type_hint_trampoline::<Self, F> as *const (),
5080 )),
5081 Box_::into_raw(f),
5082 )
5083 }
5084 }
5085
5086 #[doc(alias = "urgency-hint")]
5087 fn connect_urgency_hint_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5088 unsafe extern "C" fn notify_urgency_hint_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
5089 this: *mut ffi::GtkWindow,
5090 _param_spec: glib::ffi::gpointer,
5091 f: glib::ffi::gpointer,
5092 ) {
5093 unsafe {
5094 let f: &F = &*(f as *const F);
5095 f(Window::from_glib_borrow(this).unsafe_cast_ref())
5096 }
5097 }
5098 unsafe {
5099 let f: Box_<F> = Box_::new(f);
5100 connect_raw(
5101 self.as_ptr() as *mut _,
5102 c"notify::urgency-hint".as_ptr(),
5103 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5104 notify_urgency_hint_trampoline::<Self, F> as *const (),
5105 )),
5106 Box_::into_raw(f),
5107 )
5108 }
5109 }
5110
5111 #[doc(alias = "window-position")]
5112 fn connect_window_position_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
5113 unsafe extern "C" fn notify_window_position_trampoline<
5114 P: IsA<Window>,
5115 F: Fn(&P) + 'static,
5116 >(
5117 this: *mut ffi::GtkWindow,
5118 _param_spec: glib::ffi::gpointer,
5119 f: glib::ffi::gpointer,
5120 ) {
5121 unsafe {
5122 let f: &F = &*(f as *const F);
5123 f(Window::from_glib_borrow(this).unsafe_cast_ref())
5124 }
5125 }
5126 unsafe {
5127 let f: Box_<F> = Box_::new(f);
5128 connect_raw(
5129 self.as_ptr() as *mut _,
5130 c"notify::window-position".as_ptr(),
5131 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
5132 notify_window_position_trampoline::<Self, F> as *const (),
5133 )),
5134 Box_::into_raw(f),
5135 )
5136 }
5137 }
5138}
5139
5140impl<O: IsA<Window>> GtkWindowExt for O {}