atk/auto/action.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;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// The ATK interface provided by UI components
10 /// which the user can activate/interact with.
11 ///
12 /// [`Action`][crate::Action] should be implemented by instances of [`Object`][crate::Object] classes
13 /// with which the user can interact directly, i.e. buttons,
14 /// checkboxes, scrollbars, e.g. components which are not "passive"
15 /// providers of UI information.
16 ///
17 /// Exceptions: when the user interaction is already covered by another
18 /// appropriate interface such as [`EditableText`][crate::EditableText] (insert/delete text,
19 /// etc.) or [`Value`][crate::Value] (set value) then these actions should not be
20 /// exposed by [`Action`][crate::Action] as well.
21 ///
22 /// Though most UI interactions on components should be invocable via
23 /// keyboard as well as mouse, there will generally be a close mapping
24 /// between "mouse actions" that are possible on a component and the
25 /// AtkActions. Where mouse and keyboard actions are redundant in
26 /// effect, [`Action`][crate::Action] should expose only one action rather than
27 /// exposing redundant actions if possible. By convention we have been
28 /// using "mouse centric" terminology for [`Action`][crate::Action] names.
29 ///
30 /// # Implements
31 ///
32 /// [`AtkActionExt`][trait@crate::prelude::AtkActionExt]
33 #[doc(alias = "AtkAction")]
34 pub struct Action(Interface<ffi::AtkAction, ffi::AtkActionIface>);
35
36 match fn {
37 type_ => || ffi::atk_action_get_type(),
38 }
39}
40
41impl Action {
42 pub const NONE: Option<&'static Action> = None;
43}
44
45/// Trait containing all [`struct@Action`] methods.
46///
47/// # Implementors
48///
49/// [`Action`][struct@crate::Action], [`Hyperlink`][struct@crate::Hyperlink], [`NoOpObject`][struct@crate::NoOpObject]
50pub trait AtkActionExt: IsA<Action> + 'static {
51 /// Perform the specified action on the object.
52 /// ## `i`
53 /// the action index corresponding to the action to be performed
54 ///
55 /// # Returns
56 ///
57 /// [`true`] if success, [`false`] otherwise
58 #[doc(alias = "atk_action_do_action")]
59 fn do_action(&self, i: i32) -> bool {
60 unsafe { from_glib(ffi::atk_action_do_action(self.as_ref().to_glib_none().0, i)) }
61 }
62
63 /// Returns a description of the specified action of the object.
64 /// ## `i`
65 /// the action index corresponding to the action to be performed
66 ///
67 /// # Returns
68 ///
69 /// a description string, or [`None`] if `self` does
70 /// not implement this interface.
71 #[doc(alias = "atk_action_get_description")]
72 #[doc(alias = "get_description")]
73 fn description(&self, i: i32) -> Option<glib::GString> {
74 unsafe {
75 from_glib_none(ffi::atk_action_get_description(
76 self.as_ref().to_glib_none().0,
77 i,
78 ))
79 }
80 }
81
82 /// Gets the keybinding which can be used to activate this action, if one
83 /// exists. The string returned should contain localized, human-readable,
84 /// key sequences as they would appear when displayed on screen. It must
85 /// be in the format "mnemonic;sequence;shortcut".
86 ///
87 /// - The mnemonic key activates the object if it is presently enabled onscreen.
88 /// This typically corresponds to the underlined letter within the widget.
89 /// Example: "n" in a traditional "New..." menu item or the "a" in "Apply" for
90 /// a button.
91 /// - The sequence is the full list of keys which invoke the action even if the
92 /// relevant element is not currently shown on screen. For instance, for a menu
93 /// item the sequence is the keybindings used to open the parent menus before
94 /// invoking. The sequence string is colon-delimited. Example: "Alt+F:N" in a
95 /// traditional "New..." menu item.
96 /// - The shortcut, if it exists, will invoke the same action without showing
97 /// the component or its enclosing menus or dialogs. Example: "Ctrl+N" in a
98 /// traditional "New..." menu item.
99 ///
100 /// Example: For a traditional "New..." menu item, the expected return value
101 /// would be: "N;Alt+F:N;Ctrl+N" for the English locale and "N;Alt+D:N;Strg+N"
102 /// for the German locale. If, hypothetically, this menu item lacked a mnemonic,
103 /// it would be represented by ";;Ctrl+N" and ";;Strg+N" respectively.
104 /// ## `i`
105 /// the action index corresponding to the action to be performed
106 ///
107 /// # Returns
108 ///
109 /// the keybinding which can be used to activate
110 /// this action, or [`None`] if there is no keybinding for this action.
111 #[doc(alias = "atk_action_get_keybinding")]
112 #[doc(alias = "get_keybinding")]
113 fn keybinding(&self, i: i32) -> Option<glib::GString> {
114 unsafe {
115 from_glib_none(ffi::atk_action_get_keybinding(
116 self.as_ref().to_glib_none().0,
117 i,
118 ))
119 }
120 }
121
122 /// Returns the localized name of the specified action of the object.
123 /// ## `i`
124 /// the action index corresponding to the action to be performed
125 ///
126 /// # Returns
127 ///
128 /// a name string, or [`None`] if `self` does not
129 /// implement this interface.
130 #[doc(alias = "atk_action_get_localized_name")]
131 #[doc(alias = "get_localized_name")]
132 fn localized_name(&self, i: i32) -> Option<glib::GString> {
133 unsafe {
134 from_glib_none(ffi::atk_action_get_localized_name(
135 self.as_ref().to_glib_none().0,
136 i,
137 ))
138 }
139 }
140
141 /// Gets the number of accessible actions available on the object.
142 /// If there are more than one, the first one is considered the
143 /// "default" action of the object.
144 ///
145 /// # Returns
146 ///
147 /// a the number of actions, or 0 if `self` does not
148 /// implement this interface.
149 #[doc(alias = "atk_action_get_n_actions")]
150 #[doc(alias = "get_n_actions")]
151 fn n_actions(&self) -> i32 {
152 unsafe { ffi::atk_action_get_n_actions(self.as_ref().to_glib_none().0) }
153 }
154
155 /// Returns a non-localized string naming the specified action of the
156 /// object. This name is generally not descriptive of the end result
157 /// of the action, but instead names the 'interaction type' which the
158 /// object supports. By convention, the above strings should be used to
159 /// represent the actions which correspond to the common point-and-click
160 /// interaction techniques of the same name: i.e.
161 /// "click", "press", "release", "drag", "drop", "popup", etc.
162 /// The "popup" action should be used to pop up a context menu for the
163 /// object, if one exists.
164 ///
165 /// For technical reasons, some toolkits cannot guarantee that the
166 /// reported action is actually 'bound' to a nontrivial user event;
167 /// i.e. the result of some actions via [`do_action()`][Self::do_action()] may be
168 /// NIL.
169 /// ## `i`
170 /// the action index corresponding to the action to be performed
171 ///
172 /// # Returns
173 ///
174 /// a name string, or [`None`] if `self` does not
175 /// implement this interface.
176 #[doc(alias = "atk_action_get_name")]
177 #[doc(alias = "get_name")]
178 fn name(&self, i: i32) -> Option<glib::GString> {
179 unsafe { from_glib_none(ffi::atk_action_get_name(self.as_ref().to_glib_none().0, i)) }
180 }
181
182 /// Sets a description of the specified action of the object.
183 /// ## `i`
184 /// the action index corresponding to the action to be performed
185 /// ## `desc`
186 /// the description to be assigned to this action
187 ///
188 /// # Returns
189 ///
190 /// a gboolean representing if the description was successfully set;
191 #[doc(alias = "atk_action_set_description")]
192 fn set_description(&self, i: i32, desc: &str) -> bool {
193 unsafe {
194 from_glib(ffi::atk_action_set_description(
195 self.as_ref().to_glib_none().0,
196 i,
197 desc.to_glib_none().0,
198 ))
199 }
200 }
201}
202
203impl<O: IsA<Action>> AtkActionExt for O {}