Skip to main content

gtk/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
5use crate::{
6    Align, Application, Bin, Buildable, Container, ResizeMode, ShortcutsWindow, Widget, Window,
7    WindowPosition, WindowType, ffi,
8};
9use glib::{
10    prelude::*,
11    signal::{SignalHandlerId, connect_raw},
12    translate::*,
13};
14use std::boxed::Box as Box_;
15
16glib::wrapper! {
17    /// ` elements can be marked for translation with a
18    /// `translatable="yes"` attribute. It is also possible to specify message
19    /// context and translator comments, using the context and comments attributes.
20    /// To make use of this, the [`Builder`][crate::Builder] must have been given the gettext
21    /// domain to use.
22    ///
23    /// The following attributes are used when constructing menu items:
24    /// - "label": a user-visible string to display
25    /// - "action": the prefixed name of the action to trigger
26    /// - "target": the parameter to use when activating the action
27    /// - "icon" and "verb-icon": names of icons that may be displayed
28    /// - "submenu-action": name of an action that may be used to determine
29    ///  if a submenu can be opened
30    /// - "hidden-when": a string used to determine when the item will be hidden.
31    ///  Possible values include "action-disabled", "action-missing", "macos-menubar".
32    ///
33    /// The following attributes are used when constructing sections:
34    /// - "label": a user-visible string to use as section heading
35    /// - "display-hint": a string used to determine special formatting for the section.
36    ///  Possible values include "horizontal-buttons".
37    /// - "text-direction": a string used to determine the [`TextDirection`][crate::TextDirection] to use
38    ///  when "display-hint" is set to "horizontal-buttons". Possible values
39    ///  include "rtl", "ltr", and "none".
40    ///
41    /// The following attributes are used when constructing submenus:
42    /// - "label": a user-visible string to display
43    /// - "icon": icon name to display
44    ///
45    /// ## Properties
46    ///
47    ///
48    /// #### `show-menubar`
49    ///  If this property is [`true`], the window will display a menubar
50    /// that includes the app menu and menubar, unless these are
51    /// shown by the desktop shell. See [`GtkApplicationExt::set_app_menu()`][crate::prelude::GtkApplicationExt::set_app_menu()]
52    /// and [`GtkApplicationExt::set_menubar()`][crate::prelude::GtkApplicationExt::set_menubar()].
53    ///
54    /// If [`false`], the window will not display a menubar, regardless
55    /// of whether the desktop shell is showing the menus or not.
56    ///
57    /// Readable | Writable | Construct
58    /// <details><summary><h4>Window</h4></summary>
59    ///
60    ///
61    /// #### `accept-focus`
62    ///  Whether the window should receive the input focus.
63    ///
64    /// Readable | Writable
65    ///
66    ///
67    /// #### `application`
68    ///  The [`Application`][crate::Application] associated with the window.
69    ///
70    /// The application will be kept alive for at least as long as it
71    /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
72    /// for a way to keep it alive without windows).
73    ///
74    /// Normally, the connection between the application and the window
75    /// will remain until the window is destroyed, but you can explicitly
76    /// remove it by setting the :application property to [`None`].
77    ///
78    /// Readable | Writable
79    ///
80    ///
81    /// #### `attached-to`
82    ///  The widget to which this window is attached.
83    /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
84    ///
85    /// Examples of places where specifying this relation is useful are
86    /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
87    /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
88    /// created by [`TreeView`][crate::TreeView].
89    ///
90    /// Readable | Writable | Construct
91    ///
92    ///
93    /// #### `decorated`
94    ///  Whether the window should be decorated by the window manager.
95    ///
96    /// Readable | Writable
97    ///
98    ///
99    /// #### `default-height`
100    ///  Readable | Writable
101    ///
102    ///
103    /// #### `default-width`
104    ///  Readable | Writable
105    ///
106    ///
107    /// #### `deletable`
108    ///  Whether the window frame should have a close button.
109    ///
110    /// Readable | Writable
111    ///
112    ///
113    /// #### `destroy-with-parent`
114    ///  Readable | Writable
115    ///
116    ///
117    /// #### `focus-on-map`
118    ///  Whether the window should receive the input focus when mapped.
119    ///
120    /// Readable | Writable
121    ///
122    ///
123    /// #### `focus-visible`
124    ///  Whether 'focus rectangles' are currently visible in this window.
125    ///
126    /// This property is maintained by GTK+ based on user input
127    /// and should not be set by applications.
128    ///
129    /// Readable | Writable
130    ///
131    ///
132    /// #### `gravity`
133    ///  The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
134    /// more details about window gravity.
135    ///
136    /// Readable | Writable
137    ///
138    ///
139    /// #### `has-resize-grip`
140    ///  Whether the window has a corner resize grip.
141    ///
142    /// Note that the resize grip is only shown if the window is
143    /// actually resizable and not maximized. Use
144    /// [`resize-grip-visible`][struct@crate::Window#resize-grip-visible] to find out if the resize
145    /// grip is currently shown.
146    ///
147    /// Readable | Writable
148    ///
149    ///
150    /// #### `has-toplevel-focus`
151    ///  Readable
152    ///
153    ///
154    /// #### `hide-titlebar-when-maximized`
155    ///  Whether the titlebar should be hidden during maximization.
156    ///
157    /// Readable | Writable
158    ///
159    ///
160    /// #### `icon`
161    ///  Readable | Writable
162    ///
163    ///
164    /// #### `icon-name`
165    ///  The :icon-name property specifies the name of the themed icon to
166    /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
167    ///
168    /// Readable | Writable
169    ///
170    ///
171    /// #### `is-active`
172    ///  Readable
173    ///
174    ///
175    /// #### `is-maximized`
176    ///  Readable
177    ///
178    ///
179    /// #### `mnemonics-visible`
180    ///  Whether mnemonics are currently visible in this window.
181    ///
182    /// This property is maintained by GTK+ based on user input,
183    /// and should not be set by applications.
184    ///
185    /// Readable | Writable
186    ///
187    ///
188    /// #### `modal`
189    ///  Readable | Writable
190    ///
191    ///
192    /// #### `resizable`
193    ///  Readable | Writable
194    ///
195    ///
196    /// #### `resize-grip-visible`
197    ///  Whether a corner resize grip is currently shown.
198    ///
199    /// Readable
200    ///
201    ///
202    /// #### `role`
203    ///  Readable | Writable
204    ///
205    ///
206    /// #### `screen`
207    ///  Readable | Writable
208    ///
209    ///
210    /// #### `skip-pager-hint`
211    ///  Readable | Writable
212    ///
213    ///
214    /// #### `skip-taskbar-hint`
215    ///  Readable | Writable
216    ///
217    ///
218    /// #### `startup-id`
219    ///  The :startup-id is a write-only property for setting window's
220    /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
221    /// for more details.
222    ///
223    /// Writable
224    ///
225    ///
226    /// #### `title`
227    ///  Readable | Writable
228    ///
229    ///
230    /// #### `transient-for`
231    ///  The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
232    /// more details about transient windows.
233    ///
234    /// Readable | Writable | Construct
235    ///
236    ///
237    /// #### `type`
238    ///  Readable | Writable | Construct Only
239    ///
240    ///
241    /// #### `type-hint`
242    ///  Readable | Writable
243    ///
244    ///
245    /// #### `urgency-hint`
246    ///  Readable | Writable
247    ///
248    ///
249    /// #### `window-position`
250    ///  Readable | Writable
251    /// </details>
252    /// <details><summary><h4>Container</h4></summary>
253    ///
254    ///
255    /// #### `border-width`
256    ///  Readable | Writable
257    ///
258    ///
259    /// #### `child`
260    ///  Writable
261    ///
262    ///
263    /// #### `resize-mode`
264    ///  Readable | Writable
265    /// </details>
266    /// <details><summary><h4>Widget</h4></summary>
267    ///
268    ///
269    /// #### `app-paintable`
270    ///  Readable | Writable
271    ///
272    ///
273    /// #### `can-default`
274    ///  Readable | Writable
275    ///
276    ///
277    /// #### `can-focus`
278    ///  Readable | Writable
279    ///
280    ///
281    /// #### `composite-child`
282    ///  Readable
283    ///
284    ///
285    /// #### `double-buffered`
286    ///  Whether the widget is double buffered.
287    ///
288    /// Readable | Writable
289    ///
290    ///
291    /// #### `events`
292    ///  Readable | Writable
293    ///
294    ///
295    /// #### `expand`
296    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
297    ///
298    /// Readable | Writable
299    ///
300    ///
301    /// #### `focus-on-click`
302    ///  Whether the widget should grab focus when it is clicked with the mouse.
303    ///
304    /// This property is only relevant for widgets that can take focus.
305    ///
306    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
307    /// GtkComboBox) implemented this property individually.
308    ///
309    /// Readable | Writable
310    ///
311    ///
312    /// #### `halign`
313    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
314    ///
315    /// Readable | Writable
316    ///
317    ///
318    /// #### `has-default`
319    ///  Readable | Writable
320    ///
321    ///
322    /// #### `has-focus`
323    ///  Readable | Writable
324    ///
325    ///
326    /// #### `has-tooltip`
327    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
328    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
329    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
330    /// whether it will provide a tooltip or not.
331    ///
332    /// Note that setting this property to [`true`] for the first time will change
333    /// the event masks of the GdkWindows of this widget to include leave-notify
334    /// and motion-notify events. This cannot and will not be undone when the
335    /// property is set to [`false`] again.
336    ///
337    /// Readable | Writable
338    ///
339    ///
340    /// #### `height-request`
341    ///  Readable | Writable
342    ///
343    ///
344    /// #### `hexpand`
345    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
346    ///
347    /// Readable | Writable
348    ///
349    ///
350    /// #### `hexpand-set`
351    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
352    ///
353    /// Readable | Writable
354    ///
355    ///
356    /// #### `is-focus`
357    ///  Readable | Writable
358    ///
359    ///
360    /// #### `margin`
361    ///  Sets all four sides' margin at once. If read, returns max
362    /// margin on any side.
363    ///
364    /// Readable | Writable
365    ///
366    ///
367    /// #### `margin-bottom`
368    ///  Margin on bottom side of widget.
369    ///
370    /// This property adds margin outside of the widget's normal size
371    /// request, the margin will be added in addition to the size from
372    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
373    ///
374    /// Readable | Writable
375    ///
376    ///
377    /// #### `margin-end`
378    ///  Margin on end of widget, horizontally. This property supports
379    /// left-to-right and right-to-left text directions.
380    ///
381    /// This property adds margin outside of the widget's normal size
382    /// request, the margin will be added in addition to the size from
383    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
384    ///
385    /// Readable | Writable
386    ///
387    ///
388    /// #### `margin-left`
389    ///  Margin on left side of widget.
390    ///
391    /// This property adds margin outside of the widget's normal size
392    /// request, the margin will be added in addition to the size from
393    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
394    ///
395    /// Readable | Writable
396    ///
397    ///
398    /// #### `margin-right`
399    ///  Margin on right side of widget.
400    ///
401    /// This property adds margin outside of the widget's normal size
402    /// request, the margin will be added in addition to the size from
403    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
404    ///
405    /// Readable | Writable
406    ///
407    ///
408    /// #### `margin-start`
409    ///  Margin on start of widget, horizontally. This property supports
410    /// left-to-right and right-to-left text directions.
411    ///
412    /// This property adds margin outside of the widget's normal size
413    /// request, the margin will be added in addition to the size from
414    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
415    ///
416    /// Readable | Writable
417    ///
418    ///
419    /// #### `margin-top`
420    ///  Margin on top side of widget.
421    ///
422    /// This property adds margin outside of the widget's normal size
423    /// request, the margin will be added in addition to the size from
424    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
425    ///
426    /// Readable | Writable
427    ///
428    ///
429    /// #### `name`
430    ///  Readable | Writable
431    ///
432    ///
433    /// #### `no-show-all`
434    ///  Readable | Writable
435    ///
436    ///
437    /// #### `opacity`
438    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
439    /// more details about window opacity.
440    ///
441    /// Before 3.8 this was only available in GtkWindow
442    ///
443    /// Readable | Writable
444    ///
445    ///
446    /// #### `parent`
447    ///  Readable | Writable
448    ///
449    ///
450    /// #### `receives-default`
451    ///  Readable | Writable
452    ///
453    ///
454    /// #### `scale-factor`
455    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
456    /// more details about widget scaling.
457    ///
458    /// Readable
459    ///
460    ///
461    /// #### `sensitive`
462    ///  Readable | Writable
463    ///
464    ///
465    /// #### `style`
466    ///  The style of the widget, which contains information about how it will look (colors, etc).
467    ///
468    /// Readable | Writable
469    ///
470    ///
471    /// #### `tooltip-markup`
472    ///  Sets the text of tooltip to be the given string, which is marked up
473    /// with the [Pango text markup language][PangoMarkupFormat].
474    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
475    ///
476    /// This is a convenience property which will take care of getting the
477    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
478    /// will automatically be set to [`true`] and there will be taken care of
479    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
480    ///
481    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
482    /// are set, the last one wins.
483    ///
484    /// Readable | Writable
485    ///
486    ///
487    /// #### `tooltip-text`
488    ///  Sets the text of tooltip to be the given string.
489    ///
490    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
491    ///
492    /// This is a convenience property which will take care of getting the
493    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
494    /// will automatically be set to [`true`] and there will be taken care of
495    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
496    ///
497    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
498    /// are set, the last one wins.
499    ///
500    /// Readable | Writable
501    ///
502    ///
503    /// #### `valign`
504    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
505    ///
506    /// Readable | Writable
507    ///
508    ///
509    /// #### `vexpand`
510    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
511    ///
512    /// Readable | Writable
513    ///
514    ///
515    /// #### `vexpand-set`
516    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
517    ///
518    /// Readable | Writable
519    ///
520    ///
521    /// #### `visible`
522    ///  Readable | Writable
523    ///
524    ///
525    /// #### `width-request`
526    ///  Readable | Writable
527    ///
528    ///
529    /// #### `window`
530    ///  The widget's window if it is realized, [`None`] otherwise.
531    ///
532    /// Readable
533    /// </details>
534    ///
535    /// # Implements
536    ///
537    /// [`ApplicationWindowExt`][trait@crate::prelude::ApplicationWindowExt], [`GtkWindowExt`][trait@crate::prelude::GtkWindowExt], [`BinExt`][trait@crate::prelude::BinExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`trait@gio::prelude::ActionGroupExt`], [`trait@gio::prelude::ActionMapExt`], [`GtkWindowExtManual`][trait@crate::prelude::GtkWindowExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
538    #[doc(alias = "GtkApplicationWindow")]
539    pub struct ApplicationWindow(Object<ffi::GtkApplicationWindow, ffi::GtkApplicationWindowClass>) @extends Window, Bin, Container, Widget, @implements Buildable, gio::ActionGroup, gio::ActionMap;
540
541    match fn {
542        type_ => || ffi::gtk_application_window_get_type(),
543    }
544}
545
546impl ApplicationWindow {
547    pub const NONE: Option<&'static ApplicationWindow> = None;
548
549    // rustdoc-stripper-ignore-next
550    /// Creates a new builder-pattern struct instance to construct [`ApplicationWindow`] objects.
551    ///
552    /// This method returns an instance of [`ApplicationWindowBuilder`](crate::builders::ApplicationWindowBuilder) which can be used to create [`ApplicationWindow`] objects.
553    pub fn builder() -> ApplicationWindowBuilder {
554        ApplicationWindowBuilder::new()
555    }
556}
557
558// rustdoc-stripper-ignore-next
559/// A [builder-pattern] type to construct [`ApplicationWindow`] objects.
560///
561/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
562#[must_use = "The builder must be built to be used"]
563pub struct ApplicationWindowBuilder {
564    builder: glib::object::ObjectBuilder<'static, ApplicationWindow>,
565}
566
567impl ApplicationWindowBuilder {
568    fn new() -> Self {
569        Self {
570            builder: glib::object::Object::builder(),
571        }
572    }
573
574    /// If this property is [`true`], the window will display a menubar
575    /// that includes the app menu and menubar, unless these are
576    /// shown by the desktop shell. See [`GtkApplicationExt::set_app_menu()`][crate::prelude::GtkApplicationExt::set_app_menu()]
577    /// and [`GtkApplicationExt::set_menubar()`][crate::prelude::GtkApplicationExt::set_menubar()].
578    ///
579    /// If [`false`], the window will not display a menubar, regardless
580    /// of whether the desktop shell is showing the menus or not.
581    pub fn show_menubar(self, show_menubar: bool) -> Self {
582        Self {
583            builder: self.builder.property("show-menubar", show_menubar),
584        }
585    }
586
587    /// Whether the window should receive the input focus.
588    pub fn accept_focus(self, accept_focus: bool) -> Self {
589        Self {
590            builder: self.builder.property("accept-focus", accept_focus),
591        }
592    }
593
594    /// The [`Application`][crate::Application] associated with the window.
595    ///
596    /// The application will be kept alive for at least as long as it
597    /// has any windows associated with it (see [`ApplicationExtManual::hold()`][crate::gio::prelude::ApplicationExtManual::hold()]
598    /// for a way to keep it alive without windows).
599    ///
600    /// Normally, the connection between the application and the window
601    /// will remain until the window is destroyed, but you can explicitly
602    /// remove it by setting the :application property to [`None`].
603    pub fn application(self, application: &impl IsA<Application>) -> Self {
604        Self {
605            builder: self
606                .builder
607                .property("application", application.clone().upcast()),
608        }
609    }
610
611    /// The widget to which this window is attached.
612    /// See [`GtkWindowExt::set_attached_to()`][crate::prelude::GtkWindowExt::set_attached_to()].
613    ///
614    /// Examples of places where specifying this relation is useful are
615    /// for instance a [`Menu`][crate::Menu] created by a [`ComboBox`][crate::ComboBox], a completion
616    /// popup window created by [`Entry`][crate::Entry] or a typeahead search entry
617    /// created by [`TreeView`][crate::TreeView].
618    pub fn attached_to(self, attached_to: &impl IsA<Widget>) -> Self {
619        Self {
620            builder: self
621                .builder
622                .property("attached-to", attached_to.clone().upcast()),
623        }
624    }
625
626    /// Whether the window should be decorated by the window manager.
627    pub fn decorated(self, decorated: bool) -> Self {
628        Self {
629            builder: self.builder.property("decorated", decorated),
630        }
631    }
632
633    pub fn default_height(self, default_height: i32) -> Self {
634        Self {
635            builder: self.builder.property("default-height", default_height),
636        }
637    }
638
639    pub fn default_width(self, default_width: i32) -> Self {
640        Self {
641            builder: self.builder.property("default-width", default_width),
642        }
643    }
644
645    /// Whether the window frame should have a close button.
646    pub fn deletable(self, deletable: bool) -> Self {
647        Self {
648            builder: self.builder.property("deletable", deletable),
649        }
650    }
651
652    pub fn destroy_with_parent(self, destroy_with_parent: bool) -> Self {
653        Self {
654            builder: self
655                .builder
656                .property("destroy-with-parent", destroy_with_parent),
657        }
658    }
659
660    /// Whether the window should receive the input focus when mapped.
661    pub fn focus_on_map(self, focus_on_map: bool) -> Self {
662        Self {
663            builder: self.builder.property("focus-on-map", focus_on_map),
664        }
665    }
666
667    /// Whether 'focus rectangles' are currently visible in this window.
668    ///
669    /// This property is maintained by GTK+ based on user input
670    /// and should not be set by applications.
671    pub fn focus_visible(self, focus_visible: bool) -> Self {
672        Self {
673            builder: self.builder.property("focus-visible", focus_visible),
674        }
675    }
676
677    /// The window gravity of the window. See [`GtkWindowExt::move_()`][crate::prelude::GtkWindowExt::move_()] and [`gdk::Gravity`][crate::gdk::Gravity] for
678    /// more details about window gravity.
679    pub fn gravity(self, gravity: gdk::Gravity) -> Self {
680        Self {
681            builder: self.builder.property("gravity", gravity),
682        }
683    }
684
685    /// Whether the titlebar should be hidden during maximization.
686    pub fn hide_titlebar_when_maximized(self, hide_titlebar_when_maximized: bool) -> Self {
687        Self {
688            builder: self
689                .builder
690                .property("hide-titlebar-when-maximized", hide_titlebar_when_maximized),
691        }
692    }
693
694    pub fn icon(self, icon: &gdk_pixbuf::Pixbuf) -> Self {
695        Self {
696            builder: self.builder.property("icon", icon.clone()),
697        }
698    }
699
700    /// The :icon-name property specifies the name of the themed icon to
701    /// use as the window icon. See [`IconTheme`][crate::IconTheme] for more details.
702    pub fn icon_name(self, icon_name: impl Into<glib::GString>) -> Self {
703        Self {
704            builder: self.builder.property("icon-name", icon_name.into()),
705        }
706    }
707
708    /// Whether mnemonics are currently visible in this window.
709    ///
710    /// This property is maintained by GTK+ based on user input,
711    /// and should not be set by applications.
712    pub fn mnemonics_visible(self, mnemonics_visible: bool) -> Self {
713        Self {
714            builder: self
715                .builder
716                .property("mnemonics-visible", mnemonics_visible),
717        }
718    }
719
720    pub fn modal(self, modal: bool) -> Self {
721        Self {
722            builder: self.builder.property("modal", modal),
723        }
724    }
725
726    pub fn resizable(self, resizable: bool) -> Self {
727        Self {
728            builder: self.builder.property("resizable", resizable),
729        }
730    }
731
732    pub fn role(self, role: impl Into<glib::GString>) -> Self {
733        Self {
734            builder: self.builder.property("role", role.into()),
735        }
736    }
737
738    pub fn screen(self, screen: &gdk::Screen) -> Self {
739        Self {
740            builder: self.builder.property("screen", screen.clone()),
741        }
742    }
743
744    pub fn skip_pager_hint(self, skip_pager_hint: bool) -> Self {
745        Self {
746            builder: self.builder.property("skip-pager-hint", skip_pager_hint),
747        }
748    }
749
750    pub fn skip_taskbar_hint(self, skip_taskbar_hint: bool) -> Self {
751        Self {
752            builder: self
753                .builder
754                .property("skip-taskbar-hint", skip_taskbar_hint),
755        }
756    }
757
758    /// The :startup-id is a write-only property for setting window's
759    /// startup notification identifier. See [`GtkWindowExt::set_startup_id()`][crate::prelude::GtkWindowExt::set_startup_id()]
760    /// for more details.
761    pub fn startup_id(self, startup_id: impl Into<glib::GString>) -> Self {
762        Self {
763            builder: self.builder.property("startup-id", startup_id.into()),
764        }
765    }
766
767    pub fn title(self, title: impl Into<glib::GString>) -> Self {
768        Self {
769            builder: self.builder.property("title", title.into()),
770        }
771    }
772
773    /// The transient parent of the window. See [`GtkWindowExt::set_transient_for()`][crate::prelude::GtkWindowExt::set_transient_for()] for
774    /// more details about transient windows.
775    pub fn transient_for(self, transient_for: &impl IsA<Window>) -> Self {
776        Self {
777            builder: self
778                .builder
779                .property("transient-for", transient_for.clone().upcast()),
780        }
781    }
782
783    pub fn type_(self, type_: WindowType) -> Self {
784        Self {
785            builder: self.builder.property("type", type_),
786        }
787    }
788
789    pub fn type_hint(self, type_hint: gdk::WindowTypeHint) -> Self {
790        Self {
791            builder: self.builder.property("type-hint", type_hint),
792        }
793    }
794
795    pub fn urgency_hint(self, urgency_hint: bool) -> Self {
796        Self {
797            builder: self.builder.property("urgency-hint", urgency_hint),
798        }
799    }
800
801    pub fn window_position(self, window_position: WindowPosition) -> Self {
802        Self {
803            builder: self.builder.property("window-position", window_position),
804        }
805    }
806
807    pub fn border_width(self, border_width: u32) -> Self {
808        Self {
809            builder: self.builder.property("border-width", border_width),
810        }
811    }
812
813    pub fn child(self, child: &impl IsA<Widget>) -> Self {
814        Self {
815            builder: self.builder.property("child", child.clone().upcast()),
816        }
817    }
818
819    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
820        Self {
821            builder: self.builder.property("resize-mode", resize_mode),
822        }
823    }
824
825    pub fn app_paintable(self, app_paintable: bool) -> Self {
826        Self {
827            builder: self.builder.property("app-paintable", app_paintable),
828        }
829    }
830
831    pub fn can_default(self, can_default: bool) -> Self {
832        Self {
833            builder: self.builder.property("can-default", can_default),
834        }
835    }
836
837    pub fn can_focus(self, can_focus: bool) -> Self {
838        Self {
839            builder: self.builder.property("can-focus", can_focus),
840        }
841    }
842
843    pub fn events(self, events: gdk::EventMask) -> Self {
844        Self {
845            builder: self.builder.property("events", events),
846        }
847    }
848
849    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
850    pub fn expand(self, expand: bool) -> Self {
851        Self {
852            builder: self.builder.property("expand", expand),
853        }
854    }
855
856    /// Whether the widget should grab focus when it is clicked with the mouse.
857    ///
858    /// This property is only relevant for widgets that can take focus.
859    ///
860    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
861    /// GtkComboBox) implemented this property individually.
862    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
863        Self {
864            builder: self.builder.property("focus-on-click", focus_on_click),
865        }
866    }
867
868    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
869    pub fn halign(self, halign: Align) -> Self {
870        Self {
871            builder: self.builder.property("halign", halign),
872        }
873    }
874
875    pub fn has_default(self, has_default: bool) -> Self {
876        Self {
877            builder: self.builder.property("has-default", has_default),
878        }
879    }
880
881    pub fn has_focus(self, has_focus: bool) -> Self {
882        Self {
883            builder: self.builder.property("has-focus", has_focus),
884        }
885    }
886
887    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
888    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
889    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
890    /// whether it will provide a tooltip or not.
891    ///
892    /// Note that setting this property to [`true`] for the first time will change
893    /// the event masks of the GdkWindows of this widget to include leave-notify
894    /// and motion-notify events. This cannot and will not be undone when the
895    /// property is set to [`false`] again.
896    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
897        Self {
898            builder: self.builder.property("has-tooltip", has_tooltip),
899        }
900    }
901
902    pub fn height_request(self, height_request: i32) -> Self {
903        Self {
904            builder: self.builder.property("height-request", height_request),
905        }
906    }
907
908    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
909    pub fn hexpand(self, hexpand: bool) -> Self {
910        Self {
911            builder: self.builder.property("hexpand", hexpand),
912        }
913    }
914
915    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
916    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
917        Self {
918            builder: self.builder.property("hexpand-set", hexpand_set),
919        }
920    }
921
922    pub fn is_focus(self, is_focus: bool) -> Self {
923        Self {
924            builder: self.builder.property("is-focus", is_focus),
925        }
926    }
927
928    /// Sets all four sides' margin at once. If read, returns max
929    /// margin on any side.
930    pub fn margin(self, margin: i32) -> Self {
931        Self {
932            builder: self.builder.property("margin", margin),
933        }
934    }
935
936    /// Margin on bottom side of widget.
937    ///
938    /// This property adds margin outside of the widget's normal size
939    /// request, the margin will be added in addition to the size from
940    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
941    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
942        Self {
943            builder: self.builder.property("margin-bottom", margin_bottom),
944        }
945    }
946
947    /// Margin on end of widget, horizontally. This property supports
948    /// left-to-right and right-to-left text directions.
949    ///
950    /// This property adds margin outside of the widget's normal size
951    /// request, the margin will be added in addition to the size from
952    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
953    pub fn margin_end(self, margin_end: i32) -> Self {
954        Self {
955            builder: self.builder.property("margin-end", margin_end),
956        }
957    }
958
959    /// Margin on start of widget, horizontally. This property supports
960    /// left-to-right and right-to-left text directions.
961    ///
962    /// This property adds margin outside of the widget's normal size
963    /// request, the margin will be added in addition to the size from
964    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
965    pub fn margin_start(self, margin_start: i32) -> Self {
966        Self {
967            builder: self.builder.property("margin-start", margin_start),
968        }
969    }
970
971    /// Margin on top side of widget.
972    ///
973    /// This property adds margin outside of the widget's normal size
974    /// request, the margin will be added in addition to the size from
975    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
976    pub fn margin_top(self, margin_top: i32) -> Self {
977        Self {
978            builder: self.builder.property("margin-top", margin_top),
979        }
980    }
981
982    pub fn name(self, name: impl Into<glib::GString>) -> Self {
983        Self {
984            builder: self.builder.property("name", name.into()),
985        }
986    }
987
988    pub fn no_show_all(self, no_show_all: bool) -> Self {
989        Self {
990            builder: self.builder.property("no-show-all", no_show_all),
991        }
992    }
993
994    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
995    /// more details about window opacity.
996    ///
997    /// Before 3.8 this was only available in GtkWindow
998    pub fn opacity(self, opacity: f64) -> Self {
999        Self {
1000            builder: self.builder.property("opacity", opacity),
1001        }
1002    }
1003
1004    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1005        Self {
1006            builder: self.builder.property("parent", parent.clone().upcast()),
1007        }
1008    }
1009
1010    pub fn receives_default(self, receives_default: bool) -> Self {
1011        Self {
1012            builder: self.builder.property("receives-default", receives_default),
1013        }
1014    }
1015
1016    pub fn sensitive(self, sensitive: bool) -> Self {
1017        Self {
1018            builder: self.builder.property("sensitive", sensitive),
1019        }
1020    }
1021
1022    /// Sets the text of tooltip to be the given string, which is marked up
1023    /// with the [Pango text markup language][PangoMarkupFormat].
1024    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1025    ///
1026    /// This is a convenience property which will take care of getting the
1027    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1028    /// will automatically be set to [`true`] and there will be taken care of
1029    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1030    ///
1031    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1032    /// are set, the last one wins.
1033    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1034        Self {
1035            builder: self
1036                .builder
1037                .property("tooltip-markup", tooltip_markup.into()),
1038        }
1039    }
1040
1041    /// Sets the text of tooltip to be the given string.
1042    ///
1043    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1044    ///
1045    /// This is a convenience property which will take care of getting the
1046    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1047    /// will automatically be set to [`true`] and there will be taken care of
1048    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1049    ///
1050    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1051    /// are set, the last one wins.
1052    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1053        Self {
1054            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1055        }
1056    }
1057
1058    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1059    pub fn valign(self, valign: Align) -> Self {
1060        Self {
1061            builder: self.builder.property("valign", valign),
1062        }
1063    }
1064
1065    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1066    pub fn vexpand(self, vexpand: bool) -> Self {
1067        Self {
1068            builder: self.builder.property("vexpand", vexpand),
1069        }
1070    }
1071
1072    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1073    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1074        Self {
1075            builder: self.builder.property("vexpand-set", vexpand_set),
1076        }
1077    }
1078
1079    pub fn visible(self, visible: bool) -> Self {
1080        Self {
1081            builder: self.builder.property("visible", visible),
1082        }
1083    }
1084
1085    pub fn width_request(self, width_request: i32) -> Self {
1086        Self {
1087            builder: self.builder.property("width-request", width_request),
1088        }
1089    }
1090
1091    // rustdoc-stripper-ignore-next
1092    /// Build the [`ApplicationWindow`].
1093    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1094    pub fn build(self) -> ApplicationWindow {
1095        assert_initialized_main_thread!();
1096        self.builder.build()
1097    }
1098}
1099
1100/// Trait containing all [`struct@ApplicationWindow`] methods.
1101///
1102/// # Implementors
1103///
1104/// [`ApplicationWindow`][struct@crate::ApplicationWindow]
1105pub trait ApplicationWindowExt: IsA<ApplicationWindow> + 'static {
1106    /// Gets the [`ShortcutsWindow`][crate::ShortcutsWindow] that has been set up with
1107    /// a prior call to [`set_help_overlay()`][Self::set_help_overlay()].
1108    ///
1109    /// # Returns
1110    ///
1111    /// the help overlay associated with `self`, or [`None`]
1112    #[doc(alias = "gtk_application_window_get_help_overlay")]
1113    #[doc(alias = "get_help_overlay")]
1114    fn help_overlay(&self) -> Option<ShortcutsWindow> {
1115        unsafe {
1116            from_glib_none(ffi::gtk_application_window_get_help_overlay(
1117                self.as_ref().to_glib_none().0,
1118            ))
1119        }
1120    }
1121
1122    /// Returns the unique ID of the window. If the window has not yet been added to
1123    /// a [`Application`][crate::Application], returns `0`.
1124    ///
1125    /// # Returns
1126    ///
1127    /// the unique ID for `self`, or `0` if the window
1128    ///  has not yet been added to a [`Application`][crate::Application]
1129    #[doc(alias = "gtk_application_window_get_id")]
1130    #[doc(alias = "get_id")]
1131    fn id(&self) -> u32 {
1132        unsafe { ffi::gtk_application_window_get_id(self.as_ref().to_glib_none().0) }
1133    }
1134
1135    /// Returns whether the window will display a menubar for the app menu
1136    /// and menubar as needed.
1137    ///
1138    /// # Returns
1139    ///
1140    /// [`true`] if `self` will display a menubar when needed
1141    #[doc(alias = "gtk_application_window_get_show_menubar")]
1142    #[doc(alias = "get_show_menubar")]
1143    #[doc(alias = "show-menubar")]
1144    fn shows_menubar(&self) -> bool {
1145        unsafe {
1146            from_glib(ffi::gtk_application_window_get_show_menubar(
1147                self.as_ref().to_glib_none().0,
1148            ))
1149        }
1150    }
1151
1152    /// Associates a shortcuts window with the application window, and
1153    /// sets up an action with the name win.show-help-overlay to present
1154    /// it.
1155    ///
1156    /// `self` takes resposibility for destroying `help_overlay`.
1157    /// ## `help_overlay`
1158    /// a [`ShortcutsWindow`][crate::ShortcutsWindow]
1159    #[doc(alias = "gtk_application_window_set_help_overlay")]
1160    fn set_help_overlay(&self, help_overlay: Option<&impl IsA<ShortcutsWindow>>) {
1161        unsafe {
1162            ffi::gtk_application_window_set_help_overlay(
1163                self.as_ref().to_glib_none().0,
1164                help_overlay.map(|p| p.as_ref()).to_glib_none().0,
1165            );
1166        }
1167    }
1168
1169    /// Sets whether the window will display a menubar for the app menu
1170    /// and menubar as needed.
1171    /// ## `show_menubar`
1172    /// whether to show a menubar when needed
1173    #[doc(alias = "gtk_application_window_set_show_menubar")]
1174    #[doc(alias = "show-menubar")]
1175    fn set_show_menubar(&self, show_menubar: bool) {
1176        unsafe {
1177            ffi::gtk_application_window_set_show_menubar(
1178                self.as_ref().to_glib_none().0,
1179                show_menubar.into_glib(),
1180            );
1181        }
1182    }
1183
1184    #[doc(alias = "show-menubar")]
1185    fn connect_show_menubar_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1186        unsafe extern "C" fn notify_show_menubar_trampoline<
1187            P: IsA<ApplicationWindow>,
1188            F: Fn(&P) + 'static,
1189        >(
1190            this: *mut ffi::GtkApplicationWindow,
1191            _param_spec: glib::ffi::gpointer,
1192            f: glib::ffi::gpointer,
1193        ) {
1194            unsafe {
1195                let f: &F = &*(f as *const F);
1196                f(ApplicationWindow::from_glib_borrow(this).unsafe_cast_ref())
1197            }
1198        }
1199        unsafe {
1200            let f: Box_<F> = Box_::new(f);
1201            connect_raw(
1202                self.as_ptr() as *mut _,
1203                c"notify::show-menubar".as_ptr(),
1204                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1205                    notify_show_menubar_trampoline::<Self, F> as *const (),
1206                )),
1207                Box_::into_raw(f),
1208            )
1209        }
1210    }
1211}
1212
1213impl<O: IsA<ApplicationWindow>> ApplicationWindowExt for O {}