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::StaticType; 11 use glib::Value; 12 use glib_sys; 13 use gobject_sys; 14 use gtk; 15 use gtk_source_sys; 16 use pango; 17 use std::boxed::Box as Box_; 18 use std::fmt; 19 use std::mem::transmute; 20 use View; 21 22 glib_wrapper! { 23 pub struct Map(Object<gtk_source_sys::GtkSourceMap, gtk_source_sys::GtkSourceMapClass, MapClass>) @extends View, gtk::TextView, gtk::Container, gtk::Widget; 24 25 match fn { 26 get_type => || gtk_source_sys::gtk_source_map_get_type(), 27 } 28 } 29 30 impl Map { new() -> Map31 pub fn new() -> Map { 32 assert_initialized_main_thread!(); 33 unsafe { 34 gtk::Widget::from_glib_none(gtk_source_sys::gtk_source_map_new()).unsafe_cast() 35 } 36 } 37 } 38 39 impl Default for Map { default() -> Self40 fn default() -> Self { 41 Self::new() 42 } 43 } 44 45 pub const NONE_MAP: Option<&Map> = None; 46 47 pub trait MapExt: 'static { get_view(&self) -> Option<View>48 fn get_view(&self) -> Option<View>; 49 set_view<P: IsA<View>>(&self, view: &P)50 fn set_view<P: IsA<View>>(&self, view: &P); 51 get_property_font_desc(&self) -> Option<pango::FontDescription>52 fn get_property_font_desc(&self) -> Option<pango::FontDescription>; 53 set_property_font_desc(&self, font_desc: Option<&pango::FontDescription>)54 fn set_property_font_desc(&self, font_desc: Option<&pango::FontDescription>); 55 connect_property_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId56 fn connect_property_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 57 connect_property_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId58 fn connect_property_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 59 } 60 61 impl<O: IsA<Map>> MapExt for O { get_view(&self) -> Option<View>62 fn get_view(&self) -> Option<View> { 63 unsafe { 64 from_glib_none(gtk_source_sys::gtk_source_map_get_view(self.as_ref().to_glib_none().0)) 65 } 66 } 67 set_view<P: IsA<View>>(&self, view: &P)68 fn set_view<P: IsA<View>>(&self, view: &P) { 69 unsafe { 70 gtk_source_sys::gtk_source_map_set_view(self.as_ref().to_glib_none().0, view.as_ref().to_glib_none().0); 71 } 72 } 73 get_property_font_desc(&self) -> Option<pango::FontDescription>74 fn get_property_font_desc(&self) -> Option<pango::FontDescription> { 75 unsafe { 76 let mut value = Value::from_type(<pango::FontDescription as StaticType>::static_type()); 77 gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"font-desc\0".as_ptr() as *const _, value.to_glib_none_mut().0); 78 value.get().expect("Return Value for property `font-desc` getter") 79 } 80 } 81 set_property_font_desc(&self, font_desc: Option<&pango::FontDescription>)82 fn set_property_font_desc(&self, font_desc: Option<&pango::FontDescription>) { 83 unsafe { 84 gobject_sys::g_object_set_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"font-desc\0".as_ptr() as *const _, Value::from(font_desc).to_glib_none().0); 85 } 86 } 87 connect_property_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId88 fn connect_property_font_desc_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 89 unsafe extern "C" fn notify_font_desc_trampoline<P, F: Fn(&P) + 'static>(this: *mut gtk_source_sys::GtkSourceMap, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer) 90 where P: IsA<Map> 91 { 92 let f: &F = &*(f as *const F); 93 f(&Map::from_glib_borrow(this).unsafe_cast()) 94 } 95 unsafe { 96 let f: Box_<F> = Box_::new(f); 97 connect_raw(self.as_ptr() as *mut _, b"notify::font-desc\0".as_ptr() as *const _, 98 Some(transmute(notify_font_desc_trampoline::<Self, F> as usize)), Box_::into_raw(f)) 99 } 100 } 101 connect_property_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId102 fn connect_property_view_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 103 unsafe extern "C" fn notify_view_trampoline<P, F: Fn(&P) + 'static>(this: *mut gtk_source_sys::GtkSourceMap, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer) 104 where P: IsA<Map> 105 { 106 let f: &F = &*(f as *const F); 107 f(&Map::from_glib_borrow(this).unsafe_cast()) 108 } 109 unsafe { 110 let f: Box_<F> = Box_::new(f); 111 connect_raw(self.as_ptr() as *mut _, b"notify::view\0".as_ptr() as *const _, 112 Some(transmute(notify_view_trampoline::<Self, F> as usize)), Box_::into_raw(f)) 113 } 114 } 115 } 116 117 impl fmt::Display for Map { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result118 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 119 write!(f, "Map") 120 } 121 } 122