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 /// 
22 ///
23 /// Windows normally have decorations that are under the control
24 /// of the windowing system and allow the user to manipulate the window
25 /// (resize it, move it, close it,...).
26 ///
27 /// # GtkWindow as GtkBuildable
28 ///
29 /// The [`Window`][crate::Window] implementation of the [`Buildable`][crate::Buildable] interface supports
30 /// setting a child as the titlebar by specifying “titlebar” as the “type”
31 /// attribute of a `<child>` element.
32 ///
33 /// # Shortcuts and Gestures
34 ///
35 /// [`Window`][crate::Window] supports the following keyboard shortcuts:
36 ///
37 /// - <kbd>F10</kbd> activates the menubar, if present.
38 /// - <kbd>Alt</kbd> makes the mnemonics visible while pressed.
39 ///
40 /// The following signals have default keybindings:
41 ///
42 /// - [`activate-default`][struct@crate::Window#activate-default]
43 /// - [`activate-focus`][struct@crate::Window#activate-focus]
44 /// - [`enable-debugging`][struct@crate::Window#enable-debugging]
45 ///
46 /// # Actions
47 ///
48 /// [`Window`][crate::Window] defines a set of built-in actions:
49 ///
50 /// - `default.activate` activates the default widget.
51 /// - `window.minimize` minimizes the window.
52 /// - `window.toggle-maximized` maximizes or restores the window.
53 /// - `window.close` closes the window.
54 ///
55 /// # CSS nodes
56 ///
57 /// ```text
58 /// window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled]
59 /// ├── <child>
60 /// ╰── <titlebar child>.titlebar [.default-decoration]
61 /// ```
62 ///
63 /// [`Window`][crate::Window] has a main CSS node with name window and style class .background.
64 ///
65 /// Style classes that are typically used with the main CSS node are .csd (when
66 /// client-side decorations are in use), .solid-csd (for client-side decorations
67 /// without invisible borders), .ssd (used by mutter when rendering server-side
68 /// decorations). GtkWindow also represents window states with the following
69 /// style classes on the main node: .maximized, .fullscreen, .tiled (when supported,
70 /// also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom).
71 ///
72 /// [`Window`][crate::Window] subclasses often add their own discriminating style classes,
73 /// such as .dialog, .popup or .tooltip.
74 ///
75 /// Generally, some CSS properties don't make sense on the toplevel window node,
76 /// such as margins or padding. When client-side decorations without invisible
77 /// borders are in use (i.e. the .solid-csd style class is added to the
78 /// main window node), the CSS border of the toplevel window is used for
79 /// resize drags. In the .csd case, the shadow area outside of the window
80 /// can be used to resize it.
81 ///
82 /// [`Window`][crate::Window] adds the .titlebar and .default-decoration style classes to the
83 /// widget that is added as a titlebar child.
84 ///
85 /// # Accessibility
86 ///
87 /// [`Window`][crate::Window] uses the [enum@Gtk.AccessibleRole.window] role.
88 ///
89 /// From GTK 4.12 to 4.18, it used the [enum@Gtk.AccessibleRole.application] role.
90 ///
91 /// ## Properties
92 ///
93 ///
94 /// #### `application`
95 /// The [`Application`][crate::Application] associated with the window.
96 ///
97 /// The application will be kept alive for at least as long as it
98 /// has any windows associated with it (see g_application_hold()
99 /// for a way to keep it alive without windows).
100 ///
101 /// Normally, the connection between the application and the window
102 /// will remain until the window is destroyed, but you can explicitly
103 /// remove it by setting the this property to `NULL`.
104 ///
105 /// Readable | Writeable
106 ///
107 ///
108 /// #### `child`
109 /// The child widget.
110 ///
111 /// Readable | Writeable
112 ///
113 ///
114 /// #### `decorated`
115 /// Whether the window should have a frame (also known as *decorations*).
116 ///
117 /// Readable | Writeable
118 ///
119 ///
120 /// #### `default-height`
121 /// The default height of the window.
122 ///
123 /// Readable | Writeable
124 ///
125 ///
126 /// #### `default-widget`
127 /// The default widget.
128 ///
129 /// Readable | Writeable
130 ///
131 ///
132 /// #### `default-width`
133 /// The default width of the window.
134 ///
135 /// Readable | Writeable
136 ///
137 ///
138 /// #### `deletable`
139 /// Whether the window frame should have a close button.
140 ///
141 /// Readable | Writeable
142 ///
143 ///
144 /// #### `destroy-with-parent`
145 /// If this window should be destroyed when the parent is destroyed.
146 ///
147 /// Readable | Writeable
148 ///
149 ///
150 /// #### `display`
151 /// The display that will display this window.
152 ///
153 /// Readable | Writeable
154 ///
155 ///
156 /// #### `focus-visible`
157 /// Whether 'focus rectangles' are currently visible in this window.
158 ///
159 /// This property is maintained by GTK based on user input
160 /// and should not be set by applications.
161 ///
162 /// Readable | Writeable
163 ///
164 ///
165 /// #### `focus-widget`
166 /// The focus widget.
167 ///
168 /// Readable | Writeable
169 ///
170 ///
171 /// #### `fullscreened`
172 /// Whether the window is fullscreen.
173 ///
174 /// Setting this property is the equivalent of calling
175 /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
176 /// either operation is asynchronous, which means you will need to
177 /// connect to the ::notify signal in order to know whether the
178 /// operation was successful.
179 ///
180 /// Readable | Writeable | Construct
181 ///
182 ///
183 /// #### `handle-menubar-accel`
184 /// Whether the window frame should handle <kbd>F10</kbd> for activating
185 /// menubars.
186 ///
187 /// Readable | Writeable
188 ///
189 ///
190 /// #### `hide-on-close`
191 /// If this window should be hidden when the users clicks the close button.
192 ///
193 /// Readable | Writeable
194 ///
195 ///
196 /// #### `icon-name`
197 /// Specifies the name of the themed icon to use as the window icon.
198 ///
199 /// See [`IconTheme`][crate::IconTheme] for more details.
200 ///
201 /// Readable | Writeable
202 ///
203 ///
204 /// #### `is-active`
205 /// Whether the toplevel is the currently active window.
206 ///
207 /// Readable
208 ///
209 ///
210 /// #### `maximized`
211 /// Whether the window is maximized.
212 ///
213 /// Setting this property is the equivalent of calling
214 /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
215 /// either operation is asynchronous, which means you will need to
216 /// connect to the ::notify signal in order to know whether the
217 /// operation was successful.
218 ///
219 /// Readable | Writeable | Construct
220 ///
221 ///
222 /// #### `mnemonics-visible`
223 /// Whether mnemonics are currently visible in this window.
224 ///
225 /// This property is maintained by GTK based on user input,
226 /// and should not be set by applications.
227 ///
228 /// Readable | Writeable
229 ///
230 ///
231 /// #### `modal`
232 /// If true, the window is modal.
233 ///
234 /// Readable | Writeable
235 ///
236 ///
237 /// #### `resizable`
238 /// If true, users can resize the window.
239 ///
240 /// Readable | Writeable
241 ///
242 ///
243 /// #### `startup-id`
244 /// A write-only property for setting window's startup notification identifier.
245 ///
246 /// Writeable
247 ///
248 ///
249 /// #### `suspended`
250 /// Whether the window is suspended.
251 ///
252 /// See [`GtkWindowExt::is_suspended()`][crate::prelude::GtkWindowExt::is_suspended()] for details about what suspended means.
253 ///
254 /// Readable
255 ///
256 ///
257 /// #### `title`
258 /// The title of the window.
259 ///
260 /// Readable | Writeable
261 ///
262 ///
263 /// #### `titlebar`
264 /// The titlebar widget.
265 ///
266 /// Readable | Writeable
267 ///
268 ///
269 /// #### `transient-for`
270 /// The transient parent of the window.
271 ///
272 /// Readable | Writeable | Construct
273 /// <details><summary><h4>Widget</h4></summary>
274 ///
275 ///
276 /// #### `can-focus`
277 /// Whether the widget or any of its descendents can accept
278 /// the input focus.
279 ///
280 /// This property is meant to be set by widget implementations,
281 /// typically in their instance init function.
282 ///
283 /// Readable | Writeable
284 ///
285 ///
286 /// #### `can-target`
287 /// Whether the widget can receive pointer events.
288 ///
289 /// Readable | Writeable
290 ///
291 ///
292 /// #### `css-classes`
293 /// A list of css classes applied to this widget.
294 ///
295 /// Readable | Writeable
296 ///
297 ///
298 /// #### `css-name`
299 /// The name of this widget in the CSS tree.
300 ///
301 /// This property is meant to be set by widget implementations,
302 /// typically in their instance init function.
303 ///
304 /// Readable | Writeable | Construct Only
305 ///
306 ///
307 /// #### `cursor`
308 /// The cursor used by @widget.
309 ///
310 /// Readable | Writeable
311 ///
312 ///
313 /// #### `focus-on-click`
314 /// Whether the widget should grab focus when it is clicked with the mouse.
315 ///
316 /// This property is only relevant for widgets that can take focus.
317 ///
318 /// Readable | Writeable
319 ///
320 ///
321 /// #### `focusable`
322 /// Whether this widget itself will accept the input focus.
323 ///
324 /// Readable | Writeable
325 ///
326 ///
327 /// #### `halign`
328 /// How to distribute horizontal space if widget gets extra space.
329 ///
330 /// Readable | Writeable
331 ///
332 ///
333 /// #### `has-default`
334 /// Whether the widget is the default widget.
335 ///
336 /// Readable
337 ///
338 ///
339 /// #### `has-focus`
340 /// Whether the widget has the input focus.
341 ///
342 /// Readable
343 ///
344 ///
345 /// #### `has-tooltip`
346 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
347 /// signal on @widget.
348 ///
349 /// A true value indicates that @widget can have a tooltip, in this case
350 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
351 /// determine whether it will provide a tooltip or not.
352 ///
353 /// Readable | Writeable
354 ///
355 ///
356 /// #### `height-request`
357 /// Overrides for height request of the widget.
358 ///
359 /// If this is -1, the natural request will be used.
360 ///
361 /// Readable | Writeable
362 ///
363 ///
364 /// #### `hexpand`
365 /// Whether to expand horizontally.
366 ///
367 /// Readable | Writeable
368 ///
369 ///
370 /// #### `hexpand-set`
371 /// Whether to use the `hexpand` property.
372 ///
373 /// Readable | Writeable
374 ///
375 ///
376 /// #### `layout-manager`
377 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
378 /// the preferred size of the widget, and allocate its children.
379 ///
380 /// This property is meant to be set by widget implementations,
381 /// typically in their instance init function.
382 ///
383 /// Readable | Writeable
384 ///
385 ///
386 /// #### `limit-events`
387 /// Makes this widget act like a modal dialog, with respect to
388 /// event delivery.
389 ///
390 /// Global event controllers will not handle events with targets
391 /// inside the widget, unless they are set up to ignore propagation
392 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
393 ///
394 /// Readable | Writeable
395 ///
396 ///
397 /// #### `margin-bottom`
398 /// Margin on bottom side of widget.
399 ///
400 /// This property adds margin outside of the widget's normal size
401 /// request, the margin will be added in addition to the size from
402 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
403 ///
404 /// Readable | Writeable
405 ///
406 ///
407 /// #### `margin-end`
408 /// Margin on end of widget, horizontally.
409 ///
410 /// This property supports left-to-right and right-to-left text
411 /// directions.
412 ///
413 /// This property adds margin outside of the widget's normal size
414 /// request, the margin will be added in addition to the size from
415 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
416 ///
417 /// Readable | Writeable
418 ///
419 ///
420 /// #### `margin-start`
421 /// Margin on start of widget, horizontally.
422 ///
423 /// This property supports left-to-right and right-to-left text
424 /// directions.
425 ///
426 /// This property adds margin outside of the widget's normal size
427 /// request, the margin will be added in addition to the size from
428 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
429 ///
430 /// Readable | Writeable
431 ///
432 ///
433 /// #### `margin-top`
434 /// Margin on top side of widget.
435 ///
436 /// This property adds margin outside of the widget's normal size
437 /// request, the margin will be added in addition to the size from
438 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
439 ///
440 /// Readable | Writeable
441 ///
442 ///
443 /// #### `name`
444 /// The name of the widget.
445 ///
446 /// Readable | Writeable
447 ///
448 ///
449 /// #### `opacity`
450 /// The requested opacity of the widget.
451 ///
452 /// Readable | Writeable
453 ///
454 ///
455 /// #### `overflow`
456 /// How content outside the widget's content area is treated.
457 ///
458 /// This property is meant to be set by widget implementations,
459 /// typically in their instance init function.
460 ///
461 /// Readable | Writeable
462 ///
463 ///
464 /// #### `parent`
465 /// The parent widget of this widget.
466 ///
467 /// Readable
468 ///
469 ///
470 /// #### `receives-default`
471 /// Whether the widget will receive the default action when it is focused.
472 ///
473 /// Readable | Writeable
474 ///
475 ///
476 /// #### `root`
477 /// The [`Root`][crate::Root] widget of the widget tree containing this widget.
478 ///
479 /// This will be `NULL` if the widget is not contained in a root widget.
480 ///
481 /// Readable
482 ///
483 ///
484 /// #### `scale-factor`
485 /// The scale factor of the widget.
486 ///
487 /// Readable
488 ///
489 ///
490 /// #### `sensitive`
491 /// Whether the widget responds to input.
492 ///
493 /// Readable | Writeable
494 ///
495 ///
496 /// #### `tooltip-markup`
497 /// Sets the text of tooltip to be the given string, which is marked up
498 /// with Pango markup.
499 ///
500 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
501 ///
502 /// This is a convenience property which will take care of getting the
503 /// tooltip shown if the given string is not `NULL`:
504 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
505 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
506 /// the default signal handler.
507 ///
508 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
509 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
510 ///
511 /// Readable | Writeable
512 ///
513 ///
514 /// #### `tooltip-text`
515 /// Sets the text of tooltip to be the given string.
516 ///
517 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
518 ///
519 /// This is a convenience property which will take care of getting the
520 /// tooltip shown if the given string is not `NULL`:
521 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
522 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
523 /// the default signal handler.
524 ///
525 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
526 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
527 ///
528 /// Readable | Writeable
529 ///
530 ///
531 /// #### `valign`
532 /// How to distribute vertical space if widget gets extra space.
533 ///
534 /// Readable | Writeable
535 ///
536 ///
537 /// #### `vexpand`
538 /// Whether to expand vertically.
539 ///
540 /// Readable | Writeable
541 ///
542 ///
543 /// #### `vexpand-set`
544 /// Whether to use the `vexpand` property.
545 ///
546 /// Readable | Writeable
547 ///
548 ///
549 /// #### `visible`
550 /// Whether the widget is visible.
551 ///
552 /// Readable | Writeable
553 ///
554 ///
555 /// #### `width-request`
556 /// Overrides for width request of the widget.
557 ///
558 /// If this is -1, the natural request will be used.
559 ///
560 /// Readable | Writeable
561 /// </details>
562 /// <details><summary><h4>Accessible</h4></summary>
563 ///
564 ///
565 /// #### `accessible-role`
566 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
567 ///
568 /// The accessible role cannot be changed once set.
569 ///
570 /// Readable | Writeable
571 /// </details>
572 ///
573 /// ## Signals
574 ///
575 ///
576 /// #### `activate-default`
577 /// Emitted when the user activates the default widget.
578 ///
579 /// This is a [keybinding signal](class.SignalAction.html).
580 ///
581 /// The keybindings for this signal are all forms of the <kbd>Enter</kbd> key.
582 ///
583 /// Action
584 ///
585 ///
586 /// #### `activate-focus`
587 /// Emitted when the user activates the currently focused
588 /// widget of @window.
589 ///
590 /// This is a [keybinding signal](class.SignalAction.html).
591 ///
592 /// The default binding for this signal is <kbd>␣</kbd>.
593 ///
594 /// Action
595 ///
596 ///
597 /// #### `close-request`
598 /// Emitted when the user clicks on the close button of the window.
599 ///
600 ///
601 ///
602 ///
603 /// #### `enable-debugging`
604 /// Emitted when the user enables or disables interactive debugging.
605 ///
606 /// When @toggle is true, interactive debugging is toggled on or off,
607 /// when it is false, the debugger will be pointed at the widget
608 /// under the pointer.
609 ///
610 /// This is a [keybinding signal](class.SignalAction.html).
611 ///
612 /// The default bindings for this signal are
613 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd> and
614 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd>.
615 ///
616 /// Action
617 ///
618 ///
619 /// #### `keys-changed`
620 /// Emitted when the set of accelerators or mnemonics that
621 /// are associated with the window changes.
622 ///
623 ///
624 /// <details><summary><h4>Widget</h4></summary>
625 ///
626 ///
627 /// #### `destroy`
628 /// Signals that all holders of a reference to the widget should release
629 /// the reference that they hold.
630 ///
631 /// May result in finalization of the widget if all references are released.
632 ///
633 /// This signal is not suitable for saving widget state.
634 ///
635 ///
636 ///
637 ///
638 /// #### `direction-changed`
639 /// Emitted when the text direction of a widget changes.
640 ///
641 ///
642 ///
643 ///
644 /// #### `hide`
645 /// Emitted when @widget is hidden.
646 ///
647 ///
648 ///
649 ///
650 /// #### `keynav-failed`
651 /// Emitted if keyboard navigation fails.
652 ///
653 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
654 ///
655 ///
656 ///
657 ///
658 /// #### `map`
659 /// Emitted when @widget is going to be mapped.
660 ///
661 /// A widget is mapped when the widget is visible (which is controlled with
662 /// [`visible`][struct@crate::Widget#visible]) and all its parents up to the toplevel widget
663 /// are also visible.
664 ///
665 /// The `::map` signal can be used to determine whether a widget will be drawn,
666 /// for instance it can resume an animation that was stopped during the
667 /// emission of [`unmap`][struct@crate::Widget#unmap].
668 ///
669 ///
670 ///
671 ///
672 /// #### `mnemonic-activate`
673 /// Emitted when a widget is activated via a mnemonic.
674 ///
675 /// The default handler for this signal activates @widget if @group_cycling
676 /// is false, or just makes @widget grab focus if @group_cycling is true.
677 ///
678 ///
679 ///
680 ///
681 /// #### `move-focus`
682 /// Emitted when the focus is moved.
683 ///
684 /// The `::move-focus` signal is a [keybinding signal](class.SignalAction.html).
685 ///
686 /// The default bindings for this signal are <kbd>Tab</kbd> to move forward,
687 /// and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.
688 ///
689 /// Action
690 ///
691 ///
692 /// #### `query-tooltip`
693 /// Emitted when the widget’s tooltip is about to be shown.
694 ///
695 /// This happens when the [`has-tooltip`][struct@crate::Widget#has-tooltip] property
696 /// is true and the hover timeout has expired with the cursor hovering
697 /// above @widget; or emitted when @widget got focus in keyboard mode.
698 ///
699 /// Using the given coordinates, the signal handler should determine
700 /// whether a tooltip should be shown for @widget. If this is the case
701 /// true should be returned, false otherwise. Note that if @keyboard_mode
702 /// is true, the values of @x and @y are undefined and should not be used.
703 ///
704 /// The signal handler is free to manipulate @tooltip with the therefore
705 /// destined function calls.
706 ///
707 ///
708 ///
709 ///
710 /// #### `realize`
711 /// Emitted when @widget is associated with a [`gdk::Surface`][crate::gdk::Surface].
712 ///
713 /// This means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called
714 /// or the widget has been mapped (that is, it is going to be drawn).
715 ///
716 ///
717 ///
718 ///
719 /// #### `show`
720 /// Emitted when @widget is shown.
721 ///
722 ///
723 ///
724 ///
725 /// #### `state-flags-changed`
726 /// Emitted when the widget state changes.
727 ///
728 /// See [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
729 ///
730 ///
731 ///
732 ///
733 /// #### `unmap`
734 /// Emitted when @widget is going to be unmapped.
735 ///
736 /// A widget is unmapped when either it or any of its parents up to the
737 /// toplevel widget have been set as hidden.
738 ///
739 /// As `::unmap` indicates that a widget will not be shown any longer,
740 /// it can be used to, for example, stop an animation on the widget.
741 ///
742 ///
743 ///
744 ///
745 /// #### `unrealize`
746 /// Emitted when the [`gdk::Surface`][crate::gdk::Surface] associated with @widget is destroyed.
747 ///
748 /// This means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been called
749 /// or the widget has been unmapped (that is, it is going to be hidden).
750 ///
751 ///
752 /// </details>
753 ///
754 /// # Implements
755 ///
756 /// [`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]
757 #[doc(alias = "GtkWindow")]
758 pub struct Window(Object<ffi::GtkWindow, ffi::GtkWindowClass>) @extends Widget, @implements Accessible, Buildable, ConstraintTarget, Native, Root, ShortcutManager;
759
760 match fn {
761 type_ => || ffi::gtk_window_get_type(),
762 }
763}
764
765impl Window {
766 pub const NONE: Option<&'static Window> = None;
767
768 /// Creates a new [`Window`][crate::Window].
769 ///
770 /// To get an undecorated window (without window borders),
771 /// use [`GtkWindowExt::set_decorated()`][crate::prelude::GtkWindowExt::set_decorated()].
772 ///
773 /// All top-level windows created by this function are stored
774 /// in an internal top-level window list. This list can be obtained
775 /// from [`list_toplevels()`][Self::list_toplevels()]. Due to GTK keeping a
776 /// reference to the window internally, this function does not
777 /// return a reference to the caller.
778 ///
779 /// To delete a [`Window`][crate::Window], call `Gtk::Window::destroy()`.
780 ///
781 /// # Returns
782 ///
783 /// a new [`Window`][crate::Window]
784 #[doc(alias = "gtk_window_new")]
785 pub fn new() -> Window {
786 assert_initialized_main_thread!();
787 unsafe { Widget::from_glib_none(ffi::gtk_window_new()).unsafe_cast() }
788 }
789
790 // rustdoc-stripper-ignore-next
791 /// Creates a new builder-pattern struct instance to construct [`Window`] objects.
792 ///
793 /// This method returns an instance of [`WindowBuilder`](crate::builders::WindowBuilder) which can be used to create [`Window`] objects.
794 pub fn builder() -> WindowBuilder {
795 WindowBuilder::new()
796 }
797
798 /// Returns the fallback icon name for windows.
799 ///
800 /// The returned string is owned by GTK and should not
801 /// be modified. It is only valid until the next call to
802 /// [`set_default_icon_name()`][Self::set_default_icon_name()].
803 ///
804 /// # Returns
805 ///
806 /// the fallback icon name for windows
807 #[doc(alias = "gtk_window_get_default_icon_name")]
808 #[doc(alias = "get_default_icon_name")]
809 pub fn default_icon_name() -> Option<glib::GString> {
810 assert_initialized_main_thread!();
811 unsafe { from_glib_none(ffi::gtk_window_get_default_icon_name()) }
812 }
813
814 /// Returns the list of all existing toplevel windows.
815 ///
816 /// If you want to iterate through the list and perform actions involving
817 /// callbacks that might destroy the widgets or add new ones, be aware that
818 /// the list of toplevels will change and emit the "items-changed" signal.
819 ///
820 /// # Returns
821 ///
822 /// the list
823 /// of toplevel widgets
824 #[doc(alias = "gtk_window_get_toplevels")]
825 #[doc(alias = "get_toplevels")]
826 pub fn toplevels() -> gio::ListModel {
827 assert_initialized_main_thread!();
828 unsafe { from_glib_none(ffi::gtk_window_get_toplevels()) }
829 }
830
831 /// Returns the list of all existing toplevel windows.
832 ///
833 /// The widgets in the list are not individually referenced.
834 /// If you want to iterate through the list and perform actions
835 /// involving callbacks that might destroy the widgets, you must
836 /// call `g_list_foreach (result, (GFunc)g_object_ref, NULL)` first,
837 /// and then unref all the widgets afterwards.
838 ///
839 /// # Returns
840 ///
841 /// list of
842 /// toplevel widgets
843 #[doc(alias = "gtk_window_list_toplevels")]
844 pub fn list_toplevels() -> Vec<Widget> {
845 assert_initialized_main_thread!();
846 unsafe { FromGlibPtrContainer::from_glib_container(ffi::gtk_window_list_toplevels()) }
847 }
848
849 /// Sets whether the window should request startup notification.
850 ///
851 /// By default, after showing the first window, GTK calls
852 /// `Gdk::Toplevel::set_startup_id()`. Call this function
853 /// to disable the automatic startup notification. You might do this
854 /// if your first window is a splash screen, and you want to delay
855 /// notification until after your real main window has been shown,
856 /// for example.
857 ///
858 /// In that example, you would disable startup notification
859 /// temporarily, show your splash screen, then re-enable it so that
860 /// showing the main window would automatically result in notification.
861 /// ## `setting`
862 /// true to automatically do startup notification
863 #[doc(alias = "gtk_window_set_auto_startup_notification")]
864 pub fn set_auto_startup_notification(setting: bool) {
865 assert_initialized_main_thread!();
866 unsafe {
867 ffi::gtk_window_set_auto_startup_notification(setting.into_glib());
868 }
869 }
870
871 /// Sets an icon to be used as fallback.
872 ///
873 /// The fallback icon is used for windows that
874 /// haven't had [`GtkWindowExt::set_icon_name()`][crate::prelude::GtkWindowExt::set_icon_name()]
875 /// called on them.
876 /// ## `name`
877 /// the name of the themed icon
878 #[doc(alias = "gtk_window_set_default_icon_name")]
879 pub fn set_default_icon_name(name: &str) {
880 assert_initialized_main_thread!();
881 unsafe {
882 ffi::gtk_window_set_default_icon_name(name.to_glib_none().0);
883 }
884 }
885
886 /// Opens or closes the [interactive debugger](running.html#interactive-debugging).
887 ///
888 /// The debugger offers access to the widget hierarchy of the application
889 /// and to useful debugging tools.
890 ///
891 /// This function allows applications that already use
892 /// <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>I</kbd>
893 /// (or <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd>)
894 /// for their own key shortcuts to add a different shortcut to open the Inspector.
895 ///
896 /// If you are not overriding the default key shortcuts for the Inspector,
897 /// you should not use this function.
898 /// ## `enable`
899 /// true to enable interactive debugging
900 #[doc(alias = "gtk_window_set_interactive_debugging")]
901 pub fn set_interactive_debugging(enable: bool) {
902 assert_initialized_main_thread!();
903 unsafe {
904 ffi::gtk_window_set_interactive_debugging(enable.into_glib());
905 }
906 }
907}
908
909impl Default for Window {
910 fn default() -> Self {
911 Self::new()
912 }
913}
914
915// rustdoc-stripper-ignore-next
916/// A [builder-pattern] type to construct [`Window`] objects.
917///
918/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
919#[must_use = "The builder must be built to be used"]
920pub struct WindowBuilder {
921 builder: glib::object::ObjectBuilder<'static, Window>,
922}
923
924impl WindowBuilder {
925 fn new() -> Self {
926 Self {
927 builder: glib::object::Object::builder(),
928 }
929 }
930
931 /// The [`Application`][crate::Application] associated with the window.
932 ///
933 /// The application will be kept alive for at least as long as it
934 /// has any windows associated with it (see g_application_hold()
935 /// for a way to keep it alive without windows).
936 ///
937 /// Normally, the connection between the application and the window
938 /// will remain until the window is destroyed, but you can explicitly
939 /// remove it by setting the this property to `NULL`.
940 pub fn application(self, application: &impl IsA<Application>) -> Self {
941 Self {
942 builder: self
943 .builder
944 .property("application", application.clone().upcast()),
945 }
946 }
947
948 /// The child widget.
949 pub fn child(self, child: &impl IsA<Widget>) -> Self {
950 Self {
951 builder: self.builder.property("child", child.clone().upcast()),
952 }
953 }
954
955 /// Whether the window should have a frame (also known as *decorations*).
956 pub fn decorated(self, decorated: bool) -> Self {
957 Self {
958 builder: self.builder.property("decorated", decorated),
959 }
960 }
961
962 /// The default height of the window.
963 pub fn default_height(self, default_height: i32) -> Self {
964 Self {
965 builder: self.builder.property("default-height", default_height),
966 }
967 }
968
969 /// The default widget.
970 pub fn default_widget(self, default_widget: &impl IsA<Widget>) -> Self {
971 Self {
972 builder: self
973 .builder
974 .property("default-widget", default_widget.clone().upcast()),
975 }
976 }
977
978 /// The default width of the window.
979 pub fn default_width(self, default_width: i32) -> Self {
980 Self {
981 builder: self.builder.property("default-width", default_width),
982 }
983 }
984
985 /// Whether the window frame should have a close button.
986 pub fn deletable(self, deletable: bool) -> Self {
987 Self {
988 builder: self.builder.property("deletable", deletable),
989 }
990 }
991
992 /// If this window should be destroyed when the parent is destroyed.
993 pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
994 Self {
995 builder: self
996 .builder
997 .property("destroy-with-parent", destroy_with_parent),
998 }
999 }
1000
1001 /// The display that will display this window.
1002 pub fn display(self, display: &impl IsA<gdk::Display>) -> Self {
1003 Self {
1004 builder: self.builder.property("display", display.clone().upcast()),
1005 }
1006 }
1007
1008 /// Whether 'focus rectangles' are currently visible in this window.
1009 ///
1010 /// This property is maintained by GTK based on user input
1011 /// and should not be set by applications.
1012 pub fn focus_visible(self, focus_visible: bool) -> Self {
1013 Self {
1014 builder: self.builder.property("focus-visible", focus_visible),
1015 }
1016 }
1017
1018 /// The focus widget.
1019 pub fn focus_widget(self, focus_widget: &impl IsA<Widget>) -> Self {
1020 Self {
1021 builder: self
1022 .builder
1023 .property("focus-widget", focus_widget.clone().upcast()),
1024 }
1025 }
1026
1027 /// Whether the window is fullscreen.
1028 ///
1029 /// Setting this property is the equivalent of calling
1030 /// [`GtkWindowExt::fullscreen()`][crate::prelude::GtkWindowExt::fullscreen()] or [`GtkWindowExt::unfullscreen()`][crate::prelude::GtkWindowExt::unfullscreen()];
1031 /// either operation is asynchronous, which means you will need to
1032 /// connect to the ::notify signal in order to know whether the
1033 /// operation was successful.
1034 pub fn fullscreened(self, fullscreened: bool) -> Self {
1035 Self {
1036 builder: self.builder.property("fullscreened", fullscreened),
1037 }
1038 }
1039
1040 /// Whether the window frame should handle <kbd>F10</kbd> for activating
1041 /// menubars.
1042 #[cfg(feature = "v4_2")]
1043 #[cfg_attr(docsrs, doc(cfg(feature = "v4_2")))]
1044 pub fn handle_menubar_accel(self, handle_menubar_accel: bool) -> Self {
1045 Self {
1046 builder: self
1047 .builder
1048 .property("handle-menubar-accel", handle_menubar_accel),
1049 }
1050 }
1051
1052 /// If this window should be hidden when the users clicks the close button.
1053 pub fn hide_on_close(self, hide_on_close: bool) -> Self {
1054 Self {
1055 builder: self.builder.property("hide-on-close", hide_on_close),
1056 }
1057 }
1058
1059 /// Specifies the name of the themed icon to use as the window icon.
1060 ///
1061 /// See [`IconTheme`][crate::IconTheme] for more details.
1062 pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
1063 Self {
1064 builder: self.builder.property("icon-name", icon_name.into()),
1065 }
1066 }
1067
1068 /// Whether the window is maximized.
1069 ///
1070 /// Setting this property is the equivalent of calling
1071 /// [`GtkWindowExt::maximize()`][crate::prelude::GtkWindowExt::maximize()] or [`GtkWindowExt::unmaximize()`][crate::prelude::GtkWindowExt::unmaximize()];
1072 /// either operation is asynchronous, which means you will need to
1073 /// connect to the ::notify signal in order to know whether the
1074 /// operation was successful.
1075 pub fn maximized(self, maximized: bool) -> Self {
1076 Self {
1077 builder: self.builder.property("maximized", maximized),
1078 }
1079 }
1080
1081 /// Whether mnemonics are currently visible in this window.
1082 ///
1083 /// This property is maintained by GTK based on user input,
1084 /// and should not be set by applications.
1085 pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
1086 Self {
1087 builder: self
1088 .builder
1089 .property("mnemonics-visible", mnemonics_visible),
1090 }
1091 }
1092
1093 /// If true, the window is modal.
1094 pub fn modal(self, modal: bool) -> Self {
1095 Self {
1096 builder: self.builder.property("modal", modal),
1097 }
1098 }
1099
1100 /// If true, users can resize the window.
1101 pub fn resizable(self, resizable: bool) -> Self {
1102 Self {
1103 builder: self.builder.property("resizable", resizable),
1104 }
1105 }
1106
1107 /// A write-only property for setting window's startup notification identifier.
1108 pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
1109 Self {
1110 builder: self.builder.property("startup-id", startup_id.into()),
1111 }
1112 }
1113
1114 /// The title of the window.
1115 pub fn title(self, title: impl Into<glib::GString>) -> Self {
1116 Self {
1117 builder: self.builder.property("title", title.into()),
1118 }
1119 }
1120
1121 /// The titlebar widget.
1122 #[cfg(feature = "v4_6")]
1123 #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))]
1124 pub fn titlebar(self, titlebar: &impl IsA<Widget>) -> Self {
1125 Self {
1126 builder: self.builder.property("titlebar", titlebar.clone().upcast()),
1127 }
1128 }
1129
1130 /// The transient parent of the window.
1131 pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
1132 Self {
1133 builder: self
1134 .builder
1135 .property("transient-for", transient_for.clone().upcast()),
1136 }
1137 }
1138
1139 /// Whether the widget or any of its descendents can accept
1140 /// the input focus.
1141 ///
1142 /// This property is meant to be set by widget implementations,
1143 /// typically in their instance init function.
1144 pub fn can_focus(self, can_focus: bool) -> Self {
1145 Self {
1146 builder: self.builder.property("can-focus", can_focus),
1147 }
1148 }
1149
1150 /// Whether the widget can receive pointer events.
1151 pub fn can_target(self, can_target: bool) -> Self {
1152 Self {
1153 builder: self.builder.property("can-target", can_target),
1154 }
1155 }
1156
1157 /// A list of css classes applied to this widget.
1158 pub fn css_classes(self, css_classes: impl Into<glib::StrV>) -> Self {
1159 Self {
1160 builder: self.builder.property("css-classes", css_classes.into()),
1161 }
1162 }
1163
1164 /// The name of this widget in the CSS tree.
1165 ///
1166 /// This property is meant to be set by widget implementations,
1167 /// typically in their instance init function.
1168 pub fn css_name(self, css_name: impl Into<glib::GString>) -> Self {
1169 Self {
1170 builder: self.builder.property("css-name", css_name.into()),
1171 }
1172 }
1173
1174 /// The cursor used by @widget.
1175 pub fn cursor(self, cursor: &gdk::Cursor) -> Self {
1176 Self {
1177 builder: self.builder.property("cursor", cursor.clone()),
1178 }
1179 }
1180
1181 /// Whether the widget should grab focus when it is clicked with the mouse.
1182 ///
1183 /// This property is only relevant for widgets that can take focus.
1184 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
1185 Self {
1186 builder: self.builder.property("focus-on-click", focus_on_click),
1187 }
1188 }
1189
1190 /// Whether this widget itself will accept the input focus.
1191 pub fn focusable(self, focusable: bool) -> Self {
1192 Self {
1193 builder: self.builder.property("focusable", focusable),
1194 }
1195 }
1196
1197 /// How to distribute horizontal space if widget gets extra space.
1198 pub fn halign(self, halign: Align) -> Self {
1199 Self {
1200 builder: self.builder.property("halign", halign),
1201 }
1202 }
1203
1204 /// Enables or disables the emission of the [`query-tooltip`][struct@crate::Widget#query-tooltip]
1205 /// signal on @widget.
1206 ///
1207 /// A true value indicates that @widget can have a tooltip, in this case
1208 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to
1209 /// determine whether it will provide a tooltip or not.
1210 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
1211 Self {
1212 builder: self.builder.property("has-tooltip", has_tooltip),
1213 }
1214 }
1215
1216 /// Overrides for height request of the widget.
1217 ///
1218 /// If this is -1, the natural request will be used.
1219 pub fn height_request(self, height_request: i32) -> Self {
1220 Self {
1221 builder: self.builder.property("height-request", height_request),
1222 }
1223 }
1224
1225 /// Whether to expand horizontally.
1226 pub fn hexpand(self, hexpand: bool) -> Self {
1227 Self {
1228 builder: self.builder.property("hexpand", hexpand),
1229 }
1230 }
1231
1232 /// Whether to use the `hexpand` property.
1233 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
1234 Self {
1235 builder: self.builder.property("hexpand-set", hexpand_set),
1236 }
1237 }
1238
1239 /// The [`LayoutManager`][crate::LayoutManager] instance to use to compute
1240 /// the preferred size of the widget, and allocate its children.
1241 ///
1242 /// This property is meant to be set by widget implementations,
1243 /// typically in their instance init function.
1244 pub fn layout_manager(self, layout_manager: &impl IsA<LayoutManager>) -> Self {
1245 Self {
1246 builder: self
1247 .builder
1248 .property("layout-manager", layout_manager.clone().upcast()),
1249 }
1250 }
1251
1252 /// Makes this widget act like a modal dialog, with respect to
1253 /// event delivery.
1254 ///
1255 /// Global event controllers will not handle events with targets
1256 /// inside the widget, unless they are set up to ignore propagation
1257 /// limits. See [`EventControllerExt::set_propagation_limit()`][crate::prelude::EventControllerExt::set_propagation_limit()].
1258 #[cfg(feature = "v4_18")]
1259 #[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
1260 pub fn limit_events(self, limit_events: bool) -> Self {
1261 Self {
1262 builder: self.builder.property("limit-events", limit_events),
1263 }
1264 }
1265
1266 /// Margin on bottom side of widget.
1267 ///
1268 /// This property adds margin outside of the widget's normal size
1269 /// request, the margin will be added in addition to the size from
1270 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1271 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
1272 Self {
1273 builder: self.builder.property("margin-bottom", margin_bottom),
1274 }
1275 }
1276
1277 /// Margin on end of widget, horizontally.
1278 ///
1279 /// This property supports left-to-right and right-to-left text
1280 /// directions.
1281 ///
1282 /// This property adds margin outside of the widget's normal size
1283 /// request, the margin will be added in addition to the size from
1284 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1285 pub fn margin_end(self, margin_end: i32) -> Self {
1286 Self {
1287 builder: self.builder.property("margin-end", margin_end),
1288 }
1289 }
1290
1291 /// Margin on start of widget, horizontally.
1292 ///
1293 /// This property supports left-to-right and right-to-left text
1294 /// directions.
1295 ///
1296 /// This property adds margin outside of the widget's normal size
1297 /// request, the margin will be added in addition to the size from
1298 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1299 pub fn margin_start(self, margin_start: i32) -> Self {
1300 Self {
1301 builder: self.builder.property("margin-start", margin_start),
1302 }
1303 }
1304
1305 /// Margin on top side of widget.
1306 ///
1307 /// This property adds margin outside of the widget's normal size
1308 /// request, the margin will be added in addition to the size from
1309 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
1310 pub fn margin_top(self, margin_top: i32) -> Self {
1311 Self {
1312 builder: self.builder.property("margin-top", margin_top),
1313 }
1314 }
1315
1316 /// The name of the widget.
1317 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1318 Self {
1319 builder: self.builder.property("name", name.into()),
1320 }
1321 }
1322
1323 /// The requested opacity of the widget.
1324 pub fn opacity(self, opacity: f64) -> Self {
1325 Self {
1326 builder: self.builder.property("opacity", opacity),
1327 }
1328 }
1329
1330 /// How content outside the widget's content area is treated.
1331 ///
1332 /// This property is meant to be set by widget implementations,
1333 /// typically in their instance init function.
1334 pub fn overflow(self, overflow: Overflow) -> Self {
1335 Self {
1336 builder: self.builder.property("overflow", overflow),
1337 }
1338 }
1339
1340 /// Whether the widget will receive the default action when it is focused.
1341 pub fn receives_default(self, receives_default: bool) -> Self {
1342 Self {
1343 builder: self.builder.property("receives-default", receives_default),
1344 }
1345 }
1346
1347 /// Whether the widget responds to input.
1348 pub fn sensitive(self, sensitive: bool) -> Self {
1349 Self {
1350 builder: self.builder.property("sensitive", sensitive),
1351 }
1352 }
1353
1354 /// Sets the text of tooltip to be the given string, which is marked up
1355 /// with Pango markup.
1356 ///
1357 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1358 ///
1359 /// This is a convenience property which will take care of getting the
1360 /// tooltip shown if the given string is not `NULL`:
1361 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1362 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1363 /// the default signal handler.
1364 ///
1365 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1366 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1367 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1368 Self {
1369 builder: self
1370 .builder
1371 .property("tooltip-markup", tooltip_markup.into()),
1372 }
1373 }
1374
1375 /// Sets the text of tooltip to be the given string.
1376 ///
1377 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1378 ///
1379 /// This is a convenience property which will take care of getting the
1380 /// tooltip shown if the given string is not `NULL`:
1381 /// [`has-tooltip`][struct@crate::Widget#has-tooltip] will automatically be set to true
1382 /// and there will be taken care of [`query-tooltip`][struct@crate::Widget#query-tooltip] in
1383 /// the default signal handler.
1384 ///
1385 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and
1386 /// [`tooltip-markup`][struct@crate::Widget#tooltip-markup] are set, the last one wins.
1387 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1388 Self {
1389 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1390 }
1391 }
1392
1393 /// How to distribute vertical space if widget gets extra space.
1394 pub fn valign(self, valign: Align) -> Self {
1395 Self {
1396 builder: self.builder.property("valign", valign),
1397 }
1398 }
1399
1400 /// Whether to expand vertically.
1401 pub fn vexpand(self, vexpand: bool) -> Self {
1402 Self {
1403 builder: self.builder.property("vexpand", vexpand),
1404 }
1405 }
1406
1407 /// Whether to use the `vexpand` property.
1408 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1409 Self {
1410 builder: self.builder.property("vexpand-set", vexpand_set),
1411 }
1412 }
1413
1414 /// Whether the widget is visible.
1415 pub fn visible(self, visible: bool) -> Self {
1416 Self {
1417 builder: self.builder.property("visible", visible),
1418 }
1419 }
1420
1421 /// Overrides for width request of the widget.
1422 ///
1423 /// If this is -1, the natural request will be used.
1424 pub fn width_request(self, width_request: i32) -> Self {
1425 Self {
1426 builder: self.builder.property("width-request", width_request),
1427 }
1428 }
1429
1430 /// The accessible role of the given [`Accessible`][crate::Accessible] implementation.
1431 ///
1432 /// The accessible role cannot be changed once set.
1433 pub fn accessible_role(self, accessible_role: AccessibleRole) -> Self {
1434 Self {
1435 builder: self.builder.property("accessible-role", accessible_role),
1436 }
1437 }
1438
1439 // rustdoc-stripper-ignore-next
1440 /// Build the [`Window`].
1441 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1442 pub fn build(self) -> Window {
1443 assert_initialized_main_thread!();
1444 self.builder.build()
1445 }
1446}
1447
1448mod sealed {
1449 pub trait Sealed {}
1450 impl<T: super::IsA<super::Window>> Sealed for T {}
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> + sealed::Sealed + '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 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 b"activate-default\0".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 b"activate-focus\0".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 b"close-request\0".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 b"enable-debugging\0".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 b"keys-changed\0".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 b"notify::application\0".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 b"notify::child\0".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 b"notify::decorated\0".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 b"notify::default-height\0".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 b"notify::default-widget\0".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 b"notify::default-width\0".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 b"notify::deletable\0".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 b"notify::destroy-with-parent\0".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 b"notify::display\0".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 b"notify::focus-visible\0".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 b"notify::focus-widget\0".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 b"notify::fullscreened\0".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 b"notify::handle-menubar-accel\0".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 b"notify::hide-on-close\0".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 b"notify::icon-name\0".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 b"notify::is-active\0".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 b"notify::maximized\0".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 b"notify::mnemonics-visible\0".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 b"notify::modal\0".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 b"notify::resizable\0".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 b"notify::startup-id\0".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 b"notify::suspended\0".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 b"notify::title\0".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 b"notify::titlebar\0".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 b"notify::transient-for\0".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 {}