Skip to content

Commit

Permalink
Merge pull request #204 from odilia-app/add-action-struct
Browse files Browse the repository at this point in the history
add action struct
  • Loading branch information
TTWNO authored Jul 1, 2024
2 parents f4ca3cc + 21830fd commit 3090cd3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
29 changes: 29 additions & 0 deletions atspi-common/src/action.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use serde::{Deserialize, Serialize};
use zvariant::Type;

/// An action which may be triggered through the accessibility API.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
pub struct Action {
/// The name of the action
pub name: String,
/// Description of the action
pub description: String,
// TODO: should be an enum/stricter type; this is why it's in its own file.
/// The keybinding(s) used to trigger it (without the AT).
pub keybinding: String,
}

#[cfg(test)]
mod test {
use super::Action;
use zbus_lockstep::method_return_signature;
use zvariant::Type;
#[test]
fn validate_action_signature() {
// signature is of type `a(sss)`, where `(sss)` is the type we're validating.
let action_signature =
method_return_signature!(member: "GetActions", interface: "org.a11y.atspi.Action")
.slice(1..);
assert_eq!(Action::signature(), action_signature);
}
}
2 changes: 2 additions & 0 deletions atspi-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extern crate static_assertions;
#[macro_use]
pub(crate) mod macros;

pub mod action;
pub use action::Action;
pub mod object_match;
pub use object_match::{MatchType, ObjectMatchRule, SortOrder, TreeTraversalType};
pub mod object_ref;
Expand Down
4 changes: 3 additions & 1 deletion atspi-proxies/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
//! [TextProxy]: crate::text::TextProxy
//! [ValueProxy]: crate::value::ValueProxy

use atspi_common::Action;

/// A handle for a remote object implementing the `org.a11y.atspi.Action`
/// interface.
///
Expand Down Expand Up @@ -60,7 +62,7 @@ trait Action {
/// [`get_key_binding`]: ActionProxy#method.get_key_binding
/// [`get_localized_name`]: ActionProxy#method.get_localized_name
/// [`get_description`]: ActionProxy#method.get_description
fn get_actions(&self) -> zbus::Result<Vec<(String, String, String)>>;
fn get_actions(&self) -> zbus::Result<Vec<Action>>;

/// Returns the localized description for the action at the specified
/// index, starting at zero.
Expand Down

0 comments on commit 3090cd3

Please sign in to comment.