1use crate::ffi;
6#[cfg(feature = "v1_44")]
7#[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
8use crate::AttrIterator;
9use glib::translate::*;
10
11glib::wrapper! {
12 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
13 pub struct Item(Boxed<ffi::PangoItem>);
14
15 match fn {
16 copy => |ptr| ffi::pango_item_copy(mut_override(ptr)),
17 free => |ptr| ffi::pango_item_free(ptr),
18 type_ => || ffi::pango_item_get_type(),
19 }
20}
21
22impl Item {
23 #[doc(alias = "pango_item_new")]
24 pub fn new() -> Item {
25 unsafe { from_glib_full(ffi::pango_item_new()) }
26 }
27
28 #[cfg(feature = "v1_44")]
29 #[cfg_attr(docsrs, doc(cfg(feature = "v1_44")))]
30 #[doc(alias = "pango_item_apply_attrs")]
31 pub fn apply_attrs(&mut self, iter: &mut AttrIterator) {
32 unsafe {
33 ffi::pango_item_apply_attrs(self.to_glib_none_mut().0, iter.to_glib_none_mut().0);
34 }
35 }
36
37 #[cfg(feature = "v1_54")]
38 #[cfg_attr(docsrs, doc(cfg(feature = "v1_54")))]
39 #[doc(alias = "pango_item_get_char_offset")]
40 #[doc(alias = "get_char_offset")]
41 pub fn char_offset(&self) -> i32 {
42 unsafe { ffi::pango_item_get_char_offset(mut_override(self.to_glib_none().0)) }
43 }
44
45 #[doc(alias = "pango_item_split")]
46 #[must_use]
47 pub fn split(&mut self, split_index: i32, split_offset: i32) -> Item {
48 unsafe {
49 from_glib_full(ffi::pango_item_split(
50 self.to_glib_none_mut().0,
51 split_index,
52 split_offset,
53 ))
54 }
55 }
56}
57
58impl Default for Item {
59 fn default() -> Self {
60 Self::new()
61 }
62}