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