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