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    /// gt; HTML element will return
154    ///  [`true`].
155    ///
156    /// # Returns
157    ///
158    /// whether or not this link displays its content inline.
159    #[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    /// Since the document that a link is associated with may have changed
165    /// this method returns [`true`] if the link is still valid (with
166    /// respect to the document it references) and [`false`] otherwise.
167    ///
168    /// # Returns
169    ///
170    /// whether or not this link is still valid
171    #[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    /// The signal link-activated is emitted when a link is activated.
182    #[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 {}