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