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