1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use glib::translate::*;
use pango_sys;
use std::mem;
use AttrType;
use Attribute;

glib_wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct AttrIterator(Boxed<pango_sys::PangoAttrIterator>);

    match fn {
        copy => |ptr| pango_sys::pango_attr_iterator_copy(mut_override(ptr)),
        free => |ptr| pango_sys::pango_attr_iterator_destroy(ptr),
    }
}

impl AttrIterator {
    pub fn get(&mut self, type_: AttrType) -> Option<Attribute> {
        unsafe {
            from_glib_none(pango_sys::pango_attr_iterator_get(
                self.to_glib_none_mut().0,
                type_.to_glib(),
            ))
        }
    }

    pub fn get_attrs(&mut self) -> Vec<Attribute> {
        unsafe {
            FromGlibPtrContainer::from_glib_full(pango_sys::pango_attr_iterator_get_attrs(
                self.to_glib_none_mut().0,
            ))
        }
    }

    pub fn next(&mut self) -> bool {
        unsafe {
            from_glib(pango_sys::pango_attr_iterator_next(
                self.to_glib_none_mut().0,
            ))
        }
    }

    pub fn range(&mut self) -> (i32, i32) {
        unsafe {
            let mut start = mem::uninitialized();
            let mut end = mem::uninitialized();
            pango_sys::pango_attr_iterator_range(self.to_glib_none_mut().0, &mut start, &mut end);
            (start, end)
        }
    }
}