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