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 atk_sys;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib::GString;
12use glib_sys;
13use libc;
14use std::boxed::Box as Box_;
15use std::fmt;
16use std::mem::transmute;
17
18glib_wrapper! {
19    pub struct Document(Interface<atk_sys::AtkDocument>);
20
21    match fn {
22        get_type => || atk_sys::atk_document_get_type(),
23    }
24}
25
26pub const NONE_DOCUMENT: Option<&Document> = None;
27
28pub trait DocumentExt: 'static {
29    fn get_attribute_value(&self, attribute_name: &str) -> Option<GString>;
30
31    //fn get_attributes(&self) -> /*Ignored*/Option<AttributeSet>;
32
33    fn get_current_page_number(&self) -> i32;
34
35    //fn get_document(&self) -> /*Unimplemented*/Option<Fundamental: Pointer>;
36
37    fn get_document_type(&self) -> Option<GString>;
38
39    fn get_page_count(&self) -> i32;
40
41    fn set_attribute_value(&self, attribute_name: &str, attribute_value: &str) -> bool;
42
43    fn connect_load_complete<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
44
45    fn connect_load_stopped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
46
47    fn connect_page_changed<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId;
48
49    fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
50}
51
52impl<O: IsA<Document>> DocumentExt for O {
53    fn get_attribute_value(&self, attribute_name: &str) -> Option<GString> {
54        unsafe {
55            from_glib_none(atk_sys::atk_document_get_attribute_value(
56                self.as_ref().to_glib_none().0,
57                attribute_name.to_glib_none().0,
58            ))
59        }
60    }
61
62    //fn get_attributes(&self) -> /*Ignored*/Option<AttributeSet> {
63    //    unsafe { TODO: call atk_sys:atk_document_get_attributes() }
64    //}
65
66    fn get_current_page_number(&self) -> i32 {
67        unsafe { atk_sys::atk_document_get_current_page_number(self.as_ref().to_glib_none().0) }
68    }
69
70    //fn get_document(&self) -> /*Unimplemented*/Option<Fundamental: Pointer> {
71    //    unsafe { TODO: call atk_sys:atk_document_get_document() }
72    //}
73
74    fn get_document_type(&self) -> Option<GString> {
75        unsafe {
76            from_glib_none(atk_sys::atk_document_get_document_type(
77                self.as_ref().to_glib_none().0,
78            ))
79        }
80    }
81
82    fn get_page_count(&self) -> i32 {
83        unsafe { atk_sys::atk_document_get_page_count(self.as_ref().to_glib_none().0) }
84    }
85
86    fn set_attribute_value(&self, attribute_name: &str, attribute_value: &str) -> bool {
87        unsafe {
88            from_glib(atk_sys::atk_document_set_attribute_value(
89                self.as_ref().to_glib_none().0,
90                attribute_name.to_glib_none().0,
91                attribute_value.to_glib_none().0,
92            ))
93        }
94    }
95
96    fn connect_load_complete<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
97        unsafe extern "C" fn load_complete_trampoline<P, F: Fn(&P) + 'static>(
98            this: *mut atk_sys::AtkDocument,
99            f: glib_sys::gpointer,
100        ) where
101            P: IsA<Document>,
102        {
103            let f: &F = &*(f as *const F);
104            f(&Document::from_glib_borrow(this).unsafe_cast())
105        }
106        unsafe {
107            let f: Box_<F> = Box_::new(f);
108            connect_raw(
109                self.as_ptr() as *mut _,
110                b"load-complete\0".as_ptr() as *const _,
111                Some(transmute(load_complete_trampoline::<Self, F> as usize)),
112                Box_::into_raw(f),
113            )
114        }
115    }
116
117    fn connect_load_stopped<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
118        unsafe extern "C" fn load_stopped_trampoline<P, F: Fn(&P) + 'static>(
119            this: *mut atk_sys::AtkDocument,
120            f: glib_sys::gpointer,
121        ) where
122            P: IsA<Document>,
123        {
124            let f: &F = &*(f as *const F);
125            f(&Document::from_glib_borrow(this).unsafe_cast())
126        }
127        unsafe {
128            let f: Box_<F> = Box_::new(f);
129            connect_raw(
130                self.as_ptr() as *mut _,
131                b"load-stopped\0".as_ptr() as *const _,
132                Some(transmute(load_stopped_trampoline::<Self, F> as usize)),
133                Box_::into_raw(f),
134            )
135        }
136    }
137
138    fn connect_page_changed<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
139        unsafe extern "C" fn page_changed_trampoline<P, F: Fn(&P, i32) + 'static>(
140            this: *mut atk_sys::AtkDocument,
141            page_number: libc::c_int,
142            f: glib_sys::gpointer,
143        ) where
144            P: IsA<Document>,
145        {
146            let f: &F = &*(f as *const F);
147            f(&Document::from_glib_borrow(this).unsafe_cast(), page_number)
148        }
149        unsafe {
150            let f: Box_<F> = Box_::new(f);
151            connect_raw(
152                self.as_ptr() as *mut _,
153                b"page-changed\0".as_ptr() as *const _,
154                Some(transmute(page_changed_trampoline::<Self, F> as usize)),
155                Box_::into_raw(f),
156            )
157        }
158    }
159
160    fn connect_reload<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
161        unsafe extern "C" fn reload_trampoline<P, F: Fn(&P) + 'static>(
162            this: *mut atk_sys::AtkDocument,
163            f: glib_sys::gpointer,
164        ) where
165            P: IsA<Document>,
166        {
167            let f: &F = &*(f as *const F);
168            f(&Document::from_glib_borrow(this).unsafe_cast())
169        }
170        unsafe {
171            let f: Box_<F> = Box_::new(f);
172            connect_raw(
173                self.as_ptr() as *mut _,
174                b"reload\0".as_ptr() as *const _,
175                Some(transmute(reload_trampoline::<Self, F> as usize)),
176                Box_::into_raw(f),
177            )
178        }
179    }
180}
181
182impl fmt::Display for Document {
183    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
184        write!(f, "Document")
185    }
186}