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")]
162 fn is_inline(&self) -> bool {
163 unsafe { from_glib(ffi::atk_hyperlink_is_inline(self.as_ref().to_glib_none().0)) }
164 }
165
166 #[doc(alias = "atk_hyperlink_is_valid")]
174 fn is_valid(&self) -> bool {
175 unsafe { from_glib(ffi::atk_hyperlink_is_valid(self.as_ref().to_glib_none().0)) }
176 }
177
178 #[doc(alias = "number-of-anchors")]
179 fn number_of_anchors(&self) -> i32 {
180 ObjectExt::property(self.as_ref(), "number-of-anchors")
181 }
182
183 #[doc(alias = "link-activated")]
185 fn connect_link_activated<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
186 unsafe extern "C" fn link_activated_trampoline<P: IsA<Hyperlink>, F: Fn(&P) + 'static>(
187 this: *mut ffi::AtkHyperlink,
188 f: glib::ffi::gpointer,
189 ) {
190 unsafe {
191 let f: &F = &*(f as *const F);
192 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
193 }
194 }
195 unsafe {
196 let f: Box_<F> = Box_::new(f);
197 connect_raw(
198 self.as_ptr() as *mut _,
199 c"link-activated".as_ptr(),
200 Some(std::mem::transmute::<*const (), 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 unsafe {
216 let f: &F = &*(f as *const F);
217 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
218 }
219 }
220 unsafe {
221 let f: Box_<F> = Box_::new(f);
222 connect_raw(
223 self.as_ptr() as *mut _,
224 c"notify::end-index".as_ptr(),
225 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
226 notify_end_index_trampoline::<Self, F> as *const (),
227 )),
228 Box_::into_raw(f),
229 )
230 }
231 }
232
233 #[doc(alias = "number-of-anchors")]
234 fn connect_number_of_anchors_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
235 unsafe extern "C" fn notify_number_of_anchors_trampoline<
236 P: IsA<Hyperlink>,
237 F: Fn(&P) + 'static,
238 >(
239 this: *mut ffi::AtkHyperlink,
240 _param_spec: glib::ffi::gpointer,
241 f: glib::ffi::gpointer,
242 ) {
243 unsafe {
244 let f: &F = &*(f as *const F);
245 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
246 }
247 }
248 unsafe {
249 let f: Box_<F> = Box_::new(f);
250 connect_raw(
251 self.as_ptr() as *mut _,
252 c"notify::number-of-anchors".as_ptr(),
253 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
254 notify_number_of_anchors_trampoline::<Self, F> as *const (),
255 )),
256 Box_::into_raw(f),
257 )
258 }
259 }
260
261 #[doc(alias = "start-index")]
262 fn connect_start_index_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
263 unsafe extern "C" fn notify_start_index_trampoline<
264 P: IsA<Hyperlink>,
265 F: Fn(&P) + 'static,
266 >(
267 this: *mut ffi::AtkHyperlink,
268 _param_spec: glib::ffi::gpointer,
269 f: glib::ffi::gpointer,
270 ) {
271 unsafe {
272 let f: &F = &*(f as *const F);
273 f(Hyperlink::from_glib_borrow(this).unsafe_cast_ref())
274 }
275 }
276 unsafe {
277 let f: Box_<F> = Box_::new(f);
278 connect_raw(
279 self.as_ptr() as *mut _,
280 c"notify::start-index".as_ptr(),
281 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
282 notify_start_index_trampoline::<Self, F> as *const (),
283 )),
284 Box_::into_raw(f),
285 )
286 }
287 }
288}
289
290impl<O: IsA<Hyperlink>> HyperlinkExt for O {}