atk/auto/hypertext.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::{Hyperlink, 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 /// The ATK interface which provides standard mechanism for manipulating hyperlinks.
16 ///
17 /// An interface used for objects which implement linking between
18 /// multiple resource or content locations, or multiple 'markers'
19 /// within a single document. A Hypertext instance is associated with
20 /// one or more Hyperlinks, which are associated with particular
21 /// offsets within the Hypertext's included content. While this
22 /// interface is derived from Text, there is no requirement that
23 /// Hypertext instances have textual content; they may implement Image
24 /// as well, and Hyperlinks need not have non-zero text offsets.
25 ///
26 /// ## Signals
27 ///
28 ///
29 /// #### `link-selected`
30 /// The "link-selected" signal is emitted by an AtkHyperText
31 /// object when one of the hyperlinks associated with the object
32 /// is selected.
33 ///
34 ///
35 ///
36 /// # Implements
37 ///
38 /// [`HypertextExt`][trait@crate::prelude::HypertextExt]
39 #[doc(alias = "AtkHypertext")]
40 pub struct Hypertext(Interface<ffi::AtkHypertext, ffi::AtkHypertextIface>);
41
42 match fn {
43 type_ => || ffi::atk_hypertext_get_type(),
44 }
45}
46
47impl Hypertext {
48 pub const NONE: Option<&'static Hypertext> = None;
49}
50
51/// Trait containing all [`struct@Hypertext`] methods.
52///
53/// # Implementors
54///
55/// [`Hypertext`][struct@crate::Hypertext], [`NoOpObject`][struct@crate::NoOpObject]
56pub trait HypertextExt: IsA<Hypertext> + 'static {
57 /// Gets the link in this hypertext document at index
58 /// `link_index`
59 /// ## `link_index`
60 /// an integer specifying the desired link
61 ///
62 /// # Returns
63 ///
64 /// the link in this hypertext document at
65 /// index `link_index`
66 #[doc(alias = "atk_hypertext_get_link")]
67 #[doc(alias = "get_link")]
68 fn link(&self, link_index: i32) -> Option<Hyperlink> {
69 unsafe {
70 from_glib_none(ffi::atk_hypertext_get_link(
71 self.as_ref().to_glib_none().0,
72 link_index,
73 ))
74 }
75 }
76
77 /// Gets the index into the array of hyperlinks that is associated with
78 /// the character specified by `char_index`.
79 /// ## `char_index`
80 /// a character index
81 ///
82 /// # Returns
83 ///
84 /// an index into the array of hyperlinks in `self`,
85 /// or -1 if there is no hyperlink associated with this character.
86 #[doc(alias = "atk_hypertext_get_link_index")]
87 #[doc(alias = "get_link_index")]
88 fn link_index(&self, char_index: i32) -> i32 {
89 unsafe { ffi::atk_hypertext_get_link_index(self.as_ref().to_glib_none().0, char_index) }
90 }
91
92 /// Gets the number of links within this hypertext document.
93 ///
94 /// # Returns
95 ///
96 /// the number of links within this hypertext document
97 #[doc(alias = "atk_hypertext_get_n_links")]
98 #[doc(alias = "get_n_links")]
99 fn n_links(&self) -> i32 {
100 unsafe { ffi::atk_hypertext_get_n_links(self.as_ref().to_glib_none().0) }
101 }
102
103 /// The "link-selected" signal is emitted by an AtkHyperText
104 /// object when one of the hyperlinks associated with the object
105 /// is selected.
106 /// ## `arg1`
107 /// the index of the hyperlink which is selected
108 #[doc(alias = "link-selected")]
109 fn connect_link_selected<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
110 unsafe extern "C" fn link_selected_trampoline<
111 P: IsA<Hypertext>,
112 F: Fn(&P, i32) + 'static,
113 >(
114 this: *mut ffi::AtkHypertext,
115 arg1: std::ffi::c_int,
116 f: glib::ffi::gpointer,
117 ) {
118 unsafe {
119 let f: &F = &*(f as *const F);
120 f(Hypertext::from_glib_borrow(this).unsafe_cast_ref(), arg1)
121 }
122 }
123 unsafe {
124 let f: Box_<F> = Box_::new(f);
125 connect_raw(
126 self.as_ptr() as *mut _,
127 c"link-selected".as_ptr(),
128 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
129 link_selected_trampoline::<Self, F> as *const (),
130 )),
131 Box_::into_raw(f),
132 )
133 }
134 }
135}
136
137impl<O: IsA<Hypertext>> HypertextExt for O {}