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