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