Skip to main content

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 glib::{prelude::*, translate::*};
6use std::fmt;
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
45mod sealed {
46    pub trait Sealed {}
47    impl<T: super::IsA<super::Action>> Sealed for T {}
48}
49
50/// Trait containing all [`struct@Action`] methods.
51///
52/// # Implementors
53///
54/// [`Action`][struct@crate::Action], [`Hyperlink`][struct@crate::Hyperlink], [`NoOpObject`][struct@crate::NoOpObject]
55pub trait AtkActionExt: IsA<Action> + sealed::Sealed + 'static {
56    /// Perform the specified action on the object.
57    /// ## `i`
58    /// the action index corresponding to the action to be performed
59    ///
60    /// # Returns
61    ///
62    /// [`true`] if success, [`false`] otherwise
63    #[doc(alias = "atk_action_do_action")]
64    fn do_action(&self, i: i32) -> bool {
65        unsafe { from_glib(ffi::atk_action_do_action(self.as_ref().to_glib_none().0, i)) }
66    }
67
68    /// Returns a description of the specified action of the object.
69    /// ## `i`
70    /// the action index corresponding to the action to be performed
71    ///
72    /// # Returns
73    ///
74    /// a description string, or [`None`] if `self` does
75    /// not implement this interface.
76    #[doc(alias = "atk_action_get_description")]
77    #[doc(alias = "get_description")]
78    fn description(&self, i: i32) -> Option<glib::GString> {
79        unsafe {
80            from_glib_none(ffi::atk_action_get_description(
81                self.as_ref().to_glib_none().0,
82                i,
83            ))
84        }
85    }
86
87    /// Gets the keybinding which can be used to activate this action, if one
88    /// exists. The string returned should contain localized, human-readable,
89    /// key sequences as they would appear when displayed on screen. It must
90    /// be in the format "mnemonic;sequence;shortcut".
91    ///
92    /// - The mnemonic key activates the object if it is presently enabled onscreen.
93    ///  This typically corresponds to the underlined letter within the widget.
94    ///  Example: "n" in a traditional "New..." menu item or the "a" in "Apply" for
95    ///  a button.
96    /// - The sequence is the full list of keys which invoke the action even if the
97    ///  relevant element is not currently shown on screen. For instance, for a menu
98    ///  item the sequence is the keybindings used to open the parent menus before
99    ///  invoking. The sequence string is colon-delimited. Example: "Alt+F:N" in a
100    ///  traditional "New..." menu item.
101    /// - The shortcut, if it exists, will invoke the same action without showing
102    ///  the component or its enclosing menus or dialogs. Example: "Ctrl+N" in a
103    ///  traditional "New..." menu item.
104    ///
105    /// Example: For a traditional "New..." menu item, the expected return value
106    /// would be: "N;Alt+F:N;Ctrl+N" for the English locale and "N;Alt+D:N;Strg+N"
107    /// for the German locale. If, hypothetically, this menu item lacked a mnemonic,
108    /// it would be represented by ";;Ctrl+N" and ";;Strg+N" respectively.
109    /// ## `i`
110    /// the action index corresponding to the action to be performed
111    ///
112    /// # Returns
113    ///
114    /// the keybinding which can be used to activate
115    /// this action, or [`None`] if there is no keybinding for this action.
116    #[doc(alias = "atk_action_get_keybinding")]
117    #[doc(alias = "get_keybinding")]
118    fn keybinding(&self, i: i32) -> Option<glib::GString> {
119        unsafe {
120            from_glib_none(ffi::atk_action_get_keybinding(
121                self.as_ref().to_glib_none().0,
122                i,
123            ))
124        }
125    }
126
127    /// Returns the localized name of the specified action of the object.
128    /// ## `i`
129    /// the action index corresponding to the action to be performed
130    ///
131    /// # Returns
132    ///
133    /// a name string, or [`None`] if `self` does not
134    /// implement this interface.
135    #[doc(alias = "atk_action_get_localized_name")]
136    #[doc(alias = "get_localized_name")]
137    fn localized_name(&self, i: i32) -> Option<glib::GString> {
138        unsafe {
139            from_glib_none(ffi::atk_action_get_localized_name(
140                self.as_ref().to_glib_none().0,
141                i,
142            ))
143        }
144    }
145
146    /// Gets the number of accessible actions available on the object.
147    /// If there are more than one, the first one is considered the
148    /// "default" action of the object.
149    ///
150    /// # Returns
151    ///
152    /// a the number of actions, or 0 if `self` does not
153    /// implement this interface.
154    #[doc(alias = "atk_action_get_n_actions")]
155    #[doc(alias = "get_n_actions")]
156    fn n_actions(&self) -> i32 {
157        unsafe { ffi::atk_action_get_n_actions(self.as_ref().to_glib_none().0) }
158    }
159
160    /// Returns a non-localized string naming the specified action of the
161    /// object. This name is generally not descriptive of the end result
162    /// of the action, but instead names the 'interaction type' which the
163    /// object supports. By convention, the above strings should be used to
164    /// represent the actions which correspond to the common point-and-click
165    /// interaction techniques of the same name: i.e.
166    /// "click", "press", "release", "drag", "drop", "popup", etc.
167    /// The "popup" action should be used to pop up a context menu for the
168    /// object, if one exists.
169    ///
170    /// For technical reasons, some toolkits cannot guarantee that the
171    /// reported action is actually 'bound' to a nontrivial user event;
172    /// i.e. the result of some actions via [`do_action()`][Self::do_action()] may be
173    /// NIL.
174    /// ## `i`
175    /// the action index corresponding to the action to be performed
176    ///
177    /// # Returns
178    ///
179    /// a name string, or [`None`] if `self` does not
180    /// implement this interface.
181    #[doc(alias = "atk_action_get_name")]
182    #[doc(alias = "get_name")]
183    fn name(&self, i: i32) -> Option<glib::GString> {
184        unsafe { from_glib_none(ffi::atk_action_get_name(self.as_ref().to_glib_none().0, i)) }
185    }
186
187    /// Sets a description of the specified action of the object.
188    /// ## `i`
189    /// the action index corresponding to the action to be performed
190    /// ## `desc`
191    /// the description to be assigned to this action
192    ///
193    /// # Returns
194    ///
195    /// a gboolean representing if the description was successfully set;
196    #[doc(alias = "atk_action_set_description")]
197    fn set_description(&self, i: i32, desc: &str) -> bool {
198        unsafe {
199            from_glib(ffi::atk_action_set_description(
200                self.as_ref().to_glib_none().0,
201                i,
202                desc.to_glib_none().0,
203            ))
204        }
205    }
206}
207
208impl<O: IsA<Action>> AtkActionExt for O {}
209
210impl fmt::Display for Action {
211    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
212        f.write_str("Action")
213    }
214}