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