sourceview5/auto/
language.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.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GtkSourceLanguage")]
16    pub struct Language(Object<ffi::GtkSourceLanguage, ffi::GtkSourceLanguageClass>);
17
18    match fn {
19        type_ => || ffi::gtk_source_language_get_type(),
20    }
21}
22
23impl Language {
24    #[doc(alias = "gtk_source_language_get_globs")]
25    #[doc(alias = "get_globs")]
26    pub fn globs(&self) -> Vec<glib::GString> {
27        unsafe {
28            FromGlibPtrContainer::from_glib_full(ffi::gtk_source_language_get_globs(
29                self.to_glib_none().0,
30            ))
31        }
32    }
33
34    #[doc(alias = "gtk_source_language_get_hidden")]
35    #[doc(alias = "get_hidden")]
36    #[doc(alias = "hidden")]
37    pub fn is_hidden(&self) -> bool {
38        unsafe { from_glib(ffi::gtk_source_language_get_hidden(self.to_glib_none().0)) }
39    }
40
41    #[doc(alias = "gtk_source_language_get_id")]
42    #[doc(alias = "get_id")]
43    pub fn id(&self) -> glib::GString {
44        unsafe { from_glib_none(ffi::gtk_source_language_get_id(self.to_glib_none().0)) }
45    }
46
47    #[doc(alias = "gtk_source_language_get_metadata")]
48    #[doc(alias = "get_metadata")]
49    pub fn metadata(&self, name: &str) -> Option<glib::GString> {
50        unsafe {
51            from_glib_none(ffi::gtk_source_language_get_metadata(
52                self.to_glib_none().0,
53                name.to_glib_none().0,
54            ))
55        }
56    }
57
58    #[doc(alias = "gtk_source_language_get_mime_types")]
59    #[doc(alias = "get_mime_types")]
60    pub fn mime_types(&self) -> Vec<glib::GString> {
61        unsafe {
62            FromGlibPtrContainer::from_glib_full(ffi::gtk_source_language_get_mime_types(
63                self.to_glib_none().0,
64            ))
65        }
66    }
67
68    #[doc(alias = "gtk_source_language_get_name")]
69    #[doc(alias = "get_name")]
70    pub fn name(&self) -> glib::GString {
71        unsafe { from_glib_none(ffi::gtk_source_language_get_name(self.to_glib_none().0)) }
72    }
73
74    #[doc(alias = "gtk_source_language_get_section")]
75    #[doc(alias = "get_section")]
76    pub fn section(&self) -> glib::GString {
77        unsafe { from_glib_none(ffi::gtk_source_language_get_section(self.to_glib_none().0)) }
78    }
79
80    #[doc(alias = "gtk_source_language_get_style_fallback")]
81    #[doc(alias = "get_style_fallback")]
82    pub fn style_fallback(&self, style_id: &str) -> Option<glib::GString> {
83        unsafe {
84            from_glib_none(ffi::gtk_source_language_get_style_fallback(
85                self.to_glib_none().0,
86                style_id.to_glib_none().0,
87            ))
88        }
89    }
90
91    #[doc(alias = "gtk_source_language_get_style_ids")]
92    #[doc(alias = "get_style_ids")]
93    pub fn style_ids(&self) -> Vec<glib::GString> {
94        unsafe {
95            FromGlibPtrContainer::from_glib_full(ffi::gtk_source_language_get_style_ids(
96                self.to_glib_none().0,
97            ))
98        }
99    }
100
101    #[doc(alias = "gtk_source_language_get_style_name")]
102    #[doc(alias = "get_style_name")]
103    pub fn style_name(&self, style_id: &str) -> Option<glib::GString> {
104        unsafe {
105            from_glib_none(ffi::gtk_source_language_get_style_name(
106                self.to_glib_none().0,
107                style_id.to_glib_none().0,
108            ))
109        }
110    }
111
112    #[doc(alias = "hidden")]
113    pub fn connect_hidden_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
114        unsafe extern "C" fn notify_hidden_trampoline<F: Fn(&Language) + 'static>(
115            this: *mut ffi::GtkSourceLanguage,
116            _param_spec: glib::ffi::gpointer,
117            f: glib::ffi::gpointer,
118        ) {
119            let f: &F = &*(f as *const F);
120            f(&from_glib_borrow(this))
121        }
122        unsafe {
123            let f: Box_<F> = Box_::new(f);
124            connect_raw(
125                self.as_ptr() as *mut _,
126                c"notify::hidden".as_ptr() as *const _,
127                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
128                    notify_hidden_trampoline::<F> as *const (),
129                )),
130                Box_::into_raw(f),
131            )
132        }
133    }
134
135    #[doc(alias = "id")]
136    pub fn connect_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
137        unsafe extern "C" fn notify_id_trampoline<F: Fn(&Language) + 'static>(
138            this: *mut ffi::GtkSourceLanguage,
139            _param_spec: glib::ffi::gpointer,
140            f: glib::ffi::gpointer,
141        ) {
142            let f: &F = &*(f as *const F);
143            f(&from_glib_borrow(this))
144        }
145        unsafe {
146            let f: Box_<F> = Box_::new(f);
147            connect_raw(
148                self.as_ptr() as *mut _,
149                c"notify::id".as_ptr() as *const _,
150                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
151                    notify_id_trampoline::<F> as *const (),
152                )),
153                Box_::into_raw(f),
154            )
155        }
156    }
157
158    #[doc(alias = "name")]
159    pub fn connect_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
160        unsafe extern "C" fn notify_name_trampoline<F: Fn(&Language) + 'static>(
161            this: *mut ffi::GtkSourceLanguage,
162            _param_spec: glib::ffi::gpointer,
163            f: glib::ffi::gpointer,
164        ) {
165            let f: &F = &*(f as *const F);
166            f(&from_glib_borrow(this))
167        }
168        unsafe {
169            let f: Box_<F> = Box_::new(f);
170            connect_raw(
171                self.as_ptr() as *mut _,
172                c"notify::name".as_ptr() as *const _,
173                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
174                    notify_name_trampoline::<F> as *const (),
175                )),
176                Box_::into_raw(f),
177            )
178        }
179    }
180
181    #[doc(alias = "section")]
182    pub fn connect_section_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
183        unsafe extern "C" fn notify_section_trampoline<F: Fn(&Language) + 'static>(
184            this: *mut ffi::GtkSourceLanguage,
185            _param_spec: glib::ffi::gpointer,
186            f: glib::ffi::gpointer,
187        ) {
188            let f: &F = &*(f as *const F);
189            f(&from_glib_borrow(this))
190        }
191        unsafe {
192            let f: Box_<F> = Box_::new(f);
193            connect_raw(
194                self.as_ptr() as *mut _,
195                c"notify::section".as_ptr() as *const _,
196                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
197                    notify_section_trampoline::<F> as *const (),
198                )),
199                Box_::into_raw(f),
200            )
201        }
202    }
203}
204
205impl std::fmt::Display for Language {
206    #[inline]
207    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
208        f.write_str(&self.name())
209    }
210}