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