Skip to main content

sourceview5/auto/
annotation.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{AnnotationStyle, ffi};
7use glib::{
8    prelude::*,
9    signal::{SignalHandlerId, connect_raw},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkSourceAnnotation")]
16    pub struct Annotation(Object<ffi::GtkSourceAnnotation, ffi::GtkSourceAnnotationClass>);
17
18    match fn {
19        type_ => || ffi::gtk_source_annotation_get_type(),
20    }
21}
22
23impl Annotation {
24    #[doc(alias = "gtk_source_annotation_new")]
25    pub fn new(
26        description: Option<&str>,
27        icon: Option<impl IsA<gio::Icon>>,
28        line: i32,
29        style: AnnotationStyle,
30    ) -> Annotation {
31        assert_initialized_main_thread!();
32        unsafe {
33            from_glib_full(ffi::gtk_source_annotation_new(
34                description.to_glib_none().0,
35                icon.map(|p| p.upcast()).into_glib_ptr(),
36                line,
37                style.into_glib(),
38            ))
39        }
40    }
41
42    #[doc(alias = "gtk_source_annotation_get_description")]
43    #[doc(alias = "get_description")]
44    pub fn description(&self) -> glib::GString {
45        unsafe {
46            from_glib_none(ffi::gtk_source_annotation_get_description(
47                self.to_glib_none().0,
48            ))
49        }
50    }
51
52    #[doc(alias = "gtk_source_annotation_get_icon")]
53    #[doc(alias = "get_icon")]
54    pub fn icon(&self) -> Option<gio::Icon> {
55        unsafe { from_glib_none(ffi::gtk_source_annotation_get_icon(self.to_glib_none().0)) }
56    }
57
58    #[doc(alias = "gtk_source_annotation_get_line")]
59    #[doc(alias = "get_line")]
60    pub fn line(&self) -> i32 {
61        unsafe { ffi::gtk_source_annotation_get_line(self.to_glib_none().0) }
62    }
63
64    #[doc(alias = "gtk_source_annotation_get_style")]
65    #[doc(alias = "get_style")]
66    pub fn style(&self) -> AnnotationStyle {
67        unsafe { from_glib(ffi::gtk_source_annotation_get_style(self.to_glib_none().0)) }
68    }
69
70    #[cfg(feature = "v5_18")]
71    #[cfg_attr(docsrs, doc(cfg(feature = "v5_18")))]
72    #[doc(alias = "description")]
73    pub fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
74        unsafe extern "C" fn notify_description_trampoline<F: Fn(&Annotation) + 'static>(
75            this: *mut ffi::GtkSourceAnnotation,
76            _param_spec: glib::ffi::gpointer,
77            f: glib::ffi::gpointer,
78        ) {
79            unsafe {
80                let f: &F = &*(f as *const F);
81                f(&from_glib_borrow(this))
82            }
83        }
84        unsafe {
85            let f: Box_<F> = Box_::new(f);
86            connect_raw(
87                self.as_ptr() as *mut _,
88                c"notify::description".as_ptr(),
89                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
90                    notify_description_trampoline::<F> as *const (),
91                )),
92                Box_::into_raw(f),
93            )
94        }
95    }
96
97    #[cfg(feature = "v5_18")]
98    #[cfg_attr(docsrs, doc(cfg(feature = "v5_18")))]
99    #[doc(alias = "icon")]
100    pub fn connect_icon_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
101        unsafe extern "C" fn notify_icon_trampoline<F: Fn(&Annotation) + 'static>(
102            this: *mut ffi::GtkSourceAnnotation,
103            _param_spec: glib::ffi::gpointer,
104            f: glib::ffi::gpointer,
105        ) {
106            unsafe {
107                let f: &F = &*(f as *const F);
108                f(&from_glib_borrow(this))
109            }
110        }
111        unsafe {
112            let f: Box_<F> = Box_::new(f);
113            connect_raw(
114                self.as_ptr() as *mut _,
115                c"notify::icon".as_ptr(),
116                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
117                    notify_icon_trampoline::<F> as *const (),
118                )),
119                Box_::into_raw(f),
120            )
121        }
122    }
123
124    #[cfg(feature = "v5_18")]
125    #[cfg_attr(docsrs, doc(cfg(feature = "v5_18")))]
126    #[doc(alias = "line")]
127    pub fn connect_line_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
128        unsafe extern "C" fn notify_line_trampoline<F: Fn(&Annotation) + 'static>(
129            this: *mut ffi::GtkSourceAnnotation,
130            _param_spec: glib::ffi::gpointer,
131            f: glib::ffi::gpointer,
132        ) {
133            unsafe {
134                let f: &F = &*(f as *const F);
135                f(&from_glib_borrow(this))
136            }
137        }
138        unsafe {
139            let f: Box_<F> = Box_::new(f);
140            connect_raw(
141                self.as_ptr() as *mut _,
142                c"notify::line".as_ptr(),
143                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
144                    notify_line_trampoline::<F> as *const (),
145                )),
146                Box_::into_raw(f),
147            )
148        }
149    }
150
151    #[cfg(feature = "v5_18")]
152    #[cfg_attr(docsrs, doc(cfg(feature = "v5_18")))]
153    #[doc(alias = "style")]
154    pub fn connect_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
155        unsafe extern "C" fn notify_style_trampoline<F: Fn(&Annotation) + 'static>(
156            this: *mut ffi::GtkSourceAnnotation,
157            _param_spec: glib::ffi::gpointer,
158            f: glib::ffi::gpointer,
159        ) {
160            unsafe {
161                let f: &F = &*(f as *const F);
162                f(&from_glib_borrow(this))
163            }
164        }
165        unsafe {
166            let f: Box_<F> = Box_::new(f);
167            connect_raw(
168                self.as_ptr() as *mut _,
169                c"notify::style".as_ptr(),
170                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
171                    notify_style_trampoline::<F> as *const (),
172                )),
173                Box_::into_raw(f),
174            )
175        }
176    }
177}