atspi_common/events/
document.rs

1#[cfg(feature = "zbus")]
2use crate::{
3	error::AtspiError,
4	events::{MessageConversion, MessageConversionExt},
5};
6use crate::{events::BusProperties, EventProperties};
7use zbus_names::UniqueName;
8use zvariant::ObjectPath;
9
10/// An event triggered by the completion of a document load action.
11/// For example: a web page has finished loading its initial payload, or
12/// `LibreOffice` has loaded a document from disk.
13#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
14pub struct LoadCompleteEvent {
15	/// The [`crate::ObjectRef`] which the event applies to.
16	pub item: crate::events::ObjectRef,
17}
18
19/// An event triggered by a reloading of a document.
20/// For example: pressing F5, or `Control + r` will reload a page in a web browser.
21#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
22pub struct ReloadEvent {
23	/// The [`crate::ObjectRef`] which the event applies to.
24	pub item: crate::events::ObjectRef,
25}
26
27/// An event triggered by the cancelling of a document load.
28/// For example: during the loading of a large web page, a user may press `Escape` to stop loading the page.
29#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
30pub struct LoadStoppedEvent {
31	/// The [`crate::ObjectRef`] which the event applies to.
32	pub item: crate::events::ObjectRef,
33}
34
35#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
36pub struct ContentChangedEvent {
37	/// The [`crate::ObjectRef`] which the event applies to.
38	pub item: crate::events::ObjectRef,
39}
40
41#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
42pub struct AttributesChangedEvent {
43	/// The [`crate::ObjectRef`] which the event applies to.
44	pub item: crate::events::ObjectRef,
45}
46
47/// The focused page has changed.
48///
49/// This event is usually sent only by document readers, signaling
50/// that the _physical page equivalent is now different.
51/// This event does not encode _which_ page is the new one, only that a new page is now the primary
52/// one.
53///
54/// See `atspi_proxies::document::DocumentProxy::current_page_number` to actively find the
55/// page number.
56#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, Eq, Hash, Default)]
57pub struct PageChangedEvent {
58	/// The [`crate::ObjectRef`] which the event applies to.
59	pub item: crate::events::ObjectRef,
60}
61
62impl BusProperties for LoadCompleteEvent {
63	const DBUS_MEMBER: &'static str = "LoadComplete";
64	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Document";
65	const MATCH_RULE_STRING: &'static str =
66		"type='signal',interface='org.a11y.atspi.Event.Document',member='LoadComplete'";
67	const REGISTRY_EVENT_STRING: &'static str = "Document:";
68}
69
70impl BusProperties for ReloadEvent {
71	const DBUS_MEMBER: &'static str = "Reload";
72	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Document";
73	const MATCH_RULE_STRING: &'static str =
74		"type='signal',interface='org.a11y.atspi.Event.Document',member='Reload'";
75	const REGISTRY_EVENT_STRING: &'static str = "Document:";
76}
77
78impl BusProperties for LoadStoppedEvent {
79	const DBUS_MEMBER: &'static str = "LoadStopped";
80	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Document";
81	const MATCH_RULE_STRING: &'static str =
82		"type='signal',interface='org.a11y.atspi.Event.Document',member='LoadStopped'";
83	const REGISTRY_EVENT_STRING: &'static str = "Document:";
84}
85
86impl BusProperties for ContentChangedEvent {
87	const DBUS_MEMBER: &'static str = "ContentChanged";
88	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Document";
89	const MATCH_RULE_STRING: &'static str =
90		"type='signal',interface='org.a11y.atspi.Event.Document',member='ContentChanged'";
91	const REGISTRY_EVENT_STRING: &'static str = "Document:";
92}
93
94impl BusProperties for AttributesChangedEvent {
95	const DBUS_MEMBER: &'static str = "AttributesChanged";
96	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Document";
97	const MATCH_RULE_STRING: &'static str =
98		"type='signal',interface='org.a11y.atspi.Event.Document',member='AttributesChanged'";
99	const REGISTRY_EVENT_STRING: &'static str = "Document:";
100}
101
102impl BusProperties for PageChangedEvent {
103	const DBUS_MEMBER: &'static str = "PageChanged";
104	const DBUS_INTERFACE: &'static str = "org.a11y.atspi.Event.Document";
105	const MATCH_RULE_STRING: &'static str =
106		"type='signal',interface='org.a11y.atspi.Event.Document',member='PageChanged'";
107	const REGISTRY_EVENT_STRING: &'static str = "Document:";
108}
109
110event_test_cases!(LoadCompleteEvent);
111impl_to_dbus_message!(LoadCompleteEvent);
112impl_from_dbus_message!(LoadCompleteEvent);
113impl_event_properties!(LoadCompleteEvent);
114impl_from_object_ref!(LoadCompleteEvent);
115
116event_test_cases!(ReloadEvent);
117impl_to_dbus_message!(ReloadEvent);
118impl_from_dbus_message!(ReloadEvent);
119impl_event_properties!(ReloadEvent);
120impl_from_object_ref!(ReloadEvent);
121
122event_test_cases!(LoadStoppedEvent);
123impl_to_dbus_message!(LoadStoppedEvent);
124impl_from_dbus_message!(LoadStoppedEvent);
125impl_event_properties!(LoadStoppedEvent);
126impl_from_object_ref!(LoadStoppedEvent);
127
128event_test_cases!(ContentChangedEvent);
129impl_to_dbus_message!(ContentChangedEvent);
130impl_from_dbus_message!(ContentChangedEvent);
131impl_event_properties!(ContentChangedEvent);
132impl_from_object_ref!(ContentChangedEvent);
133
134event_test_cases!(AttributesChangedEvent);
135impl_to_dbus_message!(AttributesChangedEvent);
136impl_from_dbus_message!(AttributesChangedEvent);
137impl_event_properties!(AttributesChangedEvent);
138impl_from_object_ref!(AttributesChangedEvent);
139
140event_test_cases!(PageChangedEvent);
141impl_to_dbus_message!(PageChangedEvent);
142impl_from_dbus_message!(PageChangedEvent);
143impl_event_properties!(PageChangedEvent);
144impl_from_object_ref!(PageChangedEvent);