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