Skip to main content

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