From e7330964607d139bf87de08f8575ac6a8c0cc272 Mon Sep 17 00:00:00 2001 From: Tait Hoyem Date: Tue, 25 Jun 2024 21:45:06 -0600 Subject: [PATCH] Use Operation in TextChanged/ChildrenChangedEvent --- atspi-common/src/events/object.rs | 32 ++++++++----------------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/atspi-common/src/events/object.rs b/atspi-common/src/events/object.rs index cef25adb..2121bc11 100644 --- a/atspi-common/src/events/object.rs +++ b/atspi-common/src/events/object.rs @@ -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. @@ -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 @@ -664,7 +648,7 @@ impl BusProperties for ChildrenChangedEvent { fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result { Ok(Self { item, - operation: body.kind, + operation: body.kind.as_str().try_into()?, index_in_parent: body.detail1, child: body.any_data.try_into()?, }) @@ -943,7 +927,7 @@ impl BusProperties for TextChangedEvent { fn from_message_parts(item: ObjectRef, body: Self::Body) -> Result { 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()?, @@ -1156,7 +1140,7 @@ impl From 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` @@ -1569,7 +1553,7 @@ impl From 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,