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