atk/auto/document.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::{
6 prelude::*,
7 signal::{connect_raw, SignalHandlerId},
8 translate::*,
9};
10use std::{boxed::Box as Box_, fmt, mem::transmute};
11
12glib::wrapper! {
13 /// The ATK interface which represents the toplevel
14 /// container for document content.
15 ///
16 /// The AtkDocument interface should be supported by any object whose
17 /// content is a representation or view of a document. The AtkDocument
18 /// interface should appear on the toplevel container for the document
19 /// content; however AtkDocument instances may be nested (i.e. an
20 /// AtkDocument may be a descendant of another AtkDocument) in those
21 /// cases where one document contains "embedded content" which can
22 /// reasonably be considered a document in its own right.
23 ///
24 /// ## Signals
25 ///
26 ///
27 /// #### `load-complete`
28 /// The 'load-complete' signal is emitted when a pending load of
29 /// a static document has completed. This signal is to be
30 /// expected by ATK clients if and when AtkDocument implementors
31 /// expose ATK_STATE_BUSY. If the state of an AtkObject which
32 /// implements AtkDocument does not include ATK_STATE_BUSY, it
33 /// should be safe for clients to assume that the AtkDocument's
34 /// static contents are fully loaded into the container.
35 /// (Dynamic document contents should be exposed via other
36 /// signals.)
37 ///
38 ///
39 ///
40 ///
41 /// #### `load-stopped`
42 /// The 'load-stopped' signal is emitted when a pending load of
43 /// document contents is cancelled, paused, or otherwise
44 /// interrupted by the user or application logic. It should not
45 /// however be emitted while waiting for a resource (for instance
46 /// while blocking on a file or network read) unless a
47 /// user-significant timeout has occurred.
48 ///
49 ///
50 ///
51 ///
52 /// #### `page-changed`
53 /// The 'page-changed' signal is emitted when the current page of
54 /// a document changes, e.g. pressing page up/down in a document
55 /// viewer.
56 ///
57 ///
58 ///
59 ///
60 /// #### `reload`
61 /// The 'reload' signal is emitted when the contents of a
62 /// document is refreshed from its source. Once 'reload' has
63 /// been emitted, a matching 'load-complete' or 'load-stopped'
64 /// signal should follow, which clients may await before
65 /// interrogating ATK for the latest document content.
66 ///
67 ///
68 ///
69 /// # Implements
70 ///
71 /// [`DocumentExt`][trait@crate::prelude::DocumentExt]
72 #[doc(alias = "AtkDocument")]
73 pub struct Document(Interface<ffi::AtkDocument, ffi::AtkDocumentIface>);
74
75 match fn {
76 type_ => || ffi::atk_document_get_type(),
77 }
78}
79
80impl Document {
81 pub const NONE: Option<&'static Document> = None;
82}
83
84mod sealed {
85 pub trait Sealed {}
86 impl<T: super::IsA<super::Document>> Sealed for T {}
87}
88
89/// Trait containing all [`struct@Document`] methods.
90///
91/// # Implementors
92///
93/// [`Document`][struct@crate::Document], [`NoOpObject`][struct@crate::NoOpObject]
94pub trait DocumentExt: IsA<Document> + sealed::Sealed + 'static {
95 /// Retrieves the value of the given `attribute_name` inside `self`.
96 /// ## `attribute_name`
97 /// a character string representing the name of the attribute
98 /// whose value is being queried.
99 ///
100 /// # Returns
101 ///
102 /// a string value associated with the named
103 /// attribute for this document, or [`None`] if a value for
104 /// `attribute_name` has not been specified for this document.
105 #[doc(alias = "atk_document_get_attribute_value")]
106 #[doc(alias = "get_attribute_value")]
107 fn attribute_value(&self, attribute_name: &str) -> Option<glib::GString> {
108 unsafe {
109 from_glib_none(ffi::atk_document_get_attribute_value(
110 self.as_ref().to_glib_none().0,
111 attribute_name.to_glib_none().0,
112 ))
113 }
114 }
115
116 /// Retrieves the current page number inside `self`.
117 ///
118 /// # Returns
119 ///
120 /// the current page number inside `self`, or -1 if
121 /// not implemented, not know by the implementor, or irrelevant.
122 #[doc(alias = "atk_document_get_current_page_number")]
123 #[doc(alias = "get_current_page_number")]
124 fn current_page_number(&self) -> i32 {
125 unsafe { ffi::atk_document_get_current_page_number(self.as_ref().to_glib_none().0) }
126 }
127
128 //#[doc(alias = "atk_document_get_document")]
129 //#[doc(alias = "get_document")]
130 //fn document(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
131 // unsafe { TODO: call ffi:atk_document_get_document() }
132 //}
133
134 /// Gets a string indicating the document type.
135 ///
136 /// # Deprecated
137 ///
138 /// Since 2.12. Please use `atk_document_get_attributes()` to
139 /// ask for the document type if it applies.
140 ///
141 /// # Returns
142 ///
143 /// a string indicating the document type
144 #[doc(alias = "atk_document_get_document_type")]
145 #[doc(alias = "get_document_type")]
146 fn document_type(&self) -> Option<glib::GString> {
147 unsafe {
148 from_glib_none(ffi::atk_document_get_document_type(
149 self.as_ref().to_glib_none().0,
150 ))
151 }
152 }
153
154 /// Retrieves the total number of pages inside `self`.
155 ///
156 /// # Returns
157 ///
158 /// total page count of `self`, or -1 if not implemented,
159 /// not know by the implementor or irrelevant.
160 #[doc(alias = "atk_document_get_page_count")]
161 #[doc(alias = "get_page_count")]
162 fn page_count(&self) -> i32 {
163 unsafe { ffi::atk_document_get_page_count(self.as_ref().to_glib_none().0) }
164 }
165
166 /// Sets the value for the given `attribute_name` inside `self`.
167 /// ## `attribute_name`
168 /// a character string representing the name of the attribute
169 /// whose value is being set.
170 /// ## `attribute_value`
171 /// a string value to be associated with `attribute_name`.
172 ///
173 /// # Returns
174 ///
175 /// [`true`] if `attribute_value` is successfully associated
176 /// with `attribute_name` for this `self`, and [`false`] if if the
177 /// document does not allow the attribute to be modified
178 #[doc(alias = "atk_document_set_attribute_value")]
179 fn set_attribute_value(&self, attribute_name: &str, attribute_value: &str) -> bool {
180 unsafe {
181 from_glib(ffi::atk_document_set_attribute_value(
182 self.as_ref().to_glib_none().0,
183 attribute_name.to_glib_none().0,
184 attribute_value.to_glib_none().0,
185 ))
186 }
187 }
188
189 /// The 'load-complete' signal is emitted when a pending load of
190 /// a static document has completed. This signal is to be
191 /// expected by ATK clients if and when AtkDocument implementors
192 /// expose ATK_STATE_BUSY. If the state of an AtkObject which
193 /// implements AtkDocument does not include ATK_STATE_BUSY, it
194 /// should be safe for clients to assume that the AtkDocument's
195 /// static contents are fully loaded into the container.
196 /// (Dynamic document contents should be exposed via other
197 /// signals.)
198 #[doc(alias = "load-complete")]
199 fn connect_load_complete<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
200 unsafe extern "C" fn load_complete_trampoline<P: IsA<Document>, F: Fn(&P) + 'static>(
201 this: *mut ffi::AtkDocument,
202 f: glib::ffi::gpointer,
203 ) {
204 let f: &F = &*(f as *const F);
205 f(Document::from_glib_borrow(this).unsafe_cast_ref())
206 }
207 unsafe {
208 let f: Box_<F> = Box_::new(f);
209 connect_raw(
210 self.as_ptr() as *mut _,
211 b"load-complete\0".as_ptr() as *const _,
212 Some(transmute::<_, unsafe extern "C" fn()>(
213 load_complete_trampoline::<Self, F> as *const (),
214 )),
215 Box_::into_raw(f),
216 )
217 }
218 }
219
220 /// The 'load-stopped' signal is emitted when a pending load of
221 /// document contents is cancelled, paused, or otherwise
222 /// interrupted by the user or application logic. It should not
223 /// however be emitted while waiting for a resource (for instance
224 /// while blocking on a file or network read) unless a
225 /// user-significant timeout has occurred.
226 #[doc(alias = "load-stopped")]
227 fn connect_load_stopped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
228 unsafe extern "C" fn load_stopped_trampoline<P: IsA<Document>, F: Fn(&P) + 'static>(
229 this: *mut ffi::AtkDocument,
230 f: glib::ffi::gpointer,
231 ) {
232 let f: &F = &*(f as *const F);
233 f(Document::from_glib_borrow(this).unsafe_cast_ref())
234 }
235 unsafe {
236 let f: Box_<F> = Box_::new(f);
237 connect_raw(
238 self.as_ptr() as *mut _,
239 b"load-stopped\0".as_ptr() as *const _,
240 Some(transmute::<_, unsafe extern "C" fn()>(
241 load_stopped_trampoline::<Self, F> as *const (),
242 )),
243 Box_::into_raw(f),
244 )
245 }
246 }
247
248 /// The 'page-changed' signal is emitted when the current page of
249 /// a document changes, e.g. pressing page up/down in a document
250 /// viewer.
251 /// ## `page_number`
252 /// the new page number. If this value is unknown
253 /// or not applicable, -1 should be provided.
254 #[doc(alias = "page-changed")]
255 fn connect_page_changed<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
256 unsafe extern "C" fn page_changed_trampoline<P: IsA<Document>, F: Fn(&P, i32) + 'static>(
257 this: *mut ffi::AtkDocument,
258 page_number: libc::c_int,
259 f: glib::ffi::gpointer,
260 ) {
261 let f: &F = &*(f as *const F);
262 f(
263 Document::from_glib_borrow(this).unsafe_cast_ref(),
264 page_number,
265 )
266 }
267 unsafe {
268 let f: Box_<F> = Box_::new(f);
269 connect_raw(
270 self.as_ptr() as *mut _,
271 b"page-changed\0".as_ptr() as *const _,
272 Some(transmute::<_, unsafe extern "C" fn()>(
273 page_changed_trampoline::<Self, F> as *const (),
274 )),
275 Box_::into_raw(f),
276 )
277 }
278 }
279
280 /// The 'reload' signal is emitted when the contents of a
281 /// document is refreshed from its source. Once 'reload' has
282 /// been emitted, a matching 'load-complete' or 'load-stopped'
283 /// signal should follow, which clients may await before
284 /// interrogating ATK for the latest document content.
285 #[doc(alias = "reload")]
286 fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
287 unsafe extern "C" fn reload_trampoline<P: IsA<Document>, F: Fn(&P) + 'static>(
288 this: *mut ffi::AtkDocument,
289 f: glib::ffi::gpointer,
290 ) {
291 let f: &F = &*(f as *const F);
292 f(Document::from_glib_borrow(this).unsafe_cast_ref())
293 }
294 unsafe {
295 let f: Box_<F> = Box_::new(f);
296 connect_raw(
297 self.as_ptr() as *mut _,
298 b"reload\0".as_ptr() as *const _,
299 Some(transmute::<_, unsafe extern "C" fn()>(
300 reload_trampoline::<Self, F> as *const (),
301 )),
302 Box_::into_raw(f),
303 )
304 }
305 }
306}
307
308impl<O: IsA<Document>> DocumentExt for O {}
309
310impl fmt::Display for Document {
311 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
312 f.write_str("Document")
313 }
314}