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 
5 use glib::object::Cast;
6 use glib::object::IsA;
7 use glib::signal::connect_raw;
8 use glib::signal::SignalHandlerId;
9 use glib::translate::*;
10 use glib::GString;
11 use glib_sys;
12 use gtk_source_sys;
13 use std::boxed::Box as Box_;
14 use std::fmt;
15 use std::mem::transmute;
16 use Language;
17 
18 glib_wrapper! {
19     pub struct LanguageManager(Object<gtk_source_sys::GtkSourceLanguageManager, gtk_source_sys::GtkSourceLanguageManagerClass, LanguageManagerClass>);
20 
21     match fn {
22         get_type => || gtk_source_sys::gtk_source_language_manager_get_type(),
23     }
24 }
25 
26 impl LanguageManager {
new() -> LanguageManager27     pub fn new() -> LanguageManager {
28         assert_initialized_main_thread!();
29         unsafe {
30             from_glib_full(gtk_source_sys::gtk_source_language_manager_new())
31         }
32     }
33 
get_default() -> Option<LanguageManager>34     pub fn get_default() -> Option<LanguageManager> {
35         assert_initialized_main_thread!();
36         unsafe {
37             from_glib_none(gtk_source_sys::gtk_source_language_manager_get_default())
38         }
39     }
40 }
41 
42 impl Default for LanguageManager {
default() -> Self43     fn default() -> Self {
44         Self::new()
45     }
46 }
47 
48 pub const NONE_LANGUAGE_MANAGER: Option<&LanguageManager> = None;
49 
50 pub trait LanguageManagerExt: 'static {
get_language(&self, id: &str) -> Option<Language>51     fn get_language(&self, id: &str) -> Option<Language>;
52 
get_language_ids(&self) -> Vec<GString>53     fn get_language_ids(&self) -> Vec<GString>;
54 
get_search_path(&self) -> Vec<GString>55     fn get_search_path(&self) -> Vec<GString>;
56 
guess_language(&self, filename: Option<&str>, content_type: Option<&str>) -> Option<Language>57     fn guess_language(&self, filename: Option<&str>, content_type: Option<&str>) -> Option<Language>;
58 
set_search_path(&self, dirs: &[&str])59     fn set_search_path(&self, dirs: &[&str]);
60 
connect_property_language_ids_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId61     fn connect_property_language_ids_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
62 
connect_property_search_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId63     fn connect_property_search_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
64 }
65 
66 impl<O: IsA<LanguageManager>> LanguageManagerExt for O {
get_language(&self, id: &str) -> Option<Language>67     fn get_language(&self, id: &str) -> Option<Language> {
68         unsafe {
69             from_glib_none(gtk_source_sys::gtk_source_language_manager_get_language(self.as_ref().to_glib_none().0, id.to_glib_none().0))
70         }
71     }
72 
get_language_ids(&self) -> Vec<GString>73     fn get_language_ids(&self) -> Vec<GString> {
74         unsafe {
75             FromGlibPtrContainer::from_glib_none(gtk_source_sys::gtk_source_language_manager_get_language_ids(self.as_ref().to_glib_none().0))
76         }
77     }
78 
get_search_path(&self) -> Vec<GString>79     fn get_search_path(&self) -> Vec<GString> {
80         unsafe {
81             FromGlibPtrContainer::from_glib_none(gtk_source_sys::gtk_source_language_manager_get_search_path(self.as_ref().to_glib_none().0))
82         }
83     }
84 
guess_language(&self, filename: Option<&str>, content_type: Option<&str>) -> Option<Language>85     fn guess_language(&self, filename: Option<&str>, content_type: Option<&str>) -> Option<Language> {
86         unsafe {
87             from_glib_none(gtk_source_sys::gtk_source_language_manager_guess_language(self.as_ref().to_glib_none().0, filename.to_glib_none().0, content_type.to_glib_none().0))
88         }
89     }
90 
set_search_path(&self, dirs: &[&str])91     fn set_search_path(&self, dirs: &[&str]) {
92         unsafe {
93             gtk_source_sys::gtk_source_language_manager_set_search_path(self.as_ref().to_glib_none().0, dirs.to_glib_none().0);
94         }
95     }
96 
connect_property_language_ids_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId97     fn connect_property_language_ids_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
98         unsafe extern "C" fn notify_language_ids_trampoline<P, F: Fn(&P) + 'static>(this: *mut gtk_source_sys::GtkSourceLanguageManager, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
99             where P: IsA<LanguageManager>
100         {
101             let f: &F = &*(f as *const F);
102             f(&LanguageManager::from_glib_borrow(this).unsafe_cast())
103         }
104         unsafe {
105             let f: Box_<F> = Box_::new(f);
106             connect_raw(self.as_ptr() as *mut _, b"notify::language-ids\0".as_ptr() as *const _,
107                 Some(transmute(notify_language_ids_trampoline::<Self, F> as usize)), Box_::into_raw(f))
108         }
109     }
110 
connect_property_search_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId111     fn connect_property_search_path_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
112         unsafe extern "C" fn notify_search_path_trampoline<P, F: Fn(&P) + 'static>(this: *mut gtk_source_sys::GtkSourceLanguageManager, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
113             where P: IsA<LanguageManager>
114         {
115             let f: &F = &*(f as *const F);
116             f(&LanguageManager::from_glib_borrow(this).unsafe_cast())
117         }
118         unsafe {
119             let f: Box_<F> = Box_::new(f);
120             connect_raw(self.as_ptr() as *mut _, b"notify::search-path\0".as_ptr() as *const _,
121                 Some(transmute(notify_search_path_trampoline::<Self, F> as usize)), Box_::into_raw(f))
122         }
123     }
124 }
125 
126 impl fmt::Display for LanguageManager {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result127     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
128         write!(f, "LanguageManager")
129     }
130 }
131