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
56
57
58
59
60
61
62
63
64
65
66
use AttrIterator;
use Attribute;
use ffi;
use glib::translate::*;
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct AttrList(Shared<ffi::PangoAttrList>);
match fn {
ref => |ptr| ffi::pango_attr_list_ref(ptr),
unref => |ptr| ffi::pango_attr_list_unref(ptr),
get_type => || ffi::pango_attr_list_get_type(),
}
}
impl AttrList {
pub fn new() -> AttrList {
unsafe {
from_glib_full(ffi::pango_attr_list_new())
}
}
pub fn copy(&self) -> Option<AttrList> {
unsafe {
from_glib_full(ffi::pango_attr_list_copy(self.to_glib_none().0))
}
}
pub fn filter<P: FnMut(&Attribute) -> bool>(&self, func: P) -> Option<AttrList> {
let func_data: P = func;
unsafe extern "C" fn func_func<P: FnMut(&Attribute) -> bool>(attribute: *mut ffi::PangoAttribute, user_data: glib_ffi::gpointer) -> glib_ffi::gboolean {
let attribute = from_glib_borrow(attribute);
let callback: *mut P = user_data as *const _ as usize as *mut P;
let res = (*callback)(&attribute);
res.to_glib()
}
let func = Some(func_func::<P> as _);
let super_callback0: &P = &func_data;
unsafe {
from_glib_full(ffi::pango_attr_list_filter(self.to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _))
}
}
pub fn get_iterator(&self) -> Option<AttrIterator> {
unsafe {
from_glib_full(ffi::pango_attr_list_get_iterator(self.to_glib_none().0))
}
}
pub fn splice(&self, other: &AttrList, pos: i32, len: i32) {
unsafe {
ffi::pango_attr_list_splice(self.to_glib_none().0, other.to_glib_none().0, pos, len);
}
}
}
impl Default for AttrList {
fn default() -> Self {
Self::new()
}
}