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