gtk4/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#![allow(deprecated)]
5
6#[cfg(feature = "v4_20")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
8use crate::WindowGravity;
9use crate::{
10 ffi, Accessible, AccessibleRole, Align, Application, Buildable, ConstraintTarget,
11 LayoutManager, Native, Overflow, Root, ShortcutManager, Widget, WindowGroup,
12};
13use glib::{
14 object::ObjectType as _,
15 prelude::*,
16 signal::{connect_raw, SignalHandlerId},
17 translate::*,
18};
19use std::boxed::Box as Box_;
20
21glib::wrapper! {
22 /// A toplevel window which can contain other widgets.
23 ///
24 /// <picture>
25 /// <source srcset="window-dark.png" media="(prefers-color-scheme: dark)">
26 /// <img alt="An example GtkWindow" src="window.png">
27 /// </picture>
28 ///
29 /// Windows normally have decorations that are under the control
30 /// of the windowing system and allow the user to manipulate the window
31 /// (resize it, move it, close it,...).
32 ///
33 /// # GtkWindow as GtkBuildable
34 ///
35 /// The [`Window`][crate::Window] implementation of the [`Buildable`][crate::Buildable] interface supports
36 /// setting a child as the titlebar by specifying “titlebar” as the “type”
37 /// attribute of a `<child>` element.
38 ///
39 /// # Shortcuts and Gestures
40 ///
41 /// [`Window`][crate::Window] supports the following keyboard shortcuts:
42 ///
43 /// - <kbd>F10</kbd> activates the menubar, if present.
44 /// - <kbd>Alt</kbd> makes the mnemonics visible while pressed.
45 ///
46 /// The following signals have default keybindings:
47 ///
48 /// - [`activate-default`][struct@crate::Window#activate-default]
49 /// - [`activate-focus`][struct@crate::Window#activate-focus]
50 /// - [`enable-debugging`][struct@crate::Window#enable-debugging]
51 ///
52 /// # Actions
53 ///
54 /// [`Window`][crate::Window] defines a set of built-in actions:
55 ///
56 /// - `default.activate` activates the default widget.
57 /// - `window.minimize` minimizes the window.
58 /// - `window.toggle-maximized` maximizes or restores the window.
59 /// - `window.close` closes the window.
60 ///
61 /// # CSS nodes
62 ///
63 /// ```text
64 /// window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled]
65 /// ├── <child>
66 /// ╰── <titlebar child>.titlebar [.default-decoration]
67 /// ```
68 ///
69 /// [`Window`][crate::Window] has a main CSS node with name window and style class .background.
70 ///
71 /// Style classes that are typically used with the main CSS node are .csd (when
72 /// client-side decorations are in use), .solid-csd (for client-side decorations
73 /// without invisible borders), .ssd (used by mutter when rendering server-side
74 /// decorations). GtkWindow also represents window states with the following
75 /// style classes on the main node: .maximized, .fullscreen, .tiled (when supported,
76 /// also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom).
77 ///
78 /// [`Window`][crate::Window] subclasses often add their own discriminating style classes,
79 /// such as .dialog, .popup or .tooltip.
80 ///
81 /// Generally, some CSS properties don't make sense on the toplevel window node,
82 /// such as margins or padding. When client-side decorations without invisible
83 /// borders are in use (i.e. the .solid-csd style class is added to the
84 /// main window node), the CSS border of the toplevel window is used for
85 /// resize drags. In the .csd case, the shadow area outside of the window
86 /// can be used to resize it.
87 ///
88 /// [`Window`][crate::Window] adds the .titlebar and .default-decoration style classes to the
89 /// widget that is added as a titlebar child.
90 ///
91 /// # Accessibility
92 ///
93 /// [`Window`][crate::Window] uses the [enum@Gtk.AccessibleRole.window] role.
94 ///
95 /// From GTK 4.12 to 4.18, it used the [enum@Gtk.AccessibleRole.application] role.
96 ///
97 /// ## Properties
98 ///
99 ///
100 /// #### `application`
101 /// The [`Application`][crate::Application] associated with the window.
102 ///
103 /// The application will be kept alive for at least as long as it
104 /// has any windows associated with it (see g_application_hold()
105 /// for a way to keep it alive without windows).
106 ///
107 /// Normally, the connection between the application and the window
108 /// will remain until the window is destroyed, but you can explicitly
109 /// remove it by setting the this property to `NULL`.
110 ///
111 /// Readable | Writeable
112 ///
113 ///
114 /// #### `child`
115 /// The child widget.
116 ///
117 /// Readable | Writeable
118 ///
119 ///
120 /// #### `decorated`
121 /// Whether the window should have a frame (also known as *decorations*).
122 ///
123 /// Readable | Writeable
124 ///
125 ///
126 /// #### `default-height`
127 /// The default height of the window.
128 ///
129 /// Readable | Writeable
130 ///
131 ///
132 /// #### `default-widget`
133 /// The default widget.
134 ///
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `default-width`
139 /// The default width of the window.
140 ///
141 /// Readable | Writeable
142 ///
143 ///
144 /// #### `deletable`
145 /// Whether the window frame should have a close button.
146 ///
147 /// Readable | Writeable
148 ///
149 ///
150 /// #### `destroy-with-parent`
151 /// If this window should be destroyed when the parent is destroyed.
152 ///
153 /// Readable | Writeable
154 ///
155 ///
156 /// #### `display`
157 /// The display that will display this window.
158 ///
159 /// Readable | Writeable
160 ///
161 ///
162 /// #### `focus-visible`
163 /// Whether 'focus rectangles' are currently visible in this window.
164 ///
165 /// This property is maintained by GTK based on user input
166 /// and should not be set by applications.
167 ///
168 /// Readable | Writeable
169 ///
170 ///
171 /// #### `focus-widget`
172 /// The focus widget.
173 ///
174 /// Readable | Writeable
175 ///
176 ///
177 /// #### `fullscreened`
178 /// Whether the window is fullscreen.
179 ///
180 /// Setting this property is the equivalent of calling
181 /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
182 /// either operation is asynchronous, which means you will need to
183 /// connect to the ::notify signal in order to know whether the
184 /// operation was successful.
185 ///
186 /// Readable | Writeable
187 ///
188 ///
189 /// #### `gravity`
190 /// The gravity to use when resizing the window programmatically.
191 ///
192 /// Gravity describes which point of the window we want to keep
193 /// fixed (meaning that the window will grow in the opposite direction).
194 /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
195 /// want the to fix top right corner of the window.
196 ///
197 /// Readable | Writeable
198 ///
199 ///
200 /// #### `handle-menubar-accel`
201 /// Whether the window frame should handle <kbd>F10</kbd> for activating
202 /// menubars.
203 ///
204 /// Readable | Writeable
205 ///
206 ///
207 /// #### `hide-on-close`
208 /// If this window should be hidden instead of destroyed when the user clicks
209 /// the close button.
210 ///
211 /// Readable | Writeable
212 ///
213 ///
214 /// #### `icon-name`
215 /// Specifies the name of the themed icon to use as the window icon.
216 ///
217 /// See [`IconTheme`][crate::IconTheme] for more details.
218 ///
219 /// Readable | Writeable
220 ///
221 ///
222 /// #### `is-active`
223 /// Whether the toplevel is the currently active window.
224 ///
225 /// Readable
226 ///
227 ///
228 /// #### `maximized`
229 /// Whether the window is maximized.
230 ///
231 /// Setting this property is the equivalent of calling
232 /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
233 /// either operation is asynchronous, which means you will need to
234 /// connect to the ::notify signal in order to know whether the
235 /// operation was successful.
236 ///
237 /// Readable | Writeable
238 ///
239 ///
240 /// #### `mnemonics-visible`
241 /// Whether mnemonics are currently visible in this window.
242 ///
243 /// This property is maintained by GTK based on user input,
244 /// and should not be set by applications.
245 ///
246 /// Readable | Writeable
247 ///
248 ///
249 /// #### `modal`
250 /// If true, the window is modal.
251 ///
252 /// Readable | Writeable
253 ///
254 ///
255 /// #### `resizable`
256 /// If true, users can resize the window.
257 ///
258 /// Readable | Writeable
259 ///
260 ///
261 /// #### `startup-id`
262 /// A write-only property for setting window's startup notification identifier.
263 ///
264 /// Writeable
265 ///
266 ///
267 /// #### `suspended`
268 /// Whether the window is suspended.
269 ///
270 /// See [`GtkWindowExt::is_suspended()`][crate::prelude::GtkWindowExt::is_suspended()] for details about what suspended means.
271 ///
272 /// Readable
273 ///
274 ///
275 /// #### `title`
276 /// The title of the window.
277 ///
278 /// Readable | Writeable
279 ///
280 ///
281 /// #### `titlebar`
282 /// The titlebar widget.
283 ///
284 /// Readable | Writeable
285 ///
286 ///
287 /// #### `transient-for`
288 /// The transient parent of the window.
289 ///
290 /// Readable | Writeable | Construct
291 /// <details><summary><h4>Widget</h4></summary>
292 ///
293 ///
294 /// #### `can-focus`
295 /// Whether the widget or any of its descendents can accept
296 /// the input focus.
297 ///
298 /// This property is meant to be set by widget implementations,
299 /// typically in their instance init function.
300 ///
301 /// Readable | Writeable
302 ///
303 ///
304 /// #### `can-target`
305 /// Whether the widget can receive pointer events.
306 ///
307 /// Readable | Writeable
308 ///
309 ///
310 /// #### `css-classes`
311 /// A list of css classes applied to this widget.
312 ///
313 /// Readable | Writeable
314 ///
315 ///
316 /// #### `css-name`
317 /// The name of this widget in the CSS tree.
318 ///
319 /// This property is meant to be set by widget implementations,
320 /// typically in their instance init function.
321 ///
322 /// Readable | Writeable | Construct Only
323 ///
324 ///
325 /// #### `cursor`
326 /// The cursor used by @widget.
327 ///
328 /// Readable | Writeable
329 ///
330 ///
331 /// #### `focus-on-click`
332 /// Whether the widget should grab focus when it is clicked with the mouse.
333 ///
334 /// This property is only relevant for widgets that can take focus.
335 ///
336 /// Readable | Writeable
337 ///
338 ///
339 /// #### `focusable`
340 /// Whether this widget itself will accept the input focus.
341 ///
342 /// Readable | Writeable
343 ///
344 ///
345 /// #### `halign`
346 /// How to distribute horizontal space if widget gets extra space.
347 ///
348 /// Readable | Writeable
349 ///
350 ///
351 /// #### `has-default`
352 /// Whether the widget is the default widget.
353 ///
354 /// Readable
355 ///
356 ///
357 /// #### `has-focus`
358 /// Whether the widget has the input focus.
359 ///
360 /// Readable
361 ///
362 ///
363 /// #### `has-tooltip`
364 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
365 /// signal on @widget.
366 ///
367 /// A true value indicates that @widget can have a tooltip, in this case
368 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
369 /// determine whether it will provide a tooltip or not.
370 ///
371 /// Readable | Writeable
372 ///
373 ///
374 /// #### `height-request`
375 /// Overrides for height request of the widget.
376 ///
377 /// If this is -1, the natural request will be used.
378 ///
379 /// Readable | Writeable
380 ///
381 ///
382 /// #### `hexpand`
383 /// Whether to expand horizontally.
384 ///
385 /// Readable | Writeable
386 ///
387 ///
388 /// #### `hexpand-set`
389 /// Whether to use the `hexpand` property.
390 ///
391 /// Readable | Writeable
392 ///
393 ///
394 /// #### `layout-manager`
395 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
396 /// the preferred size of the widget, and allocate its children.
397 ///
398 /// This property is meant to be set by widget implementations,
399 /// typically in their instance init function.
400 ///
401 /// Readable | Writeable
402 ///
403 ///
404 /// #### `limit-events`
405 /// Makes this widget act like a modal dialog, with respect to
406 /// event delivery.
407 ///
408 /// Global event controllers will not handle events with targets
409 /// inside the widget, unless they are set up to ignore propagation
410 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
411 ///
412 /// Readable | Writeable
413 ///
414 ///
415 /// #### `margin-bottom`
416 /// Margin on bottom side of widget.
417 ///
418 /// This property adds margin outside of the widget's normal size
419 /// request, the margin will be added in addition to the size from
420 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
421 ///
422 /// Readable | Writeable
423 ///
424 ///
425 /// #### `margin-end`
426 /// Margin on end of widget, horizontally.
427 ///
428 /// This property supports left-to-right and right-to-left text
429 /// directions.
430 ///
431 /// This property adds margin outside of the widget's normal size
432 /// request, the margin will be added in addition to the size from
433 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
434 ///
435 /// Readable | Writeable
436 ///
437 ///
438 /// #### `margin-start`
439 /// Margin on start of widget, horizontally.
440 ///
441 /// This property supports left-to-right and right-to-left text
442 /// directions.
443 ///
444 /// This property adds margin outside of the widget's normal size
445 /// request, the margin will be added in addition to the size from
446 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
447 ///
448 /// Readable | Writeable
449 ///
450 ///
451 /// #### `margin-top`
452 /// Margin on top side of widget.
453 ///
454 /// This property adds margin outside of the widget's normal size
455 /// request, the margin will be added in addition to the size from
456 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
457 ///
458 /// Readable | Writeable
459 ///
460 ///
461 /// #### `name`
462 /// The name of the widget.
463 ///
464 /// Readable | Writeable
465 ///
466 ///
467 /// #### `opacity`
468 /// The requested opacity of the widget.
469 ///
470 /// Readable | Writeable
471 ///
472 ///
473 /// #### `overflow`
474 /// How content outside the widget's content area is treated.
475 ///
476 /// This property is meant to be set by widget implementations,
477 /// typically in their instance init function.
478 ///
479 /// Readable | Writeable
480 ///
481 ///
482 /// #### `parent`
483 /// The parent widget of this widget.
484 ///
485 /// Readable
486 ///
487 ///
488 /// #### `receives-default`
489 /// Whether the widget will receive the default action when it is focused.
490 ///
491 /// Readable | Writeable
492 ///
493 ///
494 /// #### `root`
495 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
496 ///
497 /// This will be `NULL` if the widget is not contained in a root widget.
498 ///
499 /// Readable
500 ///
501 ///
502 /// #### `scale-factor`
503 /// The scale factor of the widget.
504 ///
505 /// Readable
506 ///
507 ///
508 /// #### `sensitive`
509 /// Whether the widget responds to input.
510 ///
511 /// Readable | Writeable
512 ///
513 ///
514 /// #### `tooltip-markup`
515 /// Sets the text of tooltip to be the given string, which is marked up
516 /// with Pango markup.
517 ///
518 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
519 ///
520 /// This is a convenience property which will take care of getting the
521 /// tooltip shown if the given string is not `NULL`:
522 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
523 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
524 /// the default signal handler.
525 ///
526 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
527 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
528 ///
529 /// Readable | Writeable
530 ///
531 ///
532 /// #### `tooltip-text`
533 /// Sets the text of tooltip to be the given string.
534 ///
535 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
536 ///
537 /// This is a convenience property which will take care of getting the
538 /// tooltip shown if the given string is not `NULL`:
539 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
540 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
541 /// the default signal handler.
542 ///
543 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
544 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
545 ///
546 /// Readable | Writeable
547 ///
548 ///
549 /// #### `valign`
550 /// How to distribute vertical space if widget gets extra space.
551 ///
552 /// Readable | Writeable
553 ///
554 ///
555 /// #### `vexpand`
556 /// Whether to expand vertically.
557 ///
558 /// Readable | Writeable
559 ///
560 ///
561 /// #### `vexpand-set`
562 /// Whether to use the `vexpand` property.
563 ///
564 /// Readable | Writeable
565 ///
566 ///
567 /// #### `visible`
568 /// Whether the widget is visible.
569 ///
570 /// Readable | Writeable
571 ///
572 ///
573 /// #### `width-request`
574 /// Overrides for width request of the widget.
575 ///
576 /// If this is -1, the natural request will be used.
577 ///
578 /// Readable | Writeable
579 /// </details>
580 /// <details><summary><h4>Accessible</h4></summary>
581 ///
582 ///
583 /// #### `accessible-role`
584 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
585 ///
586 /// The accessible role cannot be changed once set.
587 ///
588 /// Readable | Writeable
589 /// </details>
590 ///
591 /// ## Signals
592 ///
593 ///
594 /// #### `activate-default`
595 /// Emitted when the user activates the default widget.
596 ///
597 /// This is a [keybinding signal](class.SignalAction.html).
598 ///
599 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
600 ///
601 /// Action
602 ///
603 ///
604 /// #### `activate-focus`
605 /// Emitted when the user activates the currently focused
606 /// widget of @window.
607 ///
608 /// This is a [keybinding signal](class.SignalAction.html).
609 ///
610 /// The default binding for this signal is <kbd>␣</kbd>.
611 ///
612 /// Action
613 ///
614 ///
615 /// #### `close-request`
616 /// Emitted when the user clicks on the close button of the window.
617 ///
618 ///
619 ///
620 ///
621 /// #### `enable-debugging`
622 /// Emitted when the user enables or disables interactive debugging.
623 ///
624 /// When @toggle is true, interactive debugging is toggled on or off,
625 /// when it is false, the debugger will be pointed at the widget
626 /// under the pointer.
627 ///
628 /// This is a [keybinding signal](class.SignalAction.html).
629 ///
630 /// The default bindings for this signal are
631 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> and
632 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd>.
633 ///
634 /// Action
635 ///
636 ///
637 /// #### `keys-changed`
638 /// Emitted when the set of accelerators or mnemonics that
639 /// are associated with the window changes.
640 ///
641 ///
642 /// <details><summary><h4>Widget</h4></summary>
643 ///
644 ///
645 /// #### `destroy`
646 /// Signals that all holders of a reference to the widget should release
647 /// the reference that they hold.
648 ///
649 /// May result in finalization of the widget if all references are released.
650 ///
651 /// This signal is not suitable for saving widget state.
652 ///
653 ///
654 ///
655 ///
656 /// #### `direction-changed`
657 /// Emitted when the text direction of a widget changes.
658 ///
659 ///
660 ///
661 ///
662 /// #### `hide`
663 /// Emitted when @widget is hidden.
664 ///
665 ///
666 ///
667 ///
668 /// #### `keynav-failed`
669 /// Emitted if keyboard navigation fails.
670 ///
671 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
672 ///
673 ///
674 ///
675 ///
676 /// #### `map`
677 /// Emitted when @widget is going to be mapped.
678 ///
679 /// A widget is mapped when the widget is visible (which is controlled with
680 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
681 /// are also visible.
682 ///
683 /// The `::map` signal can be used to determine whether a widget will be drawn,
684 /// for instance it can resume an animation that was stopped during the
685 /// emission of [`unmap`][struct@crate::Widget#unmap].
686 ///
687 ///
688 ///
689 ///
690 /// #### `mnemonic-activate`
691 /// Emitted when a widget is activated via a mnemonic.
692 ///
693 /// The default handler for this signal activates @widget if @group_cycling
694 /// is false, or just makes @widget grab focus if @group_cycling is true.
695 ///
696 ///
697 ///
698 ///
699 /// #### `move-focus`
700 /// Emitted when the focus is moved.
701 ///
702 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
703 ///
704 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
705 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
706 ///
707 /// Action
708 ///
709 ///
710 /// #### `query-tooltip`
711 /// Emitted when the widget’s tooltip is about to be shown.
712 ///
713 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
714 /// is true and the hover timeout has expired with the cursor hovering
715 /// above @widget; or emitted when @widget got focus in keyboard mode.
716 ///
717 /// Using the given coordinates, the signal handler should determine
718 /// whether a tooltip should be shown for @widget. If this is the case
719 /// true should be returned, false otherwise. Note that if @keyboard_mode
720 /// is true, the values of @x and @y are undefined and should not be used.
721 ///
722 /// The signal handler is free to manipulate @tooltip with the therefore
723 /// destined function calls.
724 ///
725 ///
726 ///
727 ///
728 /// #### `realize`
729 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
730 ///
731 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
732 /// or the widget has been mapped (that is, it is going to be drawn).
733 ///
734 ///
735 ///
736 ///
737 /// #### `show`
738 /// Emitted when @widget is shown.
739 ///
740 ///
741 ///
742 ///
743 /// #### `state-flags-changed`
744 /// Emitted when the widget state changes.
745 ///
746 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
747 ///
748 ///
749 ///
750 ///
751 /// #### `unmap`
752 /// Emitted when @widget is going to be unmapped.
753 ///
754 /// A widget is unmapped when either it or any of its parents up to the
755 /// toplevel widget have been set as hidden.
756 ///
757 /// As `::unmap` indicates that a widget will not be shown any longer,
758 /// it can be used to, for example, stop an animation on the widget.
759 ///
760 ///
761 ///
762 ///
763 /// #### `unrealize`
764 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
765 ///
766 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
767 /// or the widget has been unmapped (that is, it is going to be hidden).
768 ///
769 ///
770 /// </details>
771 ///
772 /// # Implements
773 ///
774 /// [`GtkWindowExt`][trait@crate::prelude::GtkWindowExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`NativeExt`][trait@crate::prelude::NativeExt], [`RootExt`][trait@crate::prelude::RootExt], [`ShortcutManagerExt`][trait@crate::prelude::ShortcutManagerExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
775 #[doc(alias = "GtkWindow")]
776 pub struct Window(Object<ffi::GtkWindow, ffi::GtkWindowClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager;
777
778 match fn {
779 type_ => || ffi::gtk_window_get_type(),
780 }
781}
782
783impl Window {
784 pub const NONE: Option<&'static Window> = None;
785
786 /// Creates a new [`Window`][crate::Window].
787 ///
788 /// To get an undecorated window (without window borders),
789 /// use [`GtkWindowExt::set_decorated()`][crate::prelude::GtkWindowExt::set_decorated()].
790 ///
791 /// All top-level windows created by this function are stored
792 /// in an internal top-level window list. This list can be obtained
793 /// from [`list_toplevels()`][Self::list_toplevels()]. Due to GTK keeping a
794 /// reference to the window internally, this function does not
795 /// return a reference to the caller.
796 ///
797 /// To delete a [`Window`][crate::Window], call `Gtk::Window::destroy()`.
798 ///
799 /// # Returns
800 ///
801 /// a new [`Window`][crate::Window]
802 #[doc(alias = "gtk_window_new")]
803 pub fn new() -> Window {
804 assert_initialized_main_thread!();
805 unsafe { Widget::from_glib_none(ffi::gtk_window_new()).unsafe_cast() }
806 }
807
808 // rustdoc-stripper-ignore-next
809 /// Creates a new builder-pattern struct instance to construct [`Window`] objects.
810 ///
811 /// This method returns an instance of [`WindowBuilder`](crate::builders::WindowBuilder) which can be used to create [`Window`] objects.
812 pub fn builder() -> WindowBuilder {
813 WindowBuilder::new()
814 }
815
816 /// Returns the fallback icon name for windows.
817 ///
818 /// The returned string is owned by GTK and should not
819 /// be modified. It is only valid until the next call to
820 /// [`set_default_icon_name()`][Self::set_default_icon_name()].
821 ///
822 /// # Returns
823 ///
824 /// the fallback icon name for windows
825 #[doc(alias = "gtk_window_get_default_icon_name")]
826 #[doc(alias = "get_default_icon_name")]
827 pub fn default_icon_name() -> Option<glib::GString> {
828 assert_initialized_main_thread!();
829 unsafe { from_glib_none(ffi::gtk_window_get_default_icon_name()) }
830 }
831
832 /// Returns the list of all existing toplevel windows.
833 ///
834 /// If you want to iterate through the list and perform actions involving
835 /// callbacks that might destroy the widgets or add new ones, be aware that
836 /// the list of toplevels will change and emit the "items-changed" signal.
837 ///
838 /// # Returns
839 ///
840 /// the list
841 /// of toplevel widgets
842 #[doc(alias = "gtk_window_get_toplevels")]
843 #[doc(alias = "get_toplevels")]
844 pub fn toplevels() -> gio::ListModel {
845 assert_initialized_main_thread!();
846 unsafe { from_glib_none(ffi::gtk_window_get_toplevels()) }
847 }
848
849 /// Returns the list of all existing toplevel windows.
850 ///
851 /// The widgets in the list are not individually referenced.
852 /// If you want to iterate through the list and perform actions
853 /// involving callbacks that might destroy the widgets, you must
854 /// call `g_list_foreach (result, (GFunc)g_object_ref, NULL)` first,
855 /// and then unref all the widgets afterwards.
856 ///
857 /// # Returns
858 ///
859 /// list of
860 /// toplevel widgets
861 #[doc(alias = "gtk_window_list_toplevels")]
862 pub fn list_toplevels() -> Vec<Widget> {
863 assert_initialized_main_thread!();
864 unsafe { FromGlibPtrContainer::from_glib_container(ffi::gtk_window_list_toplevels()) }
865 }
866
867 /// Sets whether the window should request startup notification.
868 ///
869 /// By default, after showing the first window, GTK calls
870 /// `Gdk::Toplevel::set_startup_id()`. Call this function
871 /// to disable the automatic startup notification. You might do this
872 /// if your first window is a splash screen, and you want to delay
873 /// notification until after your real main window has been shown,
874 /// for example.
875 ///
876 /// In that example, you would disable startup notification
877 /// temporarily, show your splash screen, then re-enable it so that
878 /// showing the main window would automatically result in notification.
879 /// ## `setting`
880 /// true to automatically do startup notification
881 #[doc(alias = "gtk_window_set_auto_startup_notification")]
882 pub fn set_auto_startup_notification(setting: bool) {
883 assert_initialized_main_thread!();
884 unsafe {
885 ffi::gtk_window_set_auto_startup_notification(setting.into_glib());
886 }
887 }
888
889 /// Sets an icon to be used as fallback.
890 ///
891 /// The fallback icon is used for windows that
892 /// haven't had [`GtkWindowExt::set_icon_name()`][crate::prelude::GtkWindowExt::set_icon_name()]
893 /// called on them.
894 /// ## `name`
895 /// the name of the themed icon
896 #[doc(alias = "gtk_window_set_default_icon_name")]
897 pub fn set_default_icon_name(name: &str) {
898 assert_initialized_main_thread!();
899 unsafe {
900 ffi::gtk_window_set_default_icon_name(name.to_glib_none().0);
901 }
902 }
903
904 /// Opens or closes the [interactive debugger](running.html#interactive-debugging).
905 ///
906 /// The debugger offers access to the widget hierarchy of the application
907 /// and to useful debugging tools.
908 ///
909 /// This function allows applications that already use
910 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd>
911 /// (or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd>)
912 /// for their own key shortcuts to add a different shortcut to open the Inspector.
913 ///
914 /// If you are not overriding the default key shortcuts for the Inspector,
915 /// you should not use this function.
916 /// ## `enable`
917 /// true to enable interactive debugging
918 #[doc(alias = "gtk_window_set_interactive_debugging")]
919 pub fn set_interactive_debugging(enable: bool) {
920 assert_initialized_main_thread!();
921 unsafe {
922 ffi::gtk_window_set_interactive_debugging(enable.into_glib());
923 }
924 }
925}
926
927impl Default for Window {
928 fn default() -> Self {
929 Self::new()
930 }
931}
932
933// rustdoc-stripper-ignore-next
934/// A [builder-pattern] type to construct [`Window`] objects.
935///
936/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
937#[must_use = "The builder must be built to be used"]
938pub struct WindowBuilder {
939 builder: glib::object::ObjectBuilder<'static, Window>,
940}
941
942impl WindowBuilder {
943 fn new() -> Self {
944 Self {
945 builder: glib::object::Object::builder(),
946 }
947 }
948
949 /// The [`Application`][crate::Application] associated with the window.
950 ///
951 /// The application will be kept alive for at least as long as it
952 /// has any windows associated with it (see g_application_hold()
953 /// for a way to keep it alive without windows).
954 ///
955 /// Normally, the connection between the application and the window
956 /// will remain until the window is destroyed, but you can explicitly
957 /// remove it by setting the this property to `NULL`.
958 pub fn application(self, application: &impl IsA<Application>) -> Self {
959 Self {
960 builder: self
961 .builder
962 .property("application", application.clone().upcast()),
963 }
964 }
965
966 /// The child widget.
967 pub fn child(self, child: &impl IsA<Widget>) -> Self {
968 Self {
969 builder: self.builder.property("child", child.clone().upcast()),
970 }
971 }
972
973 /// Whether the window should have a frame (also known as *decorations*).
974 pub fn decorated(self, decorated: bool) -> Self {
975 Self {
976 builder: self.builder.property("decorated", decorated),
977 }
978 }
979
980 /// The default height of the window.
981 pub fn default_height(self, default_height: i32) -> Self {
982 Self {
983 builder: self.builder.property("default-height", default_height),
984 }
985 }
986
987 /// The default widget.
988 pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
989 Self {
990 builder: self
991 .builder
992 .property("default-widget", default_widget.clone().upcast()),
993 }
994 }
995
996 /// The default width of the window.
997 pub fn default_width(self, default_width: i32) -> Self {
998 Self {
999 builder: self.builder.property("default-width", default_width),
1000 }
1001 }
1002
1003 /// Whether the window frame should have a close button.
1004 pub fn deletable(self, deletable: bool) -> Self {
1005 Self {
1006 builder: self.builder.property("deletable", deletable),
1007 }
1008 }
1009
1010 /// If this window should be destroyed when the parent is destroyed.
1011 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
1012 Self {
1013 builder: self
1014 .builder
1015 .property("destroy-with-parent", destroy_with_parent),
1016 }
1017 }
1018
1019 /// The display that will display this window.
1020 pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
1021 Self {
1022 builder: self.builder.property("display", display.clone().upcast()),
1023 }
1024 }
1025
1026 /// Whether 'focus rectangles' are currently visible in this window.
1027 ///
1028 /// This property is maintained by GTK based on user input
1029 /// and should not be set by applications.
1030 pub fn focus_visible(self, focus_visible: bool) -> Self {
1031 Self {
1032 builder: self.builder.property("focus-visible", focus_visible),
1033 }
1034 }
1035
1036 /// The focus widget.
1037 pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
1038 Self {
1039 builder: self
1040 .builder
1041 .property("focus-widget", focus_widget.clone().upcast()),
1042 }
1043 }
1044
1045 /// Whether the window is fullscreen.
1046 ///
1047 /// Setting this property is the equivalent of calling
1048 /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
1049 /// either operation is asynchronous, which means you will need to
1050 /// connect to the ::notify signal in order to know whether the
1051 /// operation was successful.
1052 pub fn fullscreened(self, fullscreened: bool) -> Self {
1053 Self {
1054 builder: self.builder.property("fullscreened", fullscreened),
1055 }
1056 }
1057
1058 /// The gravity to use when resizing the window programmatically.
1059 ///
1060 /// Gravity describes which point of the window we want to keep
1061 /// fixed (meaning that the window will grow in the opposite direction).
1062 /// For example, a gravity of `GTK_WINDOW_GRAVITY_TOP_RIGHT` means that we
1063 /// want the to fix top right corner of the window.
1064 #[cfg(feature = "v4_20")]
1065 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1066 pub fn gravity(self, gravity: WindowGravity) -> Self {
1067 Self {
1068 builder: self.builder.property("gravity", gravity),
1069 }
1070 }
1071
1072 /// Whether the window frame should handle <kbd>F10</kbd> for activating
1073 /// menubars.
1074 #[cfg(feature = "v4_2")]
1075 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
1076 pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
1077 Self {
1078 builder: self
1079 .builder
1080 .property("handle-menubar-accel", handle_menubar_accel),
1081 }
1082 }
1083
1084 /// If this window should be hidden instead of destroyed when the user clicks
1085 /// the close button.
1086 pub fn hide_on_close(self, hide_on_close: bool) -> Self {
1087 Self {
1088 builder: self.builder.property("hide-on-close", hide_on_close),
1089 }
1090 }
1091
1092 /// Specifies the name of the themed icon to use as the window icon.
1093 ///
1094 /// See [`IconTheme`][crate::IconTheme] for more details.
1095 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1096 Self {
1097 builder: self.builder.property("icon-name", icon_name.into()),
1098 }
1099 }
1100
1101 /// Whether the window is maximized.
1102 ///
1103 /// Setting this property is the equivalent of calling
1104 /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
1105 /// either operation is asynchronous, which means you will need to
1106 /// connect to the ::notify signal in order to know whether the
1107 /// operation was successful.
1108 pub fn maximized(self, maximized: bool) -> Self {
1109 Self {
1110 builder: self.builder.property("maximized", maximized),
1111 }
1112 }
1113
1114 /// Whether mnemonics are currently visible in this window.
1115 ///
1116 /// This property is maintained by GTK based on user input,
1117 /// and should not be set by applications.
1118 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
1119 Self {
1120 builder: self
1121 .builder
1122 .property("mnemonics-visible", mnemonics_visible),
1123 }
1124 }
1125
1126 /// If true, the window is modal.
1127 pub fn modal(self, modal: bool) -> Self {
1128 Self {
1129 builder: self.builder.property("modal", modal),
1130 }
1131 }
1132
1133 /// If true, users can resize the window.
1134 pub fn resizable(self, resizable: bool) -> Self {
1135 Self {
1136 builder: self.builder.property("resizable", resizable),
1137 }
1138 }
1139
1140 /// A write-only property for setting window's startup notification identifier.
1141 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
1142 Self {
1143 builder: self.builder.property("startup-id", startup_id.into()),
1144 }
1145 }
1146
1147 /// The title of the window.
1148 pub fn title(self, title: impl Into<glib::GString>) -> Self {
1149 Self {
1150 builder: self.builder.property("title", title.into()),
1151 }
1152 }
1153
1154 /// The titlebar widget.
1155 #[cfg(feature = "v4_6")]
1156 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1157 pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
1158 Self {
1159 builder: self.builder.property("titlebar", titlebar.clone().upcast()),
1160 }
1161 }
1162
1163 /// The transient parent of the window.
1164 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
1165 Self {
1166 builder: self
1167 .builder
1168 .property("transient-for", transient_for.clone().upcast()),
1169 }
1170 }
1171
1172 /// Whether the widget or any of its descendents can accept
1173 /// the input focus.
1174 ///
1175 /// This property is meant to be set by widget implementations,
1176 /// typically in their instance init function.
1177 pub fn can_focus(self, can_focus: bool) -> Self {
1178 Self {
1179 builder: self.builder.property("can-focus", can_focus),
1180 }
1181 }
1182
1183 /// Whether the widget can receive pointer events.
1184 pub fn can_target(self, can_target: bool) -> Self {
1185 Self {
1186 builder: self.builder.property("can-target", can_target),
1187 }
1188 }
1189
1190 /// A list of css classes applied to this widget.
1191 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1192 Self {
1193 builder: self.builder.property("css-classes", css_classes.into()),
1194 }
1195 }
1196
1197 /// The name of this widget in the CSS tree.
1198 ///
1199 /// This property is meant to be set by widget implementations,
1200 /// typically in their instance init function.
1201 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1202 Self {
1203 builder: self.builder.property("css-name", css_name.into()),
1204 }
1205 }
1206
1207 /// The cursor used by @widget.
1208 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1209 Self {
1210 builder: self.builder.property("cursor", cursor.clone()),
1211 }
1212 }
1213
1214 /// Whether the widget should grab focus when it is clicked with the mouse.
1215 ///
1216 /// This property is only relevant for widgets that can take focus.
1217 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1218 Self {
1219 builder: self.builder.property("focus-on-click", focus_on_click),
1220 }
1221 }
1222
1223 /// Whether this widget itself will accept the input focus.
1224 pub fn focusable(self, focusable: bool) -> Self {
1225 Self {
1226 builder: self.builder.property("focusable", focusable),
1227 }
1228 }
1229
1230 /// How to distribute horizontal space if widget gets extra space.
1231 pub fn halign(self, halign: Align) -> Self {
1232 Self {
1233 builder: self.builder.property("halign", halign),
1234 }
1235 }
1236
1237 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1238 /// signal on @widget.
1239 ///
1240 /// A true value indicates that @widget can have a tooltip, in this case
1241 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1242 /// determine whether it will provide a tooltip or not.
1243 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1244 Self {
1245 builder: self.builder.property("has-tooltip", has_tooltip),
1246 }
1247 }
1248
1249 /// Overrides for height request of the widget.
1250 ///
1251 /// If this is -1, the natural request will be used.
1252 pub fn height_request(self, height_request: i32) -> Self {
1253 Self {
1254 builder: self.builder.property("height-request", height_request),
1255 }
1256 }
1257
1258 /// Whether to expand horizontally.
1259 pub fn hexpand(self, hexpand: bool) -> Self {
1260 Self {
1261 builder: self.builder.property("hexpand", hexpand),
1262 }
1263 }
1264
1265 /// Whether to use the `hexpand` property.
1266 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1267 Self {
1268 builder: self.builder.property("hexpand-set", hexpand_set),
1269 }
1270 }
1271
1272 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1273 /// the preferred size of the widget, and allocate its children.
1274 ///
1275 /// This property is meant to be set by widget implementations,
1276 /// typically in their instance init function.
1277 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1278 Self {
1279 builder: self
1280 .builder
1281 .property("layout-manager", layout_manager.clone().upcast()),
1282 }
1283 }
1284
1285 /// Makes this widget act like a modal dialog, with respect to
1286 /// event delivery.
1287 ///
1288 /// Global event controllers will not handle events with targets
1289 /// inside the widget, unless they are set up to ignore propagation
1290 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1291 #[cfg(feature = "v4_18")]
1292 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1293 pub fn limit_events(self, limit_events: bool) -> Self {
1294 Self {
1295 builder: self.builder.property("limit-events", limit_events),
1296 }
1297 }
1298
1299 /// Margin on bottom side of widget.
1300 ///
1301 /// This property adds margin outside of the widget's normal size
1302 /// request, the margin will be added in addition to the size from
1303 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1304 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1305 Self {
1306 builder: self.builder.property("margin-bottom", margin_bottom),
1307 }
1308 }
1309
1310 /// Margin on end of widget, horizontally.
1311 ///
1312 /// This property supports left-to-right and right-to-left text
1313 /// directions.
1314 ///
1315 /// This property adds margin outside of the widget's normal size
1316 /// request, the margin will be added in addition to the size from
1317 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1318 pub fn margin_end(self, margin_end: i32) -> Self {
1319 Self {
1320 builder: self.builder.property("margin-end", margin_end),
1321 }
1322 }
1323
1324 /// Margin on start of widget, horizontally.
1325 ///
1326 /// This property supports left-to-right and right-to-left text
1327 /// directions.
1328 ///
1329 /// This property adds margin outside of the widget's normal size
1330 /// request, the margin will be added in addition to the size from
1331 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1332 pub fn margin_start(self, margin_start: i32) -> Self {
1333 Self {
1334 builder: self.builder.property("margin-start", margin_start),
1335 }
1336 }
1337
1338 /// Margin on top side of widget.
1339 ///
1340 /// This property adds margin outside of the widget's normal size
1341 /// request, the margin will be added in addition to the size from
1342 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1343 pub fn margin_top(self, margin_top: i32) -> Self {
1344 Self {
1345 builder: self.builder.property("margin-top", margin_top),
1346 }
1347 }
1348
1349 /// The name of the widget.
1350 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1351 Self {
1352 builder: self.builder.property("name", name.into()),
1353 }
1354 }
1355
1356 /// The requested opacity of the widget.
1357 pub fn opacity(self, opacity: f64) -> Self {
1358 Self {
1359 builder: self.builder.property("opacity", opacity),
1360 }
1361 }
1362
1363 /// How content outside the widget's content area is treated.
1364 ///
1365 /// This property is meant to be set by widget implementations,
1366 /// typically in their instance init function.
1367 pub fn overflow(self, overflow: Overflow) -> Self {
1368 Self {
1369 builder: self.builder.property("overflow", overflow),
1370 }
1371 }
1372
1373 /// Whether the widget will receive the default action when it is focused.
1374 pub fn receives_default(self, receives_default: bool) -> Self {
1375 Self {
1376 builder: self.builder.property("receives-default", receives_default),
1377 }
1378 }
1379
1380 /// Whether the widget responds to input.
1381 pub fn sensitive(self, sensitive: bool) -> Self {
1382 Self {
1383 builder: self.builder.property("sensitive", sensitive),
1384 }
1385 }
1386
1387 /// Sets the text of tooltip to be the given string, which is marked up
1388 /// with Pango markup.
1389 ///
1390 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1391 ///
1392 /// This is a convenience property which will take care of getting the
1393 /// tooltip shown if the given string is not `NULL`:
1394 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1395 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1396 /// the default signal handler.
1397 ///
1398 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1399 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1400 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1401 Self {
1402 builder: self
1403 .builder
1404 .property("tooltip-markup", tooltip_markup.into()),
1405 }
1406 }
1407
1408 /// Sets the text of tooltip to be the given string.
1409 ///
1410 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1411 ///
1412 /// This is a convenience property which will take care of getting the
1413 /// tooltip shown if the given string is not `NULL`:
1414 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1415 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1416 /// the default signal handler.
1417 ///
1418 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1419 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1420 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1421 Self {
1422 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1423 }
1424 }
1425
1426 /// How to distribute vertical space if widget gets extra space.
1427 pub fn valign(self, valign: Align) -> Self {
1428 Self {
1429 builder: self.builder.property("valign", valign),
1430 }
1431 }
1432
1433 /// Whether to expand vertically.
1434 pub fn vexpand(self, vexpand: bool) -> Self {
1435 Self {
1436 builder: self.builder.property("vexpand", vexpand),
1437 }
1438 }
1439
1440 /// Whether to use the `vexpand` property.
1441 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1442 Self {
1443 builder: self.builder.property("vexpand-set", vexpand_set),
1444 }
1445 }
1446
1447 /// Whether the widget is visible.
1448 pub fn visible(self, visible: bool) -> Self {
1449 Self {
1450 builder: self.builder.property("visible", visible),
1451 }
1452 }
1453
1454 /// Overrides for width request of the widget.
1455 ///
1456 /// If this is -1, the natural request will be used.
1457 pub fn width_request(self, width_request: i32) -> Self {
1458 Self {
1459 builder: self.builder.property("width-request", width_request),
1460 }
1461 }
1462
1463 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1464 ///
1465 /// The accessible role cannot be changed once set.
1466 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1467 Self {
1468 builder: self.builder.property("accessible-role", accessible_role),
1469 }
1470 }
1471
1472 // rustdoc-stripper-ignore-next
1473 /// Build the [`Window`].
1474 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1475 pub fn build(self) -> Window {
1476 assert_initialized_main_thread!();
1477 self.builder.build()
1478 }
1479}
1480
1481/// Trait containing all [`struct@Window`] methods.
1482///
1483/// # Implementors
1484///
1485/// [`AboutDialog`][struct@crate::AboutDialog], [`ApplicationWindow`][struct@crate::ApplicationWindow], [`Assistant`][struct@crate::Assistant], [`Dialog`][struct@crate::Dialog], [`ShortcutsWindow`][struct@crate::ShortcutsWindow], [`Window`][struct@crate::Window]
1486pub trait GtkWindowExt: IsA<Window> + 'static {
1487 /// Requests that the window is closed.
1488 ///
1489 /// This is similar to what happens when a window manager
1490 /// close button is clicked.
1491 ///
1492 /// This function can be used with close buttons in custom
1493 /// titlebars.
1494 #[doc(alias = "gtk_window_close")]
1495 fn close(&self) {
1496 unsafe {
1497 ffi::gtk_window_close(self.as_ref().to_glib_none().0);
1498 }
1499 }
1500
1501 #[doc(alias = "gtk_window_destroy")]
1502 fn destroy(&self) {
1503 unsafe {
1504 ffi::gtk_window_destroy(self.as_ref().to_glib_none().0);
1505 }
1506 }
1507
1508 /// Asks to place the window in the fullscreen state.
1509 ///
1510 /// Note that you shouldn’t assume the window is definitely fullscreen
1511 /// afterward, because other entities (e.g. the user or window manager)
1512 /// unfullscreen it again, and not all window managers honor requests
1513 /// to fullscreen windows.
1514 ///
1515 /// If a window is not explicitly fullscreened or unfullscreened before
1516 /// it is shown, the initial state is at the window managers discretion.
1517 ///
1518 /// You can track the result of this operation via the
1519 /// [`state`][struct@crate::Gdk::Toplevel#state] property, or by listening to
1520 /// notifications of the [`fullscreened`][struct@crate::Window#fullscreened] property.
1521 #[doc(alias = "gtk_window_fullscreen")]
1522 fn fullscreen(&self) {
1523 unsafe {
1524 ffi::gtk_window_fullscreen(self.as_ref().to_glib_none().0);
1525 }
1526 }
1527
1528 /// Asks to place the window in the fullscreen state on the given monitor.
1529 ///
1530 /// Note that you shouldn't assume the window is definitely fullscreen
1531 /// afterward, or that the windowing system allows fullscreen windows on
1532 /// any given monitor.
1533 ///
1534 /// You can track the result of this operation via the
1535 /// [`state`][struct@crate::Gdk::Toplevel#state] property, or by listening to
1536 /// notifications of the [`fullscreened`][struct@crate::Window#fullscreened] property.
1537 /// ## `monitor`
1538 /// which monitor to go fullscreen on
1539 #[doc(alias = "gtk_window_fullscreen_on_monitor")]
1540 fn fullscreen_on_monitor(&self, monitor: &gdk::Monitor) {
1541 unsafe {
1542 ffi::gtk_window_fullscreen_on_monitor(
1543 self.as_ref().to_glib_none().0,
1544 monitor.to_glib_none().0,
1545 );
1546 }
1547 }
1548
1549 /// Gets the application object associated with the window.
1550 ///
1551 /// # Returns
1552 ///
1553 /// the application
1554 #[doc(alias = "gtk_window_get_application")]
1555 #[doc(alias = "get_application")]
1556 fn application(&self) -> Option<Application> {
1557 unsafe {
1558 from_glib_none(ffi::gtk_window_get_application(
1559 self.as_ref().to_glib_none().0,
1560 ))
1561 }
1562 }
1563
1564 /// Gets the child widget of the window.
1565 ///
1566 /// # Returns
1567 ///
1568 /// the child widget of @self
1569 #[doc(alias = "gtk_window_get_child")]
1570 #[doc(alias = "get_child")]
1571 fn child(&self) -> Option<Widget> {
1572 unsafe { from_glib_none(ffi::gtk_window_get_child(self.as_ref().to_glib_none().0)) }
1573 }
1574
1575 /// Returns whether the window has been set to have decorations.
1576 ///
1577 /// # Returns
1578 ///
1579 /// true if the window has been set to have decorations
1580 #[doc(alias = "gtk_window_get_decorated")]
1581 #[doc(alias = "get_decorated")]
1582 #[doc(alias = "decorated")]
1583 fn is_decorated(&self) -> bool {
1584 unsafe {
1585 from_glib(ffi::gtk_window_get_decorated(
1586 self.as_ref().to_glib_none().0,
1587 ))
1588 }
1589 }
1590
1591 /// Gets the default size of the window.
1592 ///
1593 /// A value of 0 for the width or height indicates that a default
1594 /// size has not been explicitly set for that dimension, so the
1595 /// “natural” size of the window will be used.
1596 ///
1597 /// This function is the recommended way for [saving window state
1598 /// across restarts of applications](https://developer.gnome.org/documentation/tutorials/save-state.html).
1599 ///
1600 /// # Returns
1601 ///
1602 ///
1603 /// ## `width`
1604 /// location to store the default width
1605 ///
1606 /// ## `height`
1607 /// location to store the default height
1608 #[doc(alias = "gtk_window_get_default_size")]
1609 #[doc(alias = "get_default_size")]
1610 fn default_size(&self) -> (i32, i32) {
1611 unsafe {
1612 let mut width = std::mem::MaybeUninit::uninit();
1613 let mut height = std::mem::MaybeUninit::uninit();
1614 ffi::gtk_window_get_default_size(
1615 self.as_ref().to_glib_none().0,
1616 width.as_mut_ptr(),
1617 height.as_mut_ptr(),
1618 );
1619 (width.assume_init(), height.assume_init())
1620 }
1621 }
1622
1623 /// Returns the default widget for @self.
1624 ///
1625 /// # Returns
1626 ///
1627 /// the default widget
1628 #[doc(alias = "gtk_window_get_default_widget")]
1629 #[doc(alias = "get_default_widget")]
1630 #[doc(alias = "default-widget")]
1631 fn default_widget(&self) -> Option<Widget> {
1632 unsafe {
1633 from_glib_none(ffi::gtk_window_get_default_widget(
1634 self.as_ref().to_glib_none().0,
1635 ))
1636 }
1637 }
1638
1639 /// Returns whether the window has been set to have a close button.
1640 ///
1641 /// # Returns
1642 ///
1643 /// true if the window has been set to have a close button
1644 #[doc(alias = "gtk_window_get_deletable")]
1645 #[doc(alias = "get_deletable")]
1646 #[doc(alias = "deletable")]
1647 fn is_deletable(&self) -> bool {
1648 unsafe {
1649 from_glib(ffi::gtk_window_get_deletable(
1650 self.as_ref().to_glib_none().0,
1651 ))
1652 }
1653 }
1654
1655 /// Returns whether the window will be destroyed with its transient parent.
1656 ///
1657 /// # Returns
1658 ///
1659 /// true if the window will be destroyed with its transient parent
1660 #[doc(alias = "gtk_window_get_destroy_with_parent")]
1661 #[doc(alias = "get_destroy_with_parent")]
1662 #[doc(alias = "destroy-with-parent")]
1663 fn must_destroy_with_parent(&self) -> bool {
1664 unsafe {
1665 from_glib(ffi::gtk_window_get_destroy_with_parent(
1666 self.as_ref().to_glib_none().0,
1667 ))
1668 }
1669 }
1670
1671 /// Retrieves the current focused widget within the window.
1672 ///
1673 /// Note that this is the widget that would have the focus
1674 /// if the toplevel window focused; if the toplevel window
1675 /// is not focused then `gtk_widget_has_focus (widget)` will
1676 /// not be false for the widget.
1677 ///
1678 /// # Returns
1679 ///
1680 /// the currently focused widget
1681 #[doc(alias = "gtk_window_get_focus")]
1682 #[doc(alias = "get_focus")]
1683 #[doc(alias = "focus-widget")]
1684 fn focus(&self) -> Option<Widget> {
1685 unsafe { from_glib_none(ffi::gtk_window_get_focus(self.as_ref().to_glib_none().0)) }
1686 }
1687
1688 /// Gets whether “focus rectangles” are supposed to be visible.
1689 ///
1690 /// # Returns
1691 ///
1692 /// true if “focus rectangles” are supposed to be visible
1693 /// in this window
1694 #[doc(alias = "gtk_window_get_focus_visible")]
1695 #[doc(alias = "get_focus_visible")]
1696 #[doc(alias = "focus-visible")]
1697 fn gets_focus_visible(&self) -> bool {
1698 unsafe {
1699 from_glib(ffi::gtk_window_get_focus_visible(
1700 self.as_ref().to_glib_none().0,
1701 ))
1702 }
1703 }
1704
1705 /// Returns the gravity that is used when changing the window size programmatically.
1706 ///
1707 /// # Returns
1708 ///
1709 /// the gravity
1710 #[cfg(feature = "v4_20")]
1711 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1712 #[doc(alias = "gtk_window_get_gravity")]
1713 #[doc(alias = "get_gravity")]
1714 fn gravity(&self) -> WindowGravity {
1715 unsafe { from_glib(ffi::gtk_window_get_gravity(self.as_ref().to_glib_none().0)) }
1716 }
1717
1718 /// Returns the group for the window.
1719 ///
1720 /// If the window has no group, then the default group is returned.
1721 ///
1722 /// # Returns
1723 ///
1724 /// the window group for @self
1725 /// or the default group
1726 #[doc(alias = "gtk_window_get_group")]
1727 #[doc(alias = "get_group")]
1728 fn group(&self) -> WindowGroup {
1729 unsafe { from_glib_none(ffi::gtk_window_get_group(self.as_ref().to_glib_none().0)) }
1730 }
1731
1732 /// Returns whether this window reacts to <kbd>F10</kbd>
1733 /// presses by activating a menubar it contains.
1734 ///
1735 /// # Returns
1736 ///
1737 /// true if the window handles <kbd>F10</kbd>
1738 #[cfg(feature = "v4_2")]
1739 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
1740 #[doc(alias = "gtk_window_get_handle_menubar_accel")]
1741 #[doc(alias = "get_handle_menubar_accel")]
1742 #[doc(alias = "handle-menubar-accel")]
1743 fn is_handle_menubar_accel(&self) -> bool {
1744 unsafe {
1745 from_glib(ffi::gtk_window_get_handle_menubar_accel(
1746 self.as_ref().to_glib_none().0,
1747 ))
1748 }
1749 }
1750
1751 /// Returns whether the window will be hidden instead of destroyed when the close
1752 /// button is clicked.
1753 ///
1754 /// # Returns
1755 ///
1756 /// true if the window will be hidden
1757 #[doc(alias = "gtk_window_get_hide_on_close")]
1758 #[doc(alias = "get_hide_on_close")]
1759 #[doc(alias = "hide-on-close")]
1760 fn hides_on_close(&self) -> bool {
1761 unsafe {
1762 from_glib(ffi::gtk_window_get_hide_on_close(
1763 self.as_ref().to_glib_none().0,
1764 ))
1765 }
1766 }
1767
1768 /// Returns the name of the themed icon for the window.
1769 ///
1770 /// # Returns
1771 ///
1772 /// the icon name
1773 #[doc(alias = "gtk_window_get_icon_name")]
1774 #[doc(alias = "get_icon_name")]
1775 #[doc(alias = "icon-name")]
1776 fn icon_name(&self) -> Option<glib::GString> {
1777 unsafe {
1778 from_glib_none(ffi::gtk_window_get_icon_name(
1779 self.as_ref().to_glib_none().0,
1780 ))
1781 }
1782 }
1783
1784 /// Gets whether mnemonics are supposed to be visible.
1785 ///
1786 /// # Returns
1787 ///
1788 /// true if mnemonics are supposed to be visible
1789 /// in this window
1790 #[doc(alias = "gtk_window_get_mnemonics_visible")]
1791 #[doc(alias = "get_mnemonics_visible")]
1792 #[doc(alias = "mnemonics-visible")]
1793 fn is_mnemonics_visible(&self) -> bool {
1794 unsafe {
1795 from_glib(ffi::gtk_window_get_mnemonics_visible(
1796 self.as_ref().to_glib_none().0,
1797 ))
1798 }
1799 }
1800
1801 /// Returns whether the window is modal.
1802 ///
1803 /// # Returns
1804 ///
1805 /// true if the window is set to be modal and
1806 /// establishes a grab when shown
1807 #[doc(alias = "gtk_window_get_modal")]
1808 #[doc(alias = "get_modal")]
1809 #[doc(alias = "modal")]
1810 fn is_modal(&self) -> bool {
1811 unsafe { from_glib(ffi::gtk_window_get_modal(self.as_ref().to_glib_none().0)) }
1812 }
1813
1814 /// Gets whether the user can resize the window.
1815 ///
1816 /// # Returns
1817 ///
1818 /// true if the user can resize the window
1819 #[doc(alias = "gtk_window_get_resizable")]
1820 #[doc(alias = "get_resizable")]
1821 #[doc(alias = "resizable")]
1822 fn is_resizable(&self) -> bool {
1823 unsafe {
1824 from_glib(ffi::gtk_window_get_resizable(
1825 self.as_ref().to_glib_none().0,
1826 ))
1827 }
1828 }
1829
1830 /// Retrieves the title of the window.
1831 ///
1832 /// # Returns
1833 ///
1834 /// the title
1835 #[doc(alias = "gtk_window_get_title")]
1836 #[doc(alias = "get_title")]
1837 fn title(&self) -> Option<glib::GString> {
1838 unsafe { from_glib_none(ffi::gtk_window_get_title(self.as_ref().to_glib_none().0)) }
1839 }
1840
1841 /// Returns the titlebar that has been set with
1842 /// [`set_titlebar()`][Self::set_titlebar()].
1843 ///
1844 /// # Returns
1845 ///
1846 /// the titlebar
1847 #[doc(alias = "gtk_window_get_titlebar")]
1848 #[doc(alias = "get_titlebar")]
1849 fn titlebar(&self) -> Option<Widget> {
1850 unsafe { from_glib_none(ffi::gtk_window_get_titlebar(self.as_ref().to_glib_none().0)) }
1851 }
1852
1853 /// Fetches the transient parent for this window.
1854 ///
1855 /// # Returns
1856 ///
1857 /// the transient parent
1858 #[doc(alias = "gtk_window_get_transient_for")]
1859 #[doc(alias = "get_transient_for")]
1860 #[doc(alias = "transient-for")]
1861 #[must_use]
1862 fn transient_for(&self) -> Option<Window> {
1863 unsafe {
1864 from_glib_none(ffi::gtk_window_get_transient_for(
1865 self.as_ref().to_glib_none().0,
1866 ))
1867 }
1868 }
1869
1870 /// Returns whether the window has an explicit window group.
1871 ///
1872 /// # Returns
1873 ///
1874 /// true if @self has an explicit window group
1875 #[doc(alias = "gtk_window_has_group")]
1876 fn has_group(&self) -> bool {
1877 unsafe { from_glib(ffi::gtk_window_has_group(self.as_ref().to_glib_none().0)) }
1878 }
1879
1880 /// Returns whether the window is part of the current active toplevel.
1881 ///
1882 /// The active toplevel is the window receiving keystrokes.
1883 ///
1884 /// The return value is [`true`] if the window is active toplevel itself.
1885 /// You might use this function if you wanted to draw a widget
1886 /// differently in an active window from a widget in an inactive window.
1887 ///
1888 /// # Returns
1889 ///
1890 /// true if the window part of the current active window.
1891 #[doc(alias = "gtk_window_is_active")]
1892 #[doc(alias = "is-active")]
1893 fn is_active(&self) -> bool {
1894 unsafe { from_glib(ffi::gtk_window_is_active(self.as_ref().to_glib_none().0)) }
1895 }
1896
1897 /// Retrieves the current fullscreen state of the window.
1898 ///
1899 /// Note that since fullscreening is ultimately handled by the window
1900 /// manager and happens asynchronously to an application request, you
1901 /// shouldn’t assume the return value of this function changing
1902 /// immediately (or at all), as an effect of calling
1903 /// [`fullscreen()`][Self::fullscreen()] or [`unfullscreen()`][Self::unfullscreen()].
1904 ///
1905 /// If the window isn't yet mapped, the value returned will whether the
1906 /// initial requested state is fullscreen.
1907 ///
1908 /// # Returns
1909 ///
1910 /// whether the window is fullscreen
1911 #[doc(alias = "gtk_window_is_fullscreen")]
1912 #[doc(alias = "fullscreened")]
1913 fn is_fullscreen(&self) -> bool {
1914 unsafe {
1915 from_glib(ffi::gtk_window_is_fullscreen(
1916 self.as_ref().to_glib_none().0,
1917 ))
1918 }
1919 }
1920
1921 /// Retrieves the current maximized state of the window.
1922 ///
1923 /// Note that since maximization is ultimately handled by the window
1924 /// manager and happens asynchronously to an application request, you
1925 /// shouldn’t assume the return value of this function changing
1926 /// immediately (or at all), as an effect of calling
1927 /// [`maximize()`][Self::maximize()] or [`unmaximize()`][Self::unmaximize()].
1928 ///
1929 /// If the window isn't yet mapped, the value returned will whether the
1930 /// initial requested state is maximized.
1931 ///
1932 /// # Returns
1933 ///
1934 /// whether the window is maximized
1935 #[doc(alias = "gtk_window_is_maximized")]
1936 #[doc(alias = "maximized")]
1937 fn is_maximized(&self) -> bool {
1938 unsafe { from_glib(ffi::gtk_window_is_maximized(self.as_ref().to_glib_none().0)) }
1939 }
1940
1941 /// Retrieves the current suspended state of the window.
1942 ///
1943 /// A window being suspended means it's currently not visible
1944 /// to the user, for example by being on a inactive workspace,
1945 /// minimized, obstructed.
1946 ///
1947 /// # Returns
1948 ///
1949 /// whether the window is suspended
1950 #[cfg(feature = "v4_12")]
1951 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
1952 #[doc(alias = "gtk_window_is_suspended")]
1953 #[doc(alias = "suspended")]
1954 fn is_suspended(&self) -> bool {
1955 unsafe { from_glib(ffi::gtk_window_is_suspended(self.as_ref().to_glib_none().0)) }
1956 }
1957
1958 /// Asks to maximize the window, so that it fills the screen.
1959 ///
1960 /// Note that you shouldn’t assume the window is definitely maximized
1961 /// afterward, because other entities (e.g. the user or window manager)
1962 /// could unmaximize it again, and not all window managers support
1963 /// maximization.
1964 ///
1965 /// It’s permitted to call this function before showing a window,
1966 /// in which case the window will be maximized when it appears onscreen
1967 /// initially.
1968 ///
1969 /// If a window is not explicitly maximized or unmaximized before it is
1970 /// shown, the initial state is at the window managers discretion. For
1971 /// example, it might decide to maximize a window that almost fills the
1972 /// screen.
1973 ///
1974 /// You can track the result of this operation via the
1975 /// [`state`][struct@crate::Gdk::Toplevel#state] property, or by listening to
1976 /// notifications on the [`maximized`][struct@crate::Window#maximized]
1977 /// property.
1978 #[doc(alias = "gtk_window_maximize")]
1979 fn maximize(&self) {
1980 unsafe {
1981 ffi::gtk_window_maximize(self.as_ref().to_glib_none().0);
1982 }
1983 }
1984
1985 /// Asks to minimize the window.
1986 ///
1987 /// Note that you shouldn’t assume the window is definitely minimized
1988 /// afterward, because the windowing system might not support this
1989 /// functionality; other entities (e.g. the user or the window manager)
1990 /// could unminimize it again, or there may not be a window manager in
1991 /// which case minimization isn’t possible, etc.
1992 ///
1993 /// It’s permitted to call this function before showing a window,
1994 /// in which case the window will be minimized before it ever appears
1995 /// onscreen.
1996 ///
1997 /// You can track result of this operation via the
1998 /// [`state`][struct@crate::Gdk::Toplevel#state] property.
1999 #[doc(alias = "gtk_window_minimize")]
2000 fn minimize(&self) {
2001 unsafe {
2002 ffi::gtk_window_minimize(self.as_ref().to_glib_none().0);
2003 }
2004 }
2005
2006 /// Presents a window to the user.
2007 ///
2008 /// This may mean raising the window in the stacking order,
2009 /// unminimizing it, moving it to the current desktop and/or
2010 /// giving it the keyboard focus (possibly dependent on the user’s
2011 /// platform, window manager and preferences).
2012 ///
2013 /// If @self is hidden, this function also makes it visible.
2014 #[doc(alias = "gtk_window_present")]
2015 fn present(&self) {
2016 unsafe {
2017 ffi::gtk_window_present(self.as_ref().to_glib_none().0);
2018 }
2019 }
2020
2021 /// Presents a window to the user in response to an user interaction.
2022 ///
2023 /// See [`present()`][Self::present()] for more details.
2024 ///
2025 /// The timestamp should be gathered when the window was requested
2026 /// to be shown (when clicking a link for example), rather than once
2027 /// the window is ready to be shown.
2028 ///
2029 /// # Deprecated since 4.14
2030 ///
2031 /// Use [`present()`][Self::present()]
2032 /// ## `timestamp`
2033 /// the timestamp of the user interaction (typically a
2034 /// button or key press event) which triggered this call
2035 #[cfg_attr(feature = "v4_14", deprecated = "Since 4.14")]
2036 #[allow(deprecated)]
2037 #[doc(alias = "gtk_window_present_with_time")]
2038 fn present_with_time(&self, timestamp: u32) {
2039 unsafe {
2040 ffi::gtk_window_present_with_time(self.as_ref().to_glib_none().0, timestamp);
2041 }
2042 }
2043
2044 /// Sets or unsets the application object associated with the window.
2045 ///
2046 /// The application will be kept alive for at least as long as it has
2047 /// any windows associated with it (see `Gio::Application::hold()`
2048 /// for a way to keep it alive without windows).
2049 ///
2050 /// Normally, the connection between the application and the window will
2051 /// remain until the window is destroyed, but you can explicitly remove
2052 /// it by setting the @application to [`None`].
2053 ///
2054 /// This is equivalent to calling [`GtkApplicationExt::remove_window()`][crate::prelude::GtkApplicationExt::remove_window()]
2055 /// and/or [`GtkApplicationExt::add_window()`][crate::prelude::GtkApplicationExt::add_window()] on the old/new applications
2056 /// as relevant.
2057 /// ## `application`
2058 /// a [`Application`][crate::Application]
2059 #[doc(alias = "gtk_window_set_application")]
2060 #[doc(alias = "application")]
2061 fn set_application(&self, application: Option<&impl IsA<Application>>) {
2062 unsafe {
2063 ffi::gtk_window_set_application(
2064 self.as_ref().to_glib_none().0,
2065 application.map(|p| p.as_ref()).to_glib_none().0,
2066 );
2067 }
2068 }
2069
2070 /// Sets the child widget of the window.
2071 /// ## `child`
2072 /// the child widget
2073 #[doc(alias = "gtk_window_set_child")]
2074 #[doc(alias = "child")]
2075 fn set_child(&self, child: Option<&impl IsA<Widget>>) {
2076 unsafe {
2077 ffi::gtk_window_set_child(
2078 self.as_ref().to_glib_none().0,
2079 child.map(|p| p.as_ref()).to_glib_none().0,
2080 );
2081 }
2082 }
2083
2084 /// Sets whether the window should be decorated.
2085 ///
2086 /// By default, windows are decorated with a title bar, resize
2087 /// controls, etc. Some window managers allow GTK to disable these
2088 /// decorations, creating a borderless window. If you set the decorated
2089 /// property to false using this function, GTK will do its best to
2090 /// convince the window manager not to decorate the window. Depending on
2091 /// the system, this function may not have any effect when called on a
2092 /// window that is already visible, so you should call it before calling
2093 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
2094 ///
2095 /// On Windows, this function always works, since there’s no window manager
2096 /// policy involved.
2097 /// ## `setting`
2098 /// true to decorate the window
2099 #[doc(alias = "gtk_window_set_decorated")]
2100 #[doc(alias = "decorated")]
2101 fn set_decorated(&self, setting: bool) {
2102 unsafe {
2103 ffi::gtk_window_set_decorated(self.as_ref().to_glib_none().0, setting.into_glib());
2104 }
2105 }
2106
2107 /// Sets the default size of a window.
2108 ///
2109 /// The default size of a window is the size that will be used
2110 /// if no other constraints apply.
2111 ///
2112 /// The default size will be updated whenever the window is resized
2113 /// to reflect the new size, unless the window is forced to a size,
2114 /// like when it is maximized or fullscreened.
2115 ///
2116 /// If the window’s minimum size request is larger than
2117 /// the default, the default will be ignored.
2118 ///
2119 /// Setting the default size to a value <= 0 will cause it to be
2120 /// ignored and the natural size request will be used instead. It
2121 /// is possible to do this while the window is showing to "reset"
2122 /// it to its initial size.
2123 ///
2124 /// Unlike [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()], which sets a size
2125 /// request for a widget and thus would keep users from shrinking
2126 /// the window, this function only sets the initial size, just as
2127 /// if the user had resized the window themselves. Users can still
2128 /// shrink the window again as they normally would. Setting a default
2129 /// size of -1 means to use the “natural” default size (the size request
2130 /// of the window).
2131 ///
2132 /// If you use this function to reestablish a previously saved window size,
2133 /// note that the appropriate size to save is the one returned by
2134 /// [`default_size()`][Self::default_size()]. Using the window allocation
2135 /// directly will not work in all circumstances and can lead to growing
2136 /// or shrinking windows.
2137 /// ## `width`
2138 /// width in pixels, or -1 to unset the default width
2139 /// ## `height`
2140 /// height in pixels, or -1 to unset the default height
2141 #[doc(alias = "gtk_window_set_default_size")]
2142 fn set_default_size(&self, width: i32, height: i32) {
2143 unsafe {
2144 ffi::gtk_window_set_default_size(self.as_ref().to_glib_none().0, width, height);
2145 }
2146 }
2147
2148 /// Sets the default widget.
2149 ///
2150 /// The default widget is the widget that is activated
2151 /// when the user presses <kbd>Enter</kbd> in a dialog
2152 /// (for example).
2153 /// ## `default_widget`
2154 /// widget to be the default
2155 #[doc(alias = "gtk_window_set_default_widget")]
2156 #[doc(alias = "default-widget")]
2157 fn set_default_widget(&self, default_widget: Option<&impl IsA<Widget>>) {
2158 unsafe {
2159 ffi::gtk_window_set_default_widget(
2160 self.as_ref().to_glib_none().0,
2161 default_widget.map(|p| p.as_ref()).to_glib_none().0,
2162 );
2163 }
2164 }
2165
2166 /// Sets whether the window should be deletable.
2167 ///
2168 /// By default, windows have a close button in the window frame.
2169 /// Some window managers allow GTK to disable this button. If you
2170 /// set the deletable property to false using this function, GTK
2171 /// will do its best to convince the window manager not to show a
2172 /// close button. Depending on the system, this function may not
2173 /// have any effect when called on a window that is already visible,
2174 /// so you should call it before calling [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
2175 ///
2176 /// On Windows, this function always works, since there’s no window
2177 /// manager policy involved.
2178 /// ## `setting`
2179 /// true to decorate the window as deletable
2180 #[doc(alias = "gtk_window_set_deletable")]
2181 #[doc(alias = "deletable")]
2182 fn set_deletable(&self, setting: bool) {
2183 unsafe {
2184 ffi::gtk_window_set_deletable(self.as_ref().to_glib_none().0, setting.into_glib());
2185 }
2186 }
2187
2188 /// Sets whether to destroy the window when the transient parent is destroyed.
2189 ///
2190 /// This is useful for dialogs that shouldn’t persist beyond the lifetime
2191 /// of the main window they are associated with, for example.
2192 /// ## `setting`
2193 /// whether to destroy the window with its transient parent
2194 #[doc(alias = "gtk_window_set_destroy_with_parent")]
2195 #[doc(alias = "destroy-with-parent")]
2196 fn set_destroy_with_parent(&self, setting: bool) {
2197 unsafe {
2198 ffi::gtk_window_set_destroy_with_parent(
2199 self.as_ref().to_glib_none().0,
2200 setting.into_glib(),
2201 );
2202 }
2203 }
2204
2205 /// Sets the display where the window is displayed.
2206 ///
2207 /// If the window is already mapped, it will be unmapped,
2208 /// and then remapped on the new display.
2209 /// ## `display`
2210 /// a display
2211 #[doc(alias = "gtk_window_set_display")]
2212 #[doc(alias = "display")]
2213 fn set_display(&self, display: &impl IsA<gdk::Display>) {
2214 unsafe {
2215 ffi::gtk_window_set_display(
2216 self.as_ref().to_glib_none().0,
2217 display.as_ref().to_glib_none().0,
2218 );
2219 }
2220 }
2221
2222 /// Sets the focus widget.
2223 ///
2224 /// If @focus is not the current focus widget, and is focusable,
2225 /// sets it as the focus widget for the window. If @focus is [`None`],
2226 /// unsets the focus widget for this window. To set the focus to a
2227 /// particular widget in the toplevel, it is usually more convenient
2228 /// to use [`WidgetExt::grab_focus()`][crate::prelude::WidgetExt::grab_focus()] instead of this function.
2229 /// ## `focus`
2230 /// the new focus widget
2231 #[doc(alias = "gtk_window_set_focus")]
2232 #[doc(alias = "focus-widget")]
2233 fn set_focus(&self, focus: Option<&impl IsA<Widget>>) {
2234 unsafe {
2235 ffi::gtk_window_set_focus(
2236 self.as_ref().to_glib_none().0,
2237 focus.map(|p| p.as_ref()).to_glib_none().0,
2238 );
2239 }
2240 }
2241
2242 /// Sets whether “focus rectangles” are supposed to be visible.
2243 ///
2244 /// This property is maintained by GTK based on user input,
2245 /// and should not be set by applications.
2246 /// ## `setting`
2247 /// the new value
2248 #[doc(alias = "gtk_window_set_focus_visible")]
2249 #[doc(alias = "focus-visible")]
2250 fn set_focus_visible(&self, setting: bool) {
2251 unsafe {
2252 ffi::gtk_window_set_focus_visible(self.as_ref().to_glib_none().0, setting.into_glib());
2253 }
2254 }
2255
2256 /// Sets the gravity that is used when changing the window size programmatically.
2257 /// ## `gravity`
2258 /// the new gravity
2259 #[cfg(feature = "v4_20")]
2260 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
2261 #[doc(alias = "gtk_window_set_gravity")]
2262 #[doc(alias = "gravity")]
2263 fn set_gravity(&self, gravity: WindowGravity) {
2264 unsafe {
2265 ffi::gtk_window_set_gravity(self.as_ref().to_glib_none().0, gravity.into_glib());
2266 }
2267 }
2268
2269 /// Sets whether this window should react to <kbd>F10</kbd>
2270 /// presses by activating a menubar it contains.
2271 /// ## `handle_menubar_accel`
2272 /// true to make @self handle <kbd>F10</kbd>
2273 #[cfg(feature = "v4_2")]
2274 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
2275 #[doc(alias = "gtk_window_set_handle_menubar_accel")]
2276 #[doc(alias = "handle-menubar-accel")]
2277 fn set_handle_menubar_accel(&self, handle_menubar_accel: bool) {
2278 unsafe {
2279 ffi::gtk_window_set_handle_menubar_accel(
2280 self.as_ref().to_glib_none().0,
2281 handle_menubar_accel.into_glib(),
2282 );
2283 }
2284 }
2285
2286 /// Sets whether clicking the close button will hide the window instead
2287 /// of destroying it.
2288 /// ## `setting`
2289 /// whether to hide the window when it is closed
2290 #[doc(alias = "gtk_window_set_hide_on_close")]
2291 #[doc(alias = "hide-on-close")]
2292 fn set_hide_on_close(&self, setting: bool) {
2293 unsafe {
2294 ffi::gtk_window_set_hide_on_close(self.as_ref().to_glib_none().0, setting.into_glib());
2295 }
2296 }
2297
2298 /// Sets the icon for the window from a named themed icon.
2299 ///
2300 /// See the docs for [`IconTheme`][crate::IconTheme] for more details.
2301 /// On some platforms, the window icon is not used at all.
2302 ///
2303 /// Note that this has nothing to do with the WM_ICON_NAME
2304 /// property which is mentioned in the ICCCM.
2305 /// ## `name`
2306 /// the name of the themed icon
2307 #[doc(alias = "gtk_window_set_icon_name")]
2308 #[doc(alias = "icon-name")]
2309 fn set_icon_name(&self, name: Option<&str>) {
2310 unsafe {
2311 ffi::gtk_window_set_icon_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
2312 }
2313 }
2314
2315 /// Sets whether mnemonics are supposed to be visible.
2316 ///
2317 /// This property is maintained by GTK based on user input,
2318 /// and should not be set by applications.
2319 /// ## `setting`
2320 /// the new value
2321 #[doc(alias = "gtk_window_set_mnemonics_visible")]
2322 #[doc(alias = "mnemonics-visible")]
2323 fn set_mnemonics_visible(&self, setting: bool) {
2324 unsafe {
2325 ffi::gtk_window_set_mnemonics_visible(
2326 self.as_ref().to_glib_none().0,
2327 setting.into_glib(),
2328 );
2329 }
2330 }
2331
2332 /// Sets a window modal or non-modal.
2333 ///
2334 /// Modal windows prevent interaction with other windows in the same
2335 /// application. To keep modal dialogs on top of main application windows,
2336 /// use [`set_transient_for()`][Self::set_transient_for()] to make the dialog transient
2337 /// for the parent; most window managers will then disallow lowering the
2338 /// dialog below the parent.
2339 /// ## `modal`
2340 /// whether the window is modal
2341 #[doc(alias = "gtk_window_set_modal")]
2342 #[doc(alias = "modal")]
2343 fn set_modal(&self, modal: bool) {
2344 unsafe {
2345 ffi::gtk_window_set_modal(self.as_ref().to_glib_none().0, modal.into_glib());
2346 }
2347 }
2348
2349 /// Sets whether the user can resize a window.
2350 ///
2351 /// Windows are user resizable by default.
2352 /// ## `resizable`
2353 /// true if the user can resize this window
2354 #[doc(alias = "gtk_window_set_resizable")]
2355 #[doc(alias = "resizable")]
2356 fn set_resizable(&self, resizable: bool) {
2357 unsafe {
2358 ffi::gtk_window_set_resizable(self.as_ref().to_glib_none().0, resizable.into_glib());
2359 }
2360 }
2361
2362 /// Sets the startup notification ID.
2363 ///
2364 /// Startup notification identifiers are used by desktop environment
2365 /// to track application startup, to provide user feedback and other
2366 /// features. This function changes the corresponding property on the
2367 /// underlying [`gdk::Surface`][crate::gdk::Surface].
2368 ///
2369 /// Normally, startup identifier is managed automatically and you should
2370 /// only use this function in special cases like transferring focus from
2371 /// other processes. You should use this function before calling
2372 /// [`present()`][Self::present()] or any equivalent function generating
2373 /// a window map event.
2374 ///
2375 /// This function is only useful on Wayland or X11, not with other GDK
2376 /// backends.
2377 /// ## `startup_id`
2378 /// a string with startup-notification identifier
2379 #[doc(alias = "gtk_window_set_startup_id")]
2380 #[doc(alias = "startup-id")]
2381 fn set_startup_id(&self, startup_id: &str) {
2382 unsafe {
2383 ffi::gtk_window_set_startup_id(
2384 self.as_ref().to_glib_none().0,
2385 startup_id.to_glib_none().0,
2386 );
2387 }
2388 }
2389
2390 /// Sets the title of the window.
2391 ///
2392 /// The title of a window will be displayed in its title bar; on the
2393 /// X Window System, the title bar is rendered by the window manager
2394 /// so exactly how the title appears to users may vary according to a
2395 /// user’s exact configuration. The title should help a user distinguish
2396 /// this window from other windows they may have open. A good title might
2397 /// include the application name and current document filename, for example.
2398 ///
2399 /// Passing `NULL` does the same as setting the title to an empty string.
2400 /// ## `title`
2401 /// title of the window
2402 #[doc(alias = "gtk_window_set_title")]
2403 #[doc(alias = "title")]
2404 fn set_title(&self, title: Option<&str>) {
2405 unsafe {
2406 ffi::gtk_window_set_title(self.as_ref().to_glib_none().0, title.to_glib_none().0);
2407 }
2408 }
2409
2410 /// Sets a custom titlebar for the window.
2411 ///
2412 /// A typical widget used here is [`HeaderBar`][crate::HeaderBar], as it
2413 /// provides various features expected of a titlebar while allowing
2414 /// the addition of child widgets to it.
2415 ///
2416 /// If you set a custom titlebar, GTK will do its best to convince
2417 /// the window manager not to put its own titlebar on the window.
2418 /// Depending on the system, this function may not work for a window
2419 /// that is already visible, so you set the titlebar before calling
2420 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
2421 /// ## `titlebar`
2422 /// the widget to use as titlebar
2423 #[doc(alias = "gtk_window_set_titlebar")]
2424 #[doc(alias = "titlebar")]
2425 fn set_titlebar(&self, titlebar: Option<&impl IsA<Widget>>) {
2426 unsafe {
2427 ffi::gtk_window_set_titlebar(
2428 self.as_ref().to_glib_none().0,
2429 titlebar.map(|p| p.as_ref()).to_glib_none().0,
2430 );
2431 }
2432 }
2433
2434 /// Sets a transient parent for the window.
2435 ///
2436 /// Dialog windows should be set transient for the main application
2437 /// window they were spawned from. This allows window managers to e.g.
2438 /// keep the dialog on top of the main window, or center the dialog
2439 /// over the main window. [`Dialog::with_buttons()`][crate::Dialog::with_buttons()] and other
2440 /// convenience functions in GTK will sometimes call this function on
2441 /// your behalf.
2442 ///
2443 /// Passing `NULL` for @parent unsets the current transient window.
2444 ///
2445 /// On Windows, this function puts the child window on top of the parent,
2446 /// much as the window manager would have done on X.
2447 /// ## `parent`
2448 /// parent window
2449 #[doc(alias = "gtk_window_set_transient_for")]
2450 #[doc(alias = "transient-for")]
2451 fn set_transient_for(&self, parent: Option<&impl IsA<Window>>) {
2452 unsafe {
2453 ffi::gtk_window_set_transient_for(
2454 self.as_ref().to_glib_none().0,
2455 parent.map(|p| p.as_ref()).to_glib_none().0,
2456 );
2457 }
2458 }
2459
2460 /// Asks to remove the fullscreen state for the window, and return to
2461 /// its previous state.
2462 ///
2463 /// Note that you shouldn’t assume the window is definitely not
2464 /// fullscreen afterward, because other entities (e.g. the user or
2465 /// window manager) could fullscreen it again, and not all window
2466 /// managers honor requests to unfullscreen windows; normally the
2467 /// window will end up restored to its normal state. Just don’t
2468 /// write code that crashes if not.
2469 ///
2470 /// If a window is not explicitly fullscreened or unfullscreened before
2471 /// it is shown, the initial state is at the window managers discretion.
2472 ///
2473 /// You can track the result of this operation via the
2474 /// [`state`][struct@crate::Gdk::Toplevel#state] property, or by listening to
2475 /// notifications of the [`fullscreened`][struct@crate::Window#fullscreened] property.
2476 #[doc(alias = "gtk_window_unfullscreen")]
2477 fn unfullscreen(&self) {
2478 unsafe {
2479 ffi::gtk_window_unfullscreen(self.as_ref().to_glib_none().0);
2480 }
2481 }
2482
2483 /// Asks to unmaximize the window.
2484 ///
2485 /// Note that you shouldn’t assume the window is definitely unmaximized
2486 /// afterward, because other entities (e.g. the user or window manager)
2487 /// maximize it again, and not all window managers honor requests to
2488 /// unmaximize.
2489 ///
2490 /// If a window is not explicitly maximized or unmaximized before it is
2491 /// shown, the initial state is at the window managers discretion. For
2492 /// example, it might decide to maximize a window that almost fills the
2493 /// screen.
2494 ///
2495 /// You can track the result of this operation via the
2496 /// [`state`][struct@crate::Gdk::Toplevel#state] property, or by listening to
2497 /// notifications on the [`maximized`][struct@crate::Window#maximized] property.
2498 #[doc(alias = "gtk_window_unmaximize")]
2499 fn unmaximize(&self) {
2500 unsafe {
2501 ffi::gtk_window_unmaximize(self.as_ref().to_glib_none().0);
2502 }
2503 }
2504
2505 /// Asks to unminimize the window.
2506 ///
2507 /// Note that you shouldn’t assume the window is definitely unminimized
2508 /// afterward, because the windowing system might not support this
2509 /// functionality; other entities (e.g. the user or the window manager)
2510 /// could minimize it again, or there may not be a window manager in
2511 /// which case minimization isn’t possible, etc.
2512 ///
2513 /// You can track result of this operation via the
2514 /// [`state`][struct@crate::Gdk::Toplevel#state] property.
2515 #[doc(alias = "gtk_window_unminimize")]
2516 fn unminimize(&self) {
2517 unsafe {
2518 ffi::gtk_window_unminimize(self.as_ref().to_glib_none().0);
2519 }
2520 }
2521
2522 /// The default height of the window.
2523 #[doc(alias = "default-height")]
2524 fn default_height(&self) -> i32 {
2525 ObjectExt::property(self.as_ref(), "default-height")
2526 }
2527
2528 /// The default height of the window.
2529 #[doc(alias = "default-height")]
2530 fn set_default_height(&self, default_height: i32) {
2531 ObjectExt::set_property(self.as_ref(), "default-height", default_height)
2532 }
2533
2534 /// The default width of the window.
2535 #[doc(alias = "default-width")]
2536 fn default_width(&self) -> i32 {
2537 ObjectExt::property(self.as_ref(), "default-width")
2538 }
2539
2540 /// The default width of the window.
2541 #[doc(alias = "default-width")]
2542 fn set_default_width(&self, default_width: i32) {
2543 ObjectExt::set_property(self.as_ref(), "default-width", default_width)
2544 }
2545
2546 /// Whether the window is fullscreen.
2547 ///
2548 /// Setting this property is the equivalent of calling
2549 /// [`fullscreen()`][Self::fullscreen()] or [`unfullscreen()`][Self::unfullscreen()];
2550 /// either operation is asynchronous, which means you will need to
2551 /// connect to the ::notify signal in order to know whether the
2552 /// operation was successful.
2553 fn set_fullscreened(&self, fullscreened: bool) {
2554 ObjectExt::set_property(self.as_ref(), "fullscreened", fullscreened)
2555 }
2556
2557 /// Whether the window is maximized.
2558 ///
2559 /// Setting this property is the equivalent of calling
2560 /// [`maximize()`][Self::maximize()] or [`unmaximize()`][Self::unmaximize()];
2561 /// either operation is asynchronous, which means you will need to
2562 /// connect to the ::notify signal in order to know whether the
2563 /// operation was successful.
2564 fn set_maximized(&self, maximized: bool) {
2565 ObjectExt::set_property(self.as_ref(), "maximized", maximized)
2566 }
2567
2568 /// Emitted when the user activates the default widget.
2569 ///
2570 /// This is a [keybinding signal](class.SignalAction.html).
2571 ///
2572 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
2573 #[doc(alias = "activate-default")]
2574 fn connect_activate_default<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2575 unsafe extern "C" fn activate_default_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2576 this: *mut ffi::GtkWindow,
2577 f: glib::ffi::gpointer,
2578 ) {
2579 let f: &F = &*(f as *const F);
2580 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2581 }
2582 unsafe {
2583 let f: Box_<F> = Box_::new(f);
2584 connect_raw(
2585 self.as_ptr() as *mut _,
2586 c"activate-default".as_ptr() as *const _,
2587 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2588 activate_default_trampoline::<Self, F> as *const (),
2589 )),
2590 Box_::into_raw(f),
2591 )
2592 }
2593 }
2594
2595 fn emit_activate_default(&self) {
2596 self.emit_by_name::<()>("activate-default", &[]);
2597 }
2598
2599 /// Emitted when the user activates the currently focused
2600 /// widget of @window.
2601 ///
2602 /// This is a [keybinding signal](class.SignalAction.html).
2603 ///
2604 /// The default binding for this signal is <kbd>␣</kbd>.
2605 #[doc(alias = "activate-focus")]
2606 fn connect_activate_focus<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2607 unsafe extern "C" fn activate_focus_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2608 this: *mut ffi::GtkWindow,
2609 f: glib::ffi::gpointer,
2610 ) {
2611 let f: &F = &*(f as *const F);
2612 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2613 }
2614 unsafe {
2615 let f: Box_<F> = Box_::new(f);
2616 connect_raw(
2617 self.as_ptr() as *mut _,
2618 c"activate-focus".as_ptr() as *const _,
2619 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2620 activate_focus_trampoline::<Self, F> as *const (),
2621 )),
2622 Box_::into_raw(f),
2623 )
2624 }
2625 }
2626
2627 fn emit_activate_focus(&self) {
2628 self.emit_by_name::<()>("activate-focus", &[]);
2629 }
2630
2631 /// Emitted when the user clicks on the close button of the window.
2632 ///
2633 /// # Returns
2634 ///
2635 /// true to stop other handlers from being invoked for the signal
2636 #[doc(alias = "close-request")]
2637 fn connect_close_request<F: Fn(&Self) -> glib::Propagation + 'static>(
2638 &self,
2639 f: F,
2640 ) -> SignalHandlerId {
2641 unsafe extern "C" fn close_request_trampoline<
2642 P: IsA<Window>,
2643 F: Fn(&P) -> glib::Propagation + 'static,
2644 >(
2645 this: *mut ffi::GtkWindow,
2646 f: glib::ffi::gpointer,
2647 ) -> glib::ffi::gboolean {
2648 let f: &F = &*(f as *const F);
2649 f(Window::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
2650 }
2651 unsafe {
2652 let f: Box_<F> = Box_::new(f);
2653 connect_raw(
2654 self.as_ptr() as *mut _,
2655 c"close-request".as_ptr() as *const _,
2656 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2657 close_request_trampoline::<Self, F> as *const (),
2658 )),
2659 Box_::into_raw(f),
2660 )
2661 }
2662 }
2663
2664 /// Emitted when the user enables or disables interactive debugging.
2665 ///
2666 /// When @toggle is true, interactive debugging is toggled on or off,
2667 /// when it is false, the debugger will be pointed at the widget
2668 /// under the pointer.
2669 ///
2670 /// This is a [keybinding signal](class.SignalAction.html).
2671 ///
2672 /// The default bindings for this signal are
2673 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> and
2674 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd>.
2675 /// ## `toggle`
2676 /// toggle the debugger
2677 ///
2678 /// # Returns
2679 ///
2680 /// true if the key binding was handled
2681 #[doc(alias = "enable-debugging")]
2682 fn connect_enable_debugging<F: Fn(&Self, bool) -> bool + 'static>(
2683 &self,
2684 f: F,
2685 ) -> SignalHandlerId {
2686 unsafe extern "C" fn enable_debugging_trampoline<
2687 P: IsA<Window>,
2688 F: Fn(&P, bool) -> bool + 'static,
2689 >(
2690 this: *mut ffi::GtkWindow,
2691 toggle: glib::ffi::gboolean,
2692 f: glib::ffi::gpointer,
2693 ) -> glib::ffi::gboolean {
2694 let f: &F = &*(f as *const F);
2695 f(
2696 Window::from_glib_borrow(this).unsafe_cast_ref(),
2697 from_glib(toggle),
2698 )
2699 .into_glib()
2700 }
2701 unsafe {
2702 let f: Box_<F> = Box_::new(f);
2703 connect_raw(
2704 self.as_ptr() as *mut _,
2705 c"enable-debugging".as_ptr() as *const _,
2706 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2707 enable_debugging_trampoline::<Self, F> as *const (),
2708 )),
2709 Box_::into_raw(f),
2710 )
2711 }
2712 }
2713
2714 fn emit_enable_debugging(&self, toggle: bool) -> bool {
2715 self.emit_by_name("enable-debugging", &[&toggle])
2716 }
2717
2718 /// Emitted when the set of accelerators or mnemonics that
2719 /// are associated with the window changes.
2720 ///
2721 /// # Deprecated since 4.10
2722 ///
2723 /// Use [`Shortcut`][crate::Shortcut] and [`EventController`][crate::EventController]
2724 /// to implement keyboard shortcuts
2725 #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
2726 #[doc(alias = "keys-changed")]
2727 fn connect_keys_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2728 unsafe extern "C" fn keys_changed_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2729 this: *mut ffi::GtkWindow,
2730 f: glib::ffi::gpointer,
2731 ) {
2732 let f: &F = &*(f as *const F);
2733 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2734 }
2735 unsafe {
2736 let f: Box_<F> = Box_::new(f);
2737 connect_raw(
2738 self.as_ptr() as *mut _,
2739 c"keys-changed".as_ptr() as *const _,
2740 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2741 keys_changed_trampoline::<Self, F> as *const (),
2742 )),
2743 Box_::into_raw(f),
2744 )
2745 }
2746 }
2747
2748 #[doc(alias = "application")]
2749 fn connect_application_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2750 unsafe extern "C" fn notify_application_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2751 this: *mut ffi::GtkWindow,
2752 _param_spec: glib::ffi::gpointer,
2753 f: glib::ffi::gpointer,
2754 ) {
2755 let f: &F = &*(f as *const F);
2756 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2757 }
2758 unsafe {
2759 let f: Box_<F> = Box_::new(f);
2760 connect_raw(
2761 self.as_ptr() as *mut _,
2762 c"notify::application".as_ptr() as *const _,
2763 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2764 notify_application_trampoline::<Self, F> as *const (),
2765 )),
2766 Box_::into_raw(f),
2767 )
2768 }
2769 }
2770
2771 #[doc(alias = "child")]
2772 fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2773 unsafe extern "C" fn notify_child_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2774 this: *mut ffi::GtkWindow,
2775 _param_spec: glib::ffi::gpointer,
2776 f: glib::ffi::gpointer,
2777 ) {
2778 let f: &F = &*(f as *const F);
2779 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2780 }
2781 unsafe {
2782 let f: Box_<F> = Box_::new(f);
2783 connect_raw(
2784 self.as_ptr() as *mut _,
2785 c"notify::child".as_ptr() as *const _,
2786 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2787 notify_child_trampoline::<Self, F> as *const (),
2788 )),
2789 Box_::into_raw(f),
2790 )
2791 }
2792 }
2793
2794 #[doc(alias = "decorated")]
2795 fn connect_decorated_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2796 unsafe extern "C" fn notify_decorated_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2797 this: *mut ffi::GtkWindow,
2798 _param_spec: glib::ffi::gpointer,
2799 f: glib::ffi::gpointer,
2800 ) {
2801 let f: &F = &*(f as *const F);
2802 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2803 }
2804 unsafe {
2805 let f: Box_<F> = Box_::new(f);
2806 connect_raw(
2807 self.as_ptr() as *mut _,
2808 c"notify::decorated".as_ptr() as *const _,
2809 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2810 notify_decorated_trampoline::<Self, F> as *const (),
2811 )),
2812 Box_::into_raw(f),
2813 )
2814 }
2815 }
2816
2817 #[doc(alias = "default-height")]
2818 fn connect_default_height_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2819 unsafe extern "C" fn notify_default_height_trampoline<
2820 P: IsA<Window>,
2821 F: Fn(&P) + 'static,
2822 >(
2823 this: *mut ffi::GtkWindow,
2824 _param_spec: glib::ffi::gpointer,
2825 f: glib::ffi::gpointer,
2826 ) {
2827 let f: &F = &*(f as *const F);
2828 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2829 }
2830 unsafe {
2831 let f: Box_<F> = Box_::new(f);
2832 connect_raw(
2833 self.as_ptr() as *mut _,
2834 c"notify::default-height".as_ptr() as *const _,
2835 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2836 notify_default_height_trampoline::<Self, F> as *const (),
2837 )),
2838 Box_::into_raw(f),
2839 )
2840 }
2841 }
2842
2843 #[doc(alias = "default-widget")]
2844 fn connect_default_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2845 unsafe extern "C" fn notify_default_widget_trampoline<
2846 P: IsA<Window>,
2847 F: Fn(&P) + 'static,
2848 >(
2849 this: *mut ffi::GtkWindow,
2850 _param_spec: glib::ffi::gpointer,
2851 f: glib::ffi::gpointer,
2852 ) {
2853 let f: &F = &*(f as *const F);
2854 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2855 }
2856 unsafe {
2857 let f: Box_<F> = Box_::new(f);
2858 connect_raw(
2859 self.as_ptr() as *mut _,
2860 c"notify::default-widget".as_ptr() as *const _,
2861 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2862 notify_default_widget_trampoline::<Self, F> as *const (),
2863 )),
2864 Box_::into_raw(f),
2865 )
2866 }
2867 }
2868
2869 #[doc(alias = "default-width")]
2870 fn connect_default_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2871 unsafe extern "C" fn notify_default_width_trampoline<
2872 P: IsA<Window>,
2873 F: Fn(&P) + 'static,
2874 >(
2875 this: *mut ffi::GtkWindow,
2876 _param_spec: glib::ffi::gpointer,
2877 f: glib::ffi::gpointer,
2878 ) {
2879 let f: &F = &*(f as *const F);
2880 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2881 }
2882 unsafe {
2883 let f: Box_<F> = Box_::new(f);
2884 connect_raw(
2885 self.as_ptr() as *mut _,
2886 c"notify::default-width".as_ptr() as *const _,
2887 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2888 notify_default_width_trampoline::<Self, F> as *const (),
2889 )),
2890 Box_::into_raw(f),
2891 )
2892 }
2893 }
2894
2895 #[doc(alias = "deletable")]
2896 fn connect_deletable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2897 unsafe extern "C" fn notify_deletable_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2898 this: *mut ffi::GtkWindow,
2899 _param_spec: glib::ffi::gpointer,
2900 f: glib::ffi::gpointer,
2901 ) {
2902 let f: &F = &*(f as *const F);
2903 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2904 }
2905 unsafe {
2906 let f: Box_<F> = Box_::new(f);
2907 connect_raw(
2908 self.as_ptr() as *mut _,
2909 c"notify::deletable".as_ptr() as *const _,
2910 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2911 notify_deletable_trampoline::<Self, F> as *const (),
2912 )),
2913 Box_::into_raw(f),
2914 )
2915 }
2916 }
2917
2918 #[doc(alias = "destroy-with-parent")]
2919 fn connect_destroy_with_parent_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2920 unsafe extern "C" fn notify_destroy_with_parent_trampoline<
2921 P: IsA<Window>,
2922 F: Fn(&P) + 'static,
2923 >(
2924 this: *mut ffi::GtkWindow,
2925 _param_spec: glib::ffi::gpointer,
2926 f: glib::ffi::gpointer,
2927 ) {
2928 let f: &F = &*(f as *const F);
2929 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2930 }
2931 unsafe {
2932 let f: Box_<F> = Box_::new(f);
2933 connect_raw(
2934 self.as_ptr() as *mut _,
2935 c"notify::destroy-with-parent".as_ptr() as *const _,
2936 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2937 notify_destroy_with_parent_trampoline::<Self, F> as *const (),
2938 )),
2939 Box_::into_raw(f),
2940 )
2941 }
2942 }
2943
2944 #[doc(alias = "display")]
2945 fn connect_display_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2946 unsafe extern "C" fn notify_display_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2947 this: *mut ffi::GtkWindow,
2948 _param_spec: glib::ffi::gpointer,
2949 f: glib::ffi::gpointer,
2950 ) {
2951 let f: &F = &*(f as *const F);
2952 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2953 }
2954 unsafe {
2955 let f: Box_<F> = Box_::new(f);
2956 connect_raw(
2957 self.as_ptr() as *mut _,
2958 c"notify::display".as_ptr() as *const _,
2959 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2960 notify_display_trampoline::<Self, F> as *const (),
2961 )),
2962 Box_::into_raw(f),
2963 )
2964 }
2965 }
2966
2967 #[doc(alias = "focus-visible")]
2968 fn connect_focus_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2969 unsafe extern "C" fn notify_focus_visible_trampoline<
2970 P: IsA<Window>,
2971 F: Fn(&P) + 'static,
2972 >(
2973 this: *mut ffi::GtkWindow,
2974 _param_spec: glib::ffi::gpointer,
2975 f: glib::ffi::gpointer,
2976 ) {
2977 let f: &F = &*(f as *const F);
2978 f(Window::from_glib_borrow(this).unsafe_cast_ref())
2979 }
2980 unsafe {
2981 let f: Box_<F> = Box_::new(f);
2982 connect_raw(
2983 self.as_ptr() as *mut _,
2984 c"notify::focus-visible".as_ptr() as *const _,
2985 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
2986 notify_focus_visible_trampoline::<Self, F> as *const (),
2987 )),
2988 Box_::into_raw(f),
2989 )
2990 }
2991 }
2992
2993 #[doc(alias = "focus-widget")]
2994 fn connect_focus_widget_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
2995 unsafe extern "C" fn notify_focus_widget_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
2996 this: *mut ffi::GtkWindow,
2997 _param_spec: glib::ffi::gpointer,
2998 f: glib::ffi::gpointer,
2999 ) {
3000 let f: &F = &*(f as *const F);
3001 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3002 }
3003 unsafe {
3004 let f: Box_<F> = Box_::new(f);
3005 connect_raw(
3006 self.as_ptr() as *mut _,
3007 c"notify::focus-widget".as_ptr() as *const _,
3008 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3009 notify_focus_widget_trampoline::<Self, F> as *const (),
3010 )),
3011 Box_::into_raw(f),
3012 )
3013 }
3014 }
3015
3016 #[doc(alias = "fullscreened")]
3017 fn connect_fullscreened_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3018 unsafe extern "C" fn notify_fullscreened_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3019 this: *mut ffi::GtkWindow,
3020 _param_spec: glib::ffi::gpointer,
3021 f: glib::ffi::gpointer,
3022 ) {
3023 let f: &F = &*(f as *const F);
3024 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3025 }
3026 unsafe {
3027 let f: Box_<F> = Box_::new(f);
3028 connect_raw(
3029 self.as_ptr() as *mut _,
3030 c"notify::fullscreened".as_ptr() as *const _,
3031 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3032 notify_fullscreened_trampoline::<Self, F> as *const (),
3033 )),
3034 Box_::into_raw(f),
3035 )
3036 }
3037 }
3038
3039 #[cfg(feature = "v4_20")]
3040 #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
3041 #[doc(alias = "gravity")]
3042 fn connect_gravity_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3043 unsafe extern "C" fn notify_gravity_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3044 this: *mut ffi::GtkWindow,
3045 _param_spec: glib::ffi::gpointer,
3046 f: glib::ffi::gpointer,
3047 ) {
3048 let f: &F = &*(f as *const F);
3049 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3050 }
3051 unsafe {
3052 let f: Box_<F> = Box_::new(f);
3053 connect_raw(
3054 self.as_ptr() as *mut _,
3055 c"notify::gravity".as_ptr() as *const _,
3056 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3057 notify_gravity_trampoline::<Self, F> as *const (),
3058 )),
3059 Box_::into_raw(f),
3060 )
3061 }
3062 }
3063
3064 #[cfg(feature = "v4_2")]
3065 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
3066 #[doc(alias = "handle-menubar-accel")]
3067 fn connect_handle_menubar_accel_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3068 unsafe extern "C" fn notify_handle_menubar_accel_trampoline<
3069 P: IsA<Window>,
3070 F: Fn(&P) + 'static,
3071 >(
3072 this: *mut ffi::GtkWindow,
3073 _param_spec: glib::ffi::gpointer,
3074 f: glib::ffi::gpointer,
3075 ) {
3076 let f: &F = &*(f as *const F);
3077 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3078 }
3079 unsafe {
3080 let f: Box_<F> = Box_::new(f);
3081 connect_raw(
3082 self.as_ptr() as *mut _,
3083 c"notify::handle-menubar-accel".as_ptr() as *const _,
3084 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3085 notify_handle_menubar_accel_trampoline::<Self, F> as *const (),
3086 )),
3087 Box_::into_raw(f),
3088 )
3089 }
3090 }
3091
3092 #[doc(alias = "hide-on-close")]
3093 fn connect_hide_on_close_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3094 unsafe extern "C" fn notify_hide_on_close_trampoline<
3095 P: IsA<Window>,
3096 F: Fn(&P) + 'static,
3097 >(
3098 this: *mut ffi::GtkWindow,
3099 _param_spec: glib::ffi::gpointer,
3100 f: glib::ffi::gpointer,
3101 ) {
3102 let f: &F = &*(f as *const F);
3103 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3104 }
3105 unsafe {
3106 let f: Box_<F> = Box_::new(f);
3107 connect_raw(
3108 self.as_ptr() as *mut _,
3109 c"notify::hide-on-close".as_ptr() as *const _,
3110 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3111 notify_hide_on_close_trampoline::<Self, F> as *const (),
3112 )),
3113 Box_::into_raw(f),
3114 )
3115 }
3116 }
3117
3118 #[doc(alias = "icon-name")]
3119 fn connect_icon_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3120 unsafe extern "C" fn notify_icon_name_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3121 this: *mut ffi::GtkWindow,
3122 _param_spec: glib::ffi::gpointer,
3123 f: glib::ffi::gpointer,
3124 ) {
3125 let f: &F = &*(f as *const F);
3126 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3127 }
3128 unsafe {
3129 let f: Box_<F> = Box_::new(f);
3130 connect_raw(
3131 self.as_ptr() as *mut _,
3132 c"notify::icon-name".as_ptr() as *const _,
3133 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3134 notify_icon_name_trampoline::<Self, F> as *const (),
3135 )),
3136 Box_::into_raw(f),
3137 )
3138 }
3139 }
3140
3141 #[doc(alias = "is-active")]
3142 fn connect_is_active_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3143 unsafe extern "C" fn notify_is_active_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3144 this: *mut ffi::GtkWindow,
3145 _param_spec: glib::ffi::gpointer,
3146 f: glib::ffi::gpointer,
3147 ) {
3148 let f: &F = &*(f as *const F);
3149 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3150 }
3151 unsafe {
3152 let f: Box_<F> = Box_::new(f);
3153 connect_raw(
3154 self.as_ptr() as *mut _,
3155 c"notify::is-active".as_ptr() as *const _,
3156 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3157 notify_is_active_trampoline::<Self, F> as *const (),
3158 )),
3159 Box_::into_raw(f),
3160 )
3161 }
3162 }
3163
3164 #[doc(alias = "maximized")]
3165 fn connect_maximized_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3166 unsafe extern "C" fn notify_maximized_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3167 this: *mut ffi::GtkWindow,
3168 _param_spec: glib::ffi::gpointer,
3169 f: glib::ffi::gpointer,
3170 ) {
3171 let f: &F = &*(f as *const F);
3172 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3173 }
3174 unsafe {
3175 let f: Box_<F> = Box_::new(f);
3176 connect_raw(
3177 self.as_ptr() as *mut _,
3178 c"notify::maximized".as_ptr() as *const _,
3179 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3180 notify_maximized_trampoline::<Self, F> as *const (),
3181 )),
3182 Box_::into_raw(f),
3183 )
3184 }
3185 }
3186
3187 #[doc(alias = "mnemonics-visible")]
3188 fn connect_mnemonics_visible_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3189 unsafe extern "C" fn notify_mnemonics_visible_trampoline<
3190 P: IsA<Window>,
3191 F: Fn(&P) + 'static,
3192 >(
3193 this: *mut ffi::GtkWindow,
3194 _param_spec: glib::ffi::gpointer,
3195 f: glib::ffi::gpointer,
3196 ) {
3197 let f: &F = &*(f as *const F);
3198 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3199 }
3200 unsafe {
3201 let f: Box_<F> = Box_::new(f);
3202 connect_raw(
3203 self.as_ptr() as *mut _,
3204 c"notify::mnemonics-visible".as_ptr() as *const _,
3205 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3206 notify_mnemonics_visible_trampoline::<Self, F> as *const (),
3207 )),
3208 Box_::into_raw(f),
3209 )
3210 }
3211 }
3212
3213 #[doc(alias = "modal")]
3214 fn connect_modal_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3215 unsafe extern "C" fn notify_modal_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3216 this: *mut ffi::GtkWindow,
3217 _param_spec: glib::ffi::gpointer,
3218 f: glib::ffi::gpointer,
3219 ) {
3220 let f: &F = &*(f as *const F);
3221 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3222 }
3223 unsafe {
3224 let f: Box_<F> = Box_::new(f);
3225 connect_raw(
3226 self.as_ptr() as *mut _,
3227 c"notify::modal".as_ptr() as *const _,
3228 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3229 notify_modal_trampoline::<Self, F> as *const (),
3230 )),
3231 Box_::into_raw(f),
3232 )
3233 }
3234 }
3235
3236 #[doc(alias = "resizable")]
3237 fn connect_resizable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3238 unsafe extern "C" fn notify_resizable_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3239 this: *mut ffi::GtkWindow,
3240 _param_spec: glib::ffi::gpointer,
3241 f: glib::ffi::gpointer,
3242 ) {
3243 let f: &F = &*(f as *const F);
3244 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3245 }
3246 unsafe {
3247 let f: Box_<F> = Box_::new(f);
3248 connect_raw(
3249 self.as_ptr() as *mut _,
3250 c"notify::resizable".as_ptr() as *const _,
3251 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3252 notify_resizable_trampoline::<Self, F> as *const (),
3253 )),
3254 Box_::into_raw(f),
3255 )
3256 }
3257 }
3258
3259 #[doc(alias = "startup-id")]
3260 fn connect_startup_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3261 unsafe extern "C" fn notify_startup_id_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3262 this: *mut ffi::GtkWindow,
3263 _param_spec: glib::ffi::gpointer,
3264 f: glib::ffi::gpointer,
3265 ) {
3266 let f: &F = &*(f as *const F);
3267 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3268 }
3269 unsafe {
3270 let f: Box_<F> = Box_::new(f);
3271 connect_raw(
3272 self.as_ptr() as *mut _,
3273 c"notify::startup-id".as_ptr() as *const _,
3274 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3275 notify_startup_id_trampoline::<Self, F> as *const (),
3276 )),
3277 Box_::into_raw(f),
3278 )
3279 }
3280 }
3281
3282 #[cfg(feature = "v4_12")]
3283 #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
3284 #[doc(alias = "suspended")]
3285 fn connect_suspended_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3286 unsafe extern "C" fn notify_suspended_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3287 this: *mut ffi::GtkWindow,
3288 _param_spec: glib::ffi::gpointer,
3289 f: glib::ffi::gpointer,
3290 ) {
3291 let f: &F = &*(f as *const F);
3292 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3293 }
3294 unsafe {
3295 let f: Box_<F> = Box_::new(f);
3296 connect_raw(
3297 self.as_ptr() as *mut _,
3298 c"notify::suspended".as_ptr() as *const _,
3299 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3300 notify_suspended_trampoline::<Self, F> as *const (),
3301 )),
3302 Box_::into_raw(f),
3303 )
3304 }
3305 }
3306
3307 #[doc(alias = "title")]
3308 fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3309 unsafe extern "C" fn notify_title_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3310 this: *mut ffi::GtkWindow,
3311 _param_spec: glib::ffi::gpointer,
3312 f: glib::ffi::gpointer,
3313 ) {
3314 let f: &F = &*(f as *const F);
3315 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3316 }
3317 unsafe {
3318 let f: Box_<F> = Box_::new(f);
3319 connect_raw(
3320 self.as_ptr() as *mut _,
3321 c"notify::title".as_ptr() as *const _,
3322 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3323 notify_title_trampoline::<Self, F> as *const (),
3324 )),
3325 Box_::into_raw(f),
3326 )
3327 }
3328 }
3329
3330 #[cfg(feature = "v4_6")]
3331 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
3332 #[doc(alias = "titlebar")]
3333 fn connect_titlebar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3334 unsafe extern "C" fn notify_titlebar_trampoline<P: IsA<Window>, F: Fn(&P) + 'static>(
3335 this: *mut ffi::GtkWindow,
3336 _param_spec: glib::ffi::gpointer,
3337 f: glib::ffi::gpointer,
3338 ) {
3339 let f: &F = &*(f as *const F);
3340 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3341 }
3342 unsafe {
3343 let f: Box_<F> = Box_::new(f);
3344 connect_raw(
3345 self.as_ptr() as *mut _,
3346 c"notify::titlebar".as_ptr() as *const _,
3347 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3348 notify_titlebar_trampoline::<Self, F> as *const (),
3349 )),
3350 Box_::into_raw(f),
3351 )
3352 }
3353 }
3354
3355 #[doc(alias = "transient-for")]
3356 fn connect_transient_for_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
3357 unsafe extern "C" fn notify_transient_for_trampoline<
3358 P: IsA<Window>,
3359 F: Fn(&P) + 'static,
3360 >(
3361 this: *mut ffi::GtkWindow,
3362 _param_spec: glib::ffi::gpointer,
3363 f: glib::ffi::gpointer,
3364 ) {
3365 let f: &F = &*(f as *const F);
3366 f(Window::from_glib_borrow(this).unsafe_cast_ref())
3367 }
3368 unsafe {
3369 let f: Box_<F> = Box_::new(f);
3370 connect_raw(
3371 self.as_ptr() as *mut _,
3372 c"notify::transient-for".as_ptr() as *const _,
3373 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
3374 notify_transient_for_trampoline::<Self, F> as *const (),
3375 )),
3376 Box_::into_raw(f),
3377 )
3378 }
3379 }
3380}
3381
3382impl<O: IsA<Window>> GtkWindowExt for O {}