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 atk_sys;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::signal::connect_raw;
9use glib::signal::SignalHandlerId;
10use glib::translate::*;
11use glib_sys;
12use libc;
13use std::boxed::Box as Box_;
14use std::fmt;
15use std::mem::transmute;
16use Hyperlink;
17
18glib_wrapper! {
19    pub struct Hypertext(Interface<atk_sys::AtkHypertext>);
20
21    match fn {
22        get_type => || atk_sys::atk_hypertext_get_type(),
23    }
24}
25
26pub const NONE_HYPERTEXT: Option<&Hypertext> = None;
27
28pub trait HypertextExt: 'static {
29    fn get_link(&self, link_index: i32) -> Option<Hyperlink>;
30
31    fn get_link_index(&self, char_index: i32) -> i32;
32
33    fn get_n_links(&self) -> i32;
34
35    fn connect_link_selected<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId;
36}
37
38impl<O: IsA<Hypertext>> HypertextExt for O {
39    fn get_link(&self, link_index: i32) -> Option<Hyperlink> {
40        unsafe {
41            from_glib_none(atk_sys::atk_hypertext_get_link(
42                self.as_ref().to_glib_none().0,
43                link_index,
44            ))
45        }
46    }
47
48    fn get_link_index(&self, char_index: i32) -> i32 {
49        unsafe { atk_sys::atk_hypertext_get_link_index(self.as_ref().to_glib_none().0, char_index) }
50    }
51
52    fn get_n_links(&self) -> i32 {
53        unsafe { atk_sys::atk_hypertext_get_n_links(self.as_ref().to_glib_none().0) }
54    }
55
56    fn connect_link_selected<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
57        unsafe extern "C" fn link_selected_trampoline<P, F: Fn(&P, i32) + 'static>(
58            this: *mut atk_sys::AtkHypertext,
59            arg1: libc::c_int,
60            f: glib_sys::gpointer,
61        ) where
62            P: IsA<Hypertext>,
63        {
64            let f: &F = &*(f as *const F);
65            f(&Hypertext::from_glib_borrow(this).unsafe_cast(), arg1)
66        }
67        unsafe {
68            let f: Box_<F> = Box_::new(f);
69            connect_raw(
70                self.as_ptr() as *mut _,
71                b"link-selected\0".as_ptr() as *const _,
72                Some(transmute(link_selected_trampoline::<Self, F> as usize)),
73                Box_::into_raw(f),
74            )
75        }
76    }
77}
78
79impl fmt::Display for Hypertext {
80    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
81        write!(f, "Hypertext")
82    }
83}