Skip to content

Commit

Permalink
Use Operation in TextChanged/ChildrenChangedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
TTWNO committed Jun 26, 2024
1 parent 6a95ee9 commit e733096
Showing 1 changed file with 8 additions and 24 deletions.
32 changes: 8 additions & 24 deletions atspi-common/src/events/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,8 @@ pub struct StateChangedEvent {
pub struct ChildrenChangedEvent {
/// The [`ObjectRef`] which the event applies to.
pub item: crate::events::ObjectRef,
/// Operation, which may be one of:
///
/// * "insert/system"
/// * "insert"
/// * "delete/system"
/// * "delete"
///
/// The operation is the same whether it contains the "/system" suffix or not.
/// TODO: This should be an enum.
pub operation: String,
/// The [`Operation`] being performed.
pub operation: crate::Operation,
/// Index to remove from/add to.
pub index_in_parent: i32,
/// A reference to the new child.
Expand Down Expand Up @@ -545,16 +537,8 @@ pub struct TextSelectionChangedEvent {
pub struct TextChangedEvent {
/// The [`ObjectRef`] which the event applies to.
pub item: crate::events::ObjectRef,
/// Operation, which may be one of:
///
/// * "insert/system"
/// * "insert"
/// * "delete/system"
/// * "delete"
///
/// The operation is the same whether it contains the "/system" suffix or not.
/// TODO: This should be an enum.
pub operation: String,
/// The [`Operation`] being performed.
pub operation: crate::Operation,
/// starting index of the insertion/deletion
pub start_pos: i32,
/// length of the insertion/deletion
Expand Down Expand Up @@ -664,7 +648,7 @@ impl BusProperties for ChildrenChangedEvent {
fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
Ok(Self {
item,
operation: body.kind,
operation: body.kind.as_str().try_into()?,
index_in_parent: body.detail1,
child: body.any_data.try_into()?,
})
Expand Down Expand Up @@ -943,7 +927,7 @@ impl BusProperties for TextChangedEvent {
fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result<Self, AtspiError> {
Ok(Self {
item,
operation: body.kind,
operation: body.kind.as_str().try_into()?,
start_pos: body.detail1,
length: body.detail2,
text: body.any_data.try_into()?,
Expand Down Expand Up @@ -1156,7 +1140,7 @@ impl From<ChildrenChangedEvent> for EventBodyOwned {
fn from(event: ChildrenChangedEvent) -> Self {
EventBodyOwned {
properties: std::collections::HashMap::new(),
kind: event.operation,
kind: event.operation.into(),
detail1: event.index_in_parent,
detail2: i32::default(),
// `OwnedValue` is constructed from the `ObjectRef`
Expand Down Expand Up @@ -1569,7 +1553,7 @@ impl From<TextChangedEvent> for EventBodyOwned {
fn from(event: TextChangedEvent) -> Self {
EventBodyOwned {
properties: std::collections::HashMap::new(),
kind: event.operation,
kind: event.operation.into(),
detail1: event.start_pos,
detail2: event.length,

Expand Down

0 comments on commit e733096

Please sign in to comment.