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::translate::*; 6 use glib::GString; 7 use gtk_source_sys; 8 use std::fmt; 9 10 glib_wrapper! { 11 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 12 pub struct Encoding(Boxed<gtk_source_sys::GtkSourceEncoding>); 13 14 match fn { 15 copy => |ptr| gtk_source_sys::gtk_source_encoding_copy(mut_override(ptr)), 16 free => |ptr| gtk_source_sys::gtk_source_encoding_free(ptr), 17 get_type => || gtk_source_sys::gtk_source_encoding_get_type(), 18 } 19 } 20 21 impl Encoding { get_charset(&self) -> Option<GString>22 pub fn get_charset(&self) -> Option<GString> { 23 unsafe { 24 from_glib_none(gtk_source_sys::gtk_source_encoding_get_charset(self.to_glib_none().0)) 25 } 26 } 27 get_name(&self) -> Option<GString>28 pub fn get_name(&self) -> Option<GString> { 29 unsafe { 30 from_glib_none(gtk_source_sys::gtk_source_encoding_get_name(self.to_glib_none().0)) 31 } 32 } 33 to_string(&self) -> GString34 fn to_string(&self) -> GString { 35 unsafe { 36 from_glib_full(gtk_source_sys::gtk_source_encoding_to_string(self.to_glib_none().0)) 37 } 38 } 39 get_all() -> Vec<Encoding>40 pub fn get_all() -> Vec<Encoding> { 41 assert_initialized_main_thread!(); 42 unsafe { 43 FromGlibPtrContainer::from_glib_container(gtk_source_sys::gtk_source_encoding_get_all()) 44 } 45 } 46 get_current() -> Option<Encoding>47 pub fn get_current() -> Option<Encoding> { 48 assert_initialized_main_thread!(); 49 unsafe { 50 from_glib_none(gtk_source_sys::gtk_source_encoding_get_current()) 51 } 52 } 53 get_default_candidates() -> Vec<Encoding>54 pub fn get_default_candidates() -> Vec<Encoding> { 55 assert_initialized_main_thread!(); 56 unsafe { 57 FromGlibPtrContainer::from_glib_container(gtk_source_sys::gtk_source_encoding_get_default_candidates()) 58 } 59 } 60 get_from_charset(charset: &str) -> Option<Encoding>61 pub fn get_from_charset(charset: &str) -> Option<Encoding> { 62 assert_initialized_main_thread!(); 63 unsafe { 64 from_glib_none(gtk_source_sys::gtk_source_encoding_get_from_charset(charset.to_glib_none().0)) 65 } 66 } 67 get_utf8() -> Option<Encoding>68 pub fn get_utf8() -> Option<Encoding> { 69 assert_initialized_main_thread!(); 70 unsafe { 71 from_glib_none(gtk_source_sys::gtk_source_encoding_get_utf8()) 72 } 73 } 74 } 75 76 impl fmt::Display for Encoding { 77 #[inline] fmt(&self, f: &mut fmt::Formatter) -> fmt::Result78 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 79 write!(f, "{}", self.to_string()) 80 } 81 } 82