gtk4/auto/root.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::{ffi, Accessible, Buildable, ConstraintTarget, Native, Widget};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// [`Root`][crate::Root] is the interface implemented by all widgets that can act as a toplevel
10 /// widget.
11 ///
12 /// The root widget takes care of providing the connection to the windowing system
13 /// and manages layout, drawing and event delivery for its widget hierarchy.
14 ///
15 /// The obvious example of a [`Root`][crate::Root] is [`Window`][crate::Window].
16 ///
17 /// To get the display to which a [`Root`][crate::Root] belongs, use
18 /// [`RootExt::display()`][crate::prelude::RootExt::display()].
19 ///
20 /// [`Root`][crate::Root] also maintains the location of keyboard focus inside its widget
21 /// hierarchy, with [`RootExt::set_focus()`][crate::prelude::RootExt::set_focus()] and [`RootExt::focus()`][crate::prelude::RootExt::focus()].
22 ///
23 /// # Implements
24 ///
25 /// [`RootExt`][trait@crate::prelude::RootExt], [`NativeExt`][trait@crate::prelude::NativeExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`AccessibleExt`][trait@crate::prelude::AccessibleExt], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ConstraintTargetExt`][trait@crate::prelude::ConstraintTargetExt], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`AccessibleExtManual`][trait@crate::prelude::AccessibleExtManual]
26 #[doc(alias = "GtkRoot")]
27 pub struct Root(Interface<ffi::GtkRoot, ffi::GtkRootInterface>) @requires Native, Widget, Accessible, Buildable, ConstraintTarget;
28
29 match fn {
30 type_ => || ffi::gtk_root_get_type(),
31 }
32}
33
34impl Root {
35 pub const NONE: Option<&'static Root> = None;
36}
37
38mod sealed {
39 pub trait Sealed {}
40 impl<T: super::IsA<super::Root>> Sealed for T {}
41}
42
43/// Trait containing all [`struct@Root`] methods.
44///
45/// # Implementors
46///
47/// [`AboutDialog`][struct@crate::AboutDialog], [`AppChooserDialog`][struct@crate::AppChooserDialog], [`ApplicationWindow`][struct@crate::ApplicationWindow], [`Assistant`][struct@crate::Assistant], [`ColorChooserDialog`][struct@crate::ColorChooserDialog], [`Dialog`][struct@crate::Dialog], [`DragIcon`][struct@crate::DragIcon], [`FileChooserDialog`][struct@crate::FileChooserDialog], [`FontChooserDialog`][struct@crate::FontChooserDialog], [`MessageDialog`][struct@crate::MessageDialog], [`PageSetupUnixDialog`][struct@crate::PageSetupUnixDialog], [`PrintUnixDialog`][struct@crate::PrintUnixDialog], [`Root`][struct@crate::Root], [`ShortcutsWindow`][struct@crate::ShortcutsWindow], [`Window`][struct@crate::Window]
48pub trait RootExt: IsA<Root> + sealed::Sealed + 'static {
49 /// Returns the display that this [`Root`][crate::Root] is on.
50 ///
51 /// # Returns
52 ///
53 /// the display of @root
54 #[doc(alias = "gtk_root_get_display")]
55 #[doc(alias = "get_display")]
56 fn display(&self) -> gdk::Display {
57 unsafe { from_glib_none(ffi::gtk_root_get_display(self.as_ref().to_glib_none().0)) }
58 }
59
60 /// Retrieves the current focused widget within the root.
61 ///
62 /// Note that this is the widget that would have the focus
63 /// if the root is active; if the root is not focused then
64 /// `gtk_widget_has_focus (widget)` will be [`false`] for the
65 /// widget.
66 ///
67 /// # Returns
68 ///
69 /// the currently focused widget
70 #[doc(alias = "gtk_root_get_focus")]
71 #[doc(alias = "get_focus")]
72 fn focus(&self) -> Option<Widget> {
73 unsafe { from_glib_none(ffi::gtk_root_get_focus(self.as_ref().to_glib_none().0)) }
74 }
75
76 /// If @focus is not the current focus widget, and is focusable, sets
77 /// it as the focus widget for the root.
78 ///
79 /// If @focus is [`None`], unsets the focus widget for the root.
80 ///
81 /// To set the focus to a particular widget in the root, it is usually
82 /// more convenient to use [`WidgetExt::grab_focus()`][crate::prelude::WidgetExt::grab_focus()] instead of
83 /// this function.
84 /// ## `focus`
85 /// widget to be the new focus widget, or [`None`]
86 /// to unset the focus widget
87 #[doc(alias = "gtk_root_set_focus")]
88 fn set_focus(&self, focus: Option<&impl IsA<Widget>>) {
89 unsafe {
90 ffi::gtk_root_set_focus(
91 self.as_ref().to_glib_none().0,
92 focus.map(|p| p.as_ref()).to_glib_none().0,
93 );
94 }
95 }
96}
97
98impl<O: IsA<Root>> RootExt for O {}