Skip to main content

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 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    /// An ATK object which encapsulates a link or set of links in a hypertext document.
16    ///
17    /// An ATK object which encapsulates a link or set of links (for
18    /// instance in the case of client-side image maps) in a hypertext
19    /// document. It may implement the AtkAction interface. AtkHyperlink
20    /// may also be used to refer to inline embedded content, since it
21    /// allows specification of a start and end offset within the host
22    /// AtkHypertext object.
23    ///
24    /// ## Properties
25    ///
26    ///
27    /// #### `end-index`
28    ///  Readable
29    ///
30    ///
31    /// #### `number-of-anchors`
32    ///  Readable
33    ///
34    ///
35    /// #### `selected-link`
36    ///  Selected link
37    ///
38    /// Readable
39    ///
40    ///
41    /// #### `start-index`
42    ///  Readable
43    ///
44    /// ## Signals
45    ///
46    ///
47    /// #### `link-activated`
48    ///  The signal link-activated is emitted when a link is activated.
49    ///
50    ///
51    ///
52    /// # Implements
53    ///
54    /// [`HyperlinkExt`][trait@crate::prelude::HyperlinkExt], [`trait@glib::ObjectExt`], [`AtkActionExt`][trait@crate::prelude::AtkActionExt]
55    #[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
67/// Trait containing all [`struct@Hyperlink`] methods.
68///
69/// # Implementors
70///
71/// [`Hyperlink`][struct@crate::Hyperlink]
72pub trait HyperlinkExt: IsA<Hyperlink> + 'static {
73    /// Gets the index with the hypertext document at which this link ends.
74    ///
75    /// # Returns
76    ///
77    /// the index with the hypertext document at which this link ends
78    #[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    /// Gets the number of anchors associated with this hyperlink.
86    ///
87    /// # Returns
88    ///
89    /// the number of anchors associated with this hyperlink
90    #[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    /// Returns the item associated with this hyperlinks nth anchor.
97    /// For instance, the returned [`Object`][crate::Object] will implement [`Text`][crate::Text]
98    /// if `self` is a text hyperlink, [`Image`][crate::Image] if `self` is an image
99    /// hyperlink etc.
100    ///
101    /// Multiple anchors are primarily used by client-side image maps.
102    /// ## `i`
103    /// a (zero-index) integer specifying the desired anchor
104    ///
105    /// # Returns
106    ///
107    /// an [`Object`][crate::Object] associated with this hyperlinks
108    /// i-th anchor
109    #[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    /// Gets the index with the hypertext document at which this link begins.
121    ///
122    /// # Returns
123    ///
124    /// the index with the hypertext document at which this link begins
125    #[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    /// Get a the URI associated with the anchor specified
133    /// by `i` of `self`.
134    ///
135    /// Multiple anchors are primarily used by client-side image maps.
136    /// ## `i`
137    /// a (zero-index) integer specifying the desired anchor
138    ///
139    /// # Returns
140    ///
141    /// a string specifying the URI
142    #[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    /// Indicates whether the link currently displays some or all of its
154    ///  content inline. Ordinary HTML links will usually return
155    ///  [`false`], but an inline &lt;src&gt; HTML element will return
156    ///  [`true`].
157    ///
158    /// # Returns
159    ///
160    /// whether or not this link displays its content inline.
161    #[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    /// Since the document that a link is associated with may have changed
167    /// this method returns [`true`] if the link is still valid (with
168    /// respect to the document it references) and [`false`] otherwise.
169    ///
170    /// # Returns
171    ///
172    /// whether or not this link is still valid
173    #[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    /// The signal link-activated is emitted when a link is activated.
184    #[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 {}