1use crate::{Action, Object, 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 #[doc(alias = "AtkHyperlink")]
56 pub struct Hyperlink(Object<ffi::AtkHyperlink, ffi::AtkHyperlinkClass>) @implements Action;
57
58 match fn {
59 type_ => || ffi::atk_hyperlink_get_type(),
60 }
61}
62
63impl Hyperlink {
64 pub const NONE: Option<&'static Hyperlink> = None;
65}
66
67pub trait HyperlinkExt: IsA<Hyperlink> + 'static {
73 #[doc(alias = "atk_hyperlink_get_end_index")]
79 #[doc(alias = "get_end_index")]
80 #[doc(alias = "end-index")]
81 fn end_index(&self) -> i32 {
82 unsafe { ffi::atk_hyperlink_get_end_index(self.as_ref().to_glib_none().0) }
83 }
84
85 #[doc(alias = "atk_hyperlink_get_n_anchors")]
91 #[doc(alias = "get_n_anchors")]
92 fn n_anchors(&self) -> i32 {
93 unsafe { ffi::atk_hyperlink_get_n_anchors(self.as_ref().to_glib_none().0) }
94 }
95
96 #[doc(alias = "atk_hyperlink_get_object")]
110 #[doc(alias = "get_object")]
111 fn object(&self, i: i32) -> Option<Object> {
112 unsafe {
113 from_glib_none(ffi::atk_hyperlink_get_object(
114 self.as_ref().to_glib_none().0,
115 i,
116 ))
117 }
118 }
119
120 #[doc(alias = "atk_hyperlink_get_start_index")]
126 #[doc(alias = "get_start_index")]
127 #[doc(alias = "start-index")]
128 fn start_index(&self) -> i32 {
129 unsafe { ffi::atk_hyperlink_get_start_index(self.as_ref().to_glib_none().0) }
130 }
131
132 #[doc(alias = "atk_hyperlink_get_uri")]
143 #[doc(alias = "get_uri")]
144 fn uri(&self, i: i32) -> Option<glib::GString> {
145 unsafe {
146 from_glib_full(ffi::atk_hyperlink_get_uri(
147 self.as_ref().to_glib_none().0,
148 i,
149 ))
150 }
151 }
152
153 #[doc(alias = "atk_hyperlink_is_inline")]
160 fn is_inline(&self) -> bool {
161 unsafe { from_glib(ffi::atk_hyperlink_is_inline(self.as_ref().to_glib_none().0)) }
162 }
163
164 #[doc(alias = "atk_hyperlink_is_valid")]
172 fn is_valid(&self) -> bool {
173 unsafe { from_glib(ffi::atk_hyperlink_is_valid(self.as_ref().to_glib_none().0)) }
174 }
175
176 #[doc(alias = "number-of-anchors")]
177 fn number_of_anchors(&self) -> i32 {
178 ObjectExt::property(self.as_ref(), "number-of-anchors")
179 }
180
181 #[doc(alias = "link-activated")]
183 fn connect_link_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
184 unsafe extern "C" fn link_activated_trampoline<P: IsA<Hyperlink>, F: Fn(&P) + 'static>(
185 this: *mut ffi::AtkHyperlink,
186 f: glib::ffi::gpointer,
187 ) {
188 unsafe {
189 let f: &F = &*(f as *const F);
190 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
191 }
192 }
193 unsafe {
194 let f: Box_<F> = Box_::new(f);
195 connect_raw(
196 self.as_ptr() as *mut _,
197 c"link-activated".as_ptr(),
198 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
199 link_activated_trampoline::<Self, F> as *const (),
200 )),
201 Box_::into_raw(f),
202 )
203 }
204 }
205
206 #[doc(alias = "end-index")]
207 fn connect_end_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
208 unsafe extern "C" fn notify_end_index_trampoline<P: IsA<Hyperlink>, F: Fn(&P) + 'static>(
209 this: *mut ffi::AtkHyperlink,
210 _param_spec: glib::ffi::gpointer,
211 f: glib::ffi::gpointer,
212 ) {
213 unsafe {
214 let f: &F = &*(f as *const F);
215 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
216 }
217 }
218 unsafe {
219 let f: Box_<F> = Box_::new(f);
220 connect_raw(
221 self.as_ptr() as *mut _,
222 c"notify::end-index".as_ptr(),
223 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
224 notify_end_index_trampoline::<Self, F> as *const (),
225 )),
226 Box_::into_raw(f),
227 )
228 }
229 }
230
231 #[doc(alias = "number-of-anchors")]
232 fn connect_number_of_anchors_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
233 unsafe extern "C" fn notify_number_of_anchors_trampoline<
234 P: IsA<Hyperlink>,
235 F: Fn(&P) + 'static,
236 >(
237 this: *mut ffi::AtkHyperlink,
238 _param_spec: glib::ffi::gpointer,
239 f: glib::ffi::gpointer,
240 ) {
241 unsafe {
242 let f: &F = &*(f as *const F);
243 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
244 }
245 }
246 unsafe {
247 let f: Box_<F> = Box_::new(f);
248 connect_raw(
249 self.as_ptr() as *mut _,
250 c"notify::number-of-anchors".as_ptr(),
251 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
252 notify_number_of_anchors_trampoline::<Self, F> as *const (),
253 )),
254 Box_::into_raw(f),
255 )
256 }
257 }
258
259 #[doc(alias = "start-index")]
260 fn connect_start_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
261 unsafe extern "C" fn notify_start_index_trampoline<
262 P: IsA<Hyperlink>,
263 F: Fn(&P) + 'static,
264 >(
265 this: *mut ffi::AtkHyperlink,
266 _param_spec: glib::ffi::gpointer,
267 f: glib::ffi::gpointer,
268 ) {
269 unsafe {
270 let f: &F = &*(f as *const F);
271 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
272 }
273 }
274 unsafe {
275 let f: Box_<F> = Box_::new(f);
276 connect_raw(
277 self.as_ptr() as *mut _,
278 c"notify::start-index".as_ptr(),
279 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
280 notify_start_index_trampoline::<Self, F> as *const (),
281 )),
282 Box_::into_raw(f),
283 )
284 }
285 }
286}
287
288impl<O: IsA<Hyperlink>> HyperlinkExt for O {}