1use crate::{Action, Object};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::{boxed::Box as Box_, fmt, mem::transmute};
12
13glib::wrapper! {
14 #[doc(alias = "AtkHyperlink")]
55 pub struct Hyperlink(Object<ffi::AtkHyperlink, ffi::AtkHyperlinkClass>) @implements Action;
56
57 match fn {
58 type_ => || ffi::atk_hyperlink_get_type(),
59 }
60}
61
62impl Hyperlink {
63 pub const NONE: Option<&'static Hyperlink> = None;
64}
65
66mod sealed {
67 pub trait Sealed {}
68 impl<T: super::IsA<super::Hyperlink>> Sealed for T {}
69}
70
71pub trait HyperlinkExt: IsA<Hyperlink> + sealed::Sealed + 'static {
77 #[doc(alias = "atk_hyperlink_get_end_index")]
83 #[doc(alias = "get_end_index")]
84 fn end_index(&self) -> i32 {
85 unsafe { ffi::atk_hyperlink_get_end_index(self.as_ref().to_glib_none().0) }
86 }
87
88 #[doc(alias = "atk_hyperlink_get_n_anchors")]
94 #[doc(alias = "get_n_anchors")]
95 fn n_anchors(&self) -> i32 {
96 unsafe { ffi::atk_hyperlink_get_n_anchors(self.as_ref().to_glib_none().0) }
97 }
98
99 #[doc(alias = "atk_hyperlink_get_object")]
113 #[doc(alias = "get_object")]
114 fn object(&self, i: i32) -> Option<Object> {
115 unsafe {
116 from_glib_none(ffi::atk_hyperlink_get_object(
117 self.as_ref().to_glib_none().0,
118 i,
119 ))
120 }
121 }
122
123 #[doc(alias = "atk_hyperlink_get_start_index")]
129 #[doc(alias = "get_start_index")]
130 fn start_index(&self) -> i32 {
131 unsafe { ffi::atk_hyperlink_get_start_index(self.as_ref().to_glib_none().0) }
132 }
133
134 #[doc(alias = "atk_hyperlink_get_uri")]
145 #[doc(alias = "get_uri")]
146 fn uri(&self, i: i32) -> Option<glib::GString> {
147 unsafe {
148 from_glib_full(ffi::atk_hyperlink_get_uri(
149 self.as_ref().to_glib_none().0,
150 i,
151 ))
152 }
153 }
154
155 #[doc(alias = "atk_hyperlink_is_inline")]
164 fn is_inline(&self) -> bool {
165 unsafe { from_glib(ffi::atk_hyperlink_is_inline(self.as_ref().to_glib_none().0)) }
166 }
167
168 #[doc(alias = "atk_hyperlink_is_valid")]
176 fn is_valid(&self) -> bool {
177 unsafe { from_glib(ffi::atk_hyperlink_is_valid(self.as_ref().to_glib_none().0)) }
178 }
179
180 #[doc(alias = "number-of-anchors")]
181 fn number_of_anchors(&self) -> i32 {
182 ObjectExt::property(self.as_ref(), "number-of-anchors")
183 }
184
185 #[doc(alias = "link-activated")]
187 fn connect_link_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
188 unsafe extern "C" fn link_activated_trampoline<P: IsA<Hyperlink>, F: Fn(&P) + 'static>(
189 this: *mut ffi::AtkHyperlink,
190 f: glib::ffi::gpointer,
191 ) {
192 let f: &F = &*(f as *const F);
193 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
194 }
195 unsafe {
196 let f: Box_<F> = Box_::new(f);
197 connect_raw(
198 self.as_ptr() as *mut _,
199 b"link-activated\0".as_ptr() as *const _,
200 Some(transmute::<_, unsafe extern "C" fn()>(
201 link_activated_trampoline::<Self, F> as *const (),
202 )),
203 Box_::into_raw(f),
204 )
205 }
206 }
207
208 #[doc(alias = "end-index")]
209 fn connect_end_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
210 unsafe extern "C" fn notify_end_index_trampoline<P: IsA<Hyperlink>, F: Fn(&P) + 'static>(
211 this: *mut ffi::AtkHyperlink,
212 _param_spec: glib::ffi::gpointer,
213 f: glib::ffi::gpointer,
214 ) {
215 let f: &F = &*(f as *const F);
216 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
217 }
218 unsafe {
219 let f: Box_<F> = Box_::new(f);
220 connect_raw(
221 self.as_ptr() as *mut _,
222 b"notify::end-index\0".as_ptr() as *const _,
223 Some(transmute::<_, 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 let f: &F = &*(f as *const F);
242 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
243 }
244 unsafe {
245 let f: Box_<F> = Box_::new(f);
246 connect_raw(
247 self.as_ptr() as *mut _,
248 b"notify::number-of-anchors\0".as_ptr() as *const _,
249 Some(transmute::<_, unsafe extern "C" fn()>(
250 notify_number_of_anchors_trampoline::<Self, F> as *const (),
251 )),
252 Box_::into_raw(f),
253 )
254 }
255 }
256
257 #[doc(alias = "start-index")]
258 fn connect_start_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
259 unsafe extern "C" fn notify_start_index_trampoline<
260 P: IsA<Hyperlink>,
261 F: Fn(&P) + 'static,
262 >(
263 this: *mut ffi::AtkHyperlink,
264 _param_spec: glib::ffi::gpointer,
265 f: glib::ffi::gpointer,
266 ) {
267 let f: &F = &*(f as *const F);
268 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
269 }
270 unsafe {
271 let f: Box_<F> = Box_::new(f);
272 connect_raw(
273 self.as_ptr() as *mut _,
274 b"notify::start-index\0".as_ptr() as *const _,
275 Some(transmute::<_, unsafe extern "C" fn()>(
276 notify_start_index_trampoline::<Self, F> as *const (),
277 )),
278 Box_::into_raw(f),
279 )
280 }
281 }
282}
283
284impl<O: IsA<Hyperlink>> HyperlinkExt for O {}
285
286impl fmt::Display for Hyperlink {
287 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
288 f.write_str("Hyperlink")
289 }
290}