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