atk/auto/
hyperlink.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::StaticType;
13use glib::Value;
14use glib_sys;
15use gobject_sys;
16use std::boxed::Box as Box_;
17use std::fmt;
18use std::mem::transmute;
19use Action;
20use Object;
21
22glib_wrapper! {
23    pub struct Hyperlink(Object<atk_sys::AtkHyperlink, atk_sys::AtkHyperlinkClass, HyperlinkClass>) @implements Action;
24
25    match fn {
26        get_type => || atk_sys::atk_hyperlink_get_type(),
27    }
28}
29
30pub const NONE_HYPERLINK: Option<&Hyperlink> = None;
31
32pub trait HyperlinkExt: 'static {
33    fn get_end_index(&self) -> i32;
34
35    fn get_n_anchors(&self) -> i32;
36
37    fn get_object(&self, i: i32) -> Option<Object>;
38
39    fn get_start_index(&self) -> i32;
40
41    fn get_uri(&self, i: i32) -> Option<GString>;
42
43    fn is_inline(&self) -> bool;
44
45    fn is_valid(&self) -> bool;
46
47    fn get_property_number_of_anchors(&self) -> i32;
48
49    fn connect_link_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
50
51    fn connect_property_end_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
52
53    fn connect_property_number_of_anchors_notify<F: Fn(&Self) + 'static>(
54        &self,
55        f: F,
56    ) -> SignalHandlerId;
57
58    fn connect_property_start_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
59}
60
61impl<O: IsA<Hyperlink>> HyperlinkExt for O {
62    fn get_end_index(&self) -> i32 {
63        unsafe { atk_sys::atk_hyperlink_get_end_index(self.as_ref().to_glib_none().0) }
64    }
65
66    fn get_n_anchors(&self) -> i32 {
67        unsafe { atk_sys::atk_hyperlink_get_n_anchors(self.as_ref().to_glib_none().0) }
68    }
69
70    fn get_object(&self, i: i32) -> Option<Object> {
71        unsafe {
72            from_glib_none(atk_sys::atk_hyperlink_get_object(
73                self.as_ref().to_glib_none().0,
74                i,
75            ))
76        }
77    }
78
79    fn get_start_index(&self) -> i32 {
80        unsafe { atk_sys::atk_hyperlink_get_start_index(self.as_ref().to_glib_none().0) }
81    }
82
83    fn get_uri(&self, i: i32) -> Option<GString> {
84        unsafe {
85            from_glib_full(atk_sys::atk_hyperlink_get_uri(
86                self.as_ref().to_glib_none().0,
87                i,
88            ))
89        }
90    }
91
92    fn is_inline(&self) -> bool {
93        unsafe {
94            from_glib(atk_sys::atk_hyperlink_is_inline(
95                self.as_ref().to_glib_none().0,
96            ))
97        }
98    }
99
100    fn is_valid(&self) -> bool {
101        unsafe {
102            from_glib(atk_sys::atk_hyperlink_is_valid(
103                self.as_ref().to_glib_none().0,
104            ))
105        }
106    }
107
108    fn get_property_number_of_anchors(&self) -> i32 {
109        unsafe {
110            let mut value = Value::from_type(<i32 as StaticType>::static_type());
111            gobject_sys::g_object_get_property(
112                self.to_glib_none().0 as *mut gobject_sys::GObject,
113                b"number-of-anchors\0".as_ptr() as *const _,
114                value.to_glib_none_mut().0,
115            );
116            value.get().unwrap()
117        }
118    }
119
120    fn connect_link_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
121        unsafe extern "C" fn link_activated_trampoline<P, F: Fn(&P) + 'static>(
122            this: *mut atk_sys::AtkHyperlink,
123            f: glib_sys::gpointer,
124        ) where
125            P: IsA<Hyperlink>,
126        {
127            let f: &F = &*(f as *const F);
128            f(&Hyperlink::from_glib_borrow(this).unsafe_cast())
129        }
130        unsafe {
131            let f: Box_<F> = Box_::new(f);
132            connect_raw(
133                self.as_ptr() as *mut _,
134                b"link-activated\0".as_ptr() as *const _,
135                Some(transmute(link_activated_trampoline::<Self, F> as usize)),
136                Box_::into_raw(f),
137            )
138        }
139    }
140
141    fn connect_property_end_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
142        unsafe extern "C" fn notify_end_index_trampoline<P, F: Fn(&P) + 'static>(
143            this: *mut atk_sys::AtkHyperlink,
144            _param_spec: glib_sys::gpointer,
145            f: glib_sys::gpointer,
146        ) where
147            P: IsA<Hyperlink>,
148        {
149            let f: &F = &*(f as *const F);
150            f(&Hyperlink::from_glib_borrow(this).unsafe_cast())
151        }
152        unsafe {
153            let f: Box_<F> = Box_::new(f);
154            connect_raw(
155                self.as_ptr() as *mut _,
156                b"notify::end-index\0".as_ptr() as *const _,
157                Some(transmute(notify_end_index_trampoline::<Self, F> as usize)),
158                Box_::into_raw(f),
159            )
160        }
161    }
162
163    fn connect_property_number_of_anchors_notify<F: Fn(&Self) + 'static>(
164        &self,
165        f: F,
166    ) -> SignalHandlerId {
167        unsafe extern "C" fn notify_number_of_anchors_trampoline<P, F: Fn(&P) + 'static>(
168            this: *mut atk_sys::AtkHyperlink,
169            _param_spec: glib_sys::gpointer,
170            f: glib_sys::gpointer,
171        ) where
172            P: IsA<Hyperlink>,
173        {
174            let f: &F = &*(f as *const F);
175            f(&Hyperlink::from_glib_borrow(this).unsafe_cast())
176        }
177        unsafe {
178            let f: Box_<F> = Box_::new(f);
179            connect_raw(
180                self.as_ptr() as *mut _,
181                b"notify::number-of-anchors\0".as_ptr() as *const _,
182                Some(transmute(
183                    notify_number_of_anchors_trampoline::<Self, F> as usize,
184                )),
185                Box_::into_raw(f),
186            )
187        }
188    }
189
190    fn connect_property_start_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
191        unsafe extern "C" fn notify_start_index_trampoline<P, F: Fn(&P) + 'static>(
192            this: *mut atk_sys::AtkHyperlink,
193            _param_spec: glib_sys::gpointer,
194            f: glib_sys::gpointer,
195        ) where
196            P: IsA<Hyperlink>,
197        {
198            let f: &F = &*(f as *const F);
199            f(&Hyperlink::from_glib_borrow(this).unsafe_cast())
200        }
201        unsafe {
202            let f: Box_<F> = Box_::new(f);
203            connect_raw(
204                self.as_ptr() as *mut _,
205                b"notify::start-index\0".as_ptr() as *const _,
206                Some(transmute(notify_start_index_trampoline::<Self, F> as usize)),
207                Box_::into_raw(f),
208            )
209        }
210    }
211}
212
213impl fmt::Display for Hyperlink {
214    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
215        write!(f, "Hyperlink")
216    }
217}