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