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 /// An interface for widgets that can act as the root of a widget hierarchy.
10 ///
11 /// The root widget takes care of providing the connection to the windowing
12 /// system and manages layout, drawing and event delivery for its widget
13 /// 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
38/// Trait containing all [`struct@Root`] methods.
39///
40/// # Implementors
41///
42/// [`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]
43pub trait RootExt: IsA<Root> + 'static {
44 /// Returns the display that this [`Root`][crate::Root] is on.
45 ///
46 /// # Returns
47 ///
48 /// the display of @root
49 #[doc(alias = "gtk_root_get_display")]
50 #[doc(alias = "get_display")]
51 fn display(&self) -> gdk::Display {
52 unsafe { from_glib_none(ffi::gtk_root_get_display(self.as_ref().to_glib_none().0)) }
53 }
54
55 /// Retrieves the current focused widget within the root.
56 ///
57 /// Note that this is the widget that would have the focus
58 /// if the root is active; if the root is not focused then
59 /// `gtk_widget_has_focus (widget)` will be [`false`] for the
60 /// widget.
61 ///
62 /// # Returns
63 ///
64 /// the currently focused widget
65 #[doc(alias = "gtk_root_get_focus")]
66 #[doc(alias = "get_focus")]
67 fn focus(&self) -> Option<Widget> {
68 unsafe { from_glib_none(ffi::gtk_root_get_focus(self.as_ref().to_glib_none().0)) }
69 }
70
71 /// If @focus is not the current focus widget, and is focusable, sets
72 /// it as the focus widget for the root.
73 ///
74 /// If @focus is [`None`], unsets the focus widget for the root.
75 ///
76 /// To set the focus to a particular widget in the root, it is usually
77 /// more convenient to use [`WidgetExt::grab_focus()`][crate::prelude::WidgetExt::grab_focus()] instead of
78 /// this function.
79 /// ## `focus`
80 /// widget to be the new focus widget, or [`None`]
81 /// to unset the focus widget
82 #[doc(alias = "gtk_root_set_focus")]
83 fn set_focus(&self, focus: Option<&impl IsA<Widget>>) {
84 unsafe {
85 ffi::gtk_root_set_focus(
86 self.as_ref().to_glib_none().0,
87 focus.map(|p| p.as_ref()).to_glib_none().0,
88 );
89 }
90 }
91}
92
93impl<O: IsA<Root>> RootExt for O {}