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 crate::AttrType; 6 use crate::Attribute; 7 use glib::translate::*; 8 use std::mem; 9 10 #[cfg(any(feature = "v1_44", feature = "dox"))] 11 #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_44")))] 12 glib::wrapper! { 13 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 14 pub struct AttrIterator(Boxed<ffi::PangoAttrIterator>); 15 16 match fn { 17 copy => |ptr| ffi::pango_attr_iterator_copy(mut_override(ptr)), 18 free => |ptr| ffi::pango_attr_iterator_destroy(ptr), 19 type_ => || ffi::pango_attr_iterator_get_type(), 20 } 21 } 22 23 #[cfg(not(any(feature = "v1_44", feature = "dox")))] 24 glib::wrapper! { 25 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] 26 pub struct AttrIterator(Boxed<ffi::PangoAttrIterator>); 27 28 match fn { 29 copy => |ptr| ffi::pango_attr_iterator_copy(mut_override(ptr)), 30 free => |ptr| ffi::pango_attr_iterator_destroy(ptr), 31 } 32 } 33 34 impl AttrIterator { 35 #[doc(alias = "pango_attr_iterator_get")] get(&mut self, type_: AttrType) -> Option<Attribute>36 pub fn get(&mut self, type_: AttrType) -> Option<Attribute> { 37 unsafe { 38 from_glib_none(ffi::pango_attr_iterator_get( 39 self.to_glib_none_mut().0, 40 type_.into_glib(), 41 )) 42 } 43 } 44 45 #[doc(alias = "pango_attr_iterator_get_attrs")] 46 #[doc(alias = "get_attrs")] attrs(&mut self) -> Vec<Attribute>47 pub fn attrs(&mut self) -> Vec<Attribute> { 48 unsafe { 49 FromGlibPtrContainer::from_glib_full(ffi::pango_attr_iterator_get_attrs( 50 self.to_glib_none_mut().0, 51 )) 52 } 53 } 54 55 #[doc(alias = "pango_attr_iterator_next")] next(&mut self) -> bool56 pub fn next(&mut self) -> bool { 57 unsafe { from_glib(ffi::pango_attr_iterator_next(self.to_glib_none_mut().0)) } 58 } 59 60 #[doc(alias = "pango_attr_iterator_range")] range(&mut self) -> (i32, i32)61 pub fn range(&mut self) -> (i32, i32) { 62 unsafe { 63 let mut start = mem::MaybeUninit::uninit(); 64 let mut end = mem::MaybeUninit::uninit(); 65 ffi::pango_attr_iterator_range( 66 self.to_glib_none_mut().0, 67 start.as_mut_ptr(), 68 end.as_mut_ptr(), 69 ); 70 let start = start.assume_init(); 71 let end = end.assume_init(); 72 (start, end) 73 } 74 } 75 } 76