pango/auto/
tab_array.rs

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
5use crate::{ffi, TabAlign};
6use glib::translate::*;
7
8glib::wrapper! {
9    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
10    pub struct TabArray(Boxed<ffi::PangoTabArray>);
11
12    match fn {
13        copy => |ptr| ffi::pango_tab_array_copy(mut_override(ptr)),
14        free => |ptr| ffi::pango_tab_array_free(ptr),
15        type_ => || ffi::pango_tab_array_get_type(),
16    }
17}
18
19impl TabArray {
20    #[doc(alias = "pango_tab_array_new")]
21    pub fn new(initial_size: i32, positions_in_pixels: bool) -> TabArray {
22        unsafe {
23            from_glib_full(ffi::pango_tab_array_new(
24                initial_size,
25                positions_in_pixels.into_glib(),
26            ))
27        }
28    }
29
30    //#[doc(alias = "pango_tab_array_new_with_positions")]
31    //#[doc(alias = "new_with_positions")]
32    //pub fn with_positions(size: i32, positions_in_pixels: bool, first_alignment: TabAlign, first_position: i32, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> TabArray {
33    //    unsafe { TODO: call ffi:pango_tab_array_new_with_positions() }
34    //}
35
36    #[cfg(feature = "v1_50")]
37    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
38    #[doc(alias = "pango_tab_array_get_decimal_point")]
39    #[doc(alias = "get_decimal_point")]
40    pub fn decimal_point(&self, tab_index: i32) -> char {
41        unsafe {
42            std::convert::TryFrom::try_from(ffi::pango_tab_array_get_decimal_point(
43                mut_override(self.to_glib_none().0),
44                tab_index,
45            ))
46            .expect("conversion from an invalid Unicode value attempted")
47        }
48    }
49
50    #[doc(alias = "pango_tab_array_get_positions_in_pixels")]
51    #[doc(alias = "get_positions_in_pixels")]
52    pub fn is_positions_in_pixels(&self) -> bool {
53        unsafe {
54            from_glib(ffi::pango_tab_array_get_positions_in_pixels(mut_override(
55                self.to_glib_none().0,
56            )))
57        }
58    }
59
60    #[doc(alias = "pango_tab_array_get_size")]
61    #[doc(alias = "get_size")]
62    pub fn size(&self) -> i32 {
63        unsafe { ffi::pango_tab_array_get_size(mut_override(self.to_glib_none().0)) }
64    }
65
66    #[doc(alias = "pango_tab_array_get_tab")]
67    #[doc(alias = "get_tab")]
68    pub fn tab(&self, tab_index: i32) -> (TabAlign, i32) {
69        unsafe {
70            let mut alignment = std::mem::MaybeUninit::uninit();
71            let mut location = std::mem::MaybeUninit::uninit();
72            ffi::pango_tab_array_get_tab(
73                mut_override(self.to_glib_none().0),
74                tab_index,
75                alignment.as_mut_ptr(),
76                location.as_mut_ptr(),
77            );
78            (from_glib(alignment.assume_init()), location.assume_init())
79        }
80    }
81
82    #[doc(alias = "pango_tab_array_resize")]
83    pub fn resize(&mut self, new_size: i32) {
84        unsafe {
85            ffi::pango_tab_array_resize(self.to_glib_none_mut().0, new_size);
86        }
87    }
88
89    #[cfg(feature = "v1_50")]
90    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
91    #[doc(alias = "pango_tab_array_set_decimal_point")]
92    pub fn set_decimal_point(&mut self, tab_index: i32, decimal_point: char) {
93        unsafe {
94            ffi::pango_tab_array_set_decimal_point(
95                self.to_glib_none_mut().0,
96                tab_index,
97                decimal_point.into_glib(),
98            );
99        }
100    }
101
102    #[cfg(feature = "v1_50")]
103    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
104    #[doc(alias = "pango_tab_array_set_positions_in_pixels")]
105    pub fn set_positions_in_pixels(&mut self, positions_in_pixels: bool) {
106        unsafe {
107            ffi::pango_tab_array_set_positions_in_pixels(
108                self.to_glib_none_mut().0,
109                positions_in_pixels.into_glib(),
110            );
111        }
112    }
113
114    #[doc(alias = "pango_tab_array_set_tab")]
115    pub fn set_tab(&mut self, tab_index: i32, alignment: TabAlign, location: i32) {
116        unsafe {
117            ffi::pango_tab_array_set_tab(
118                self.to_glib_none_mut().0,
119                tab_index,
120                alignment.into_glib(),
121                location,
122            );
123        }
124    }
125
126    #[cfg(feature = "v1_50")]
127    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
128    #[doc(alias = "pango_tab_array_sort")]
129    pub fn sort(&mut self) {
130        unsafe {
131            ffi::pango_tab_array_sort(self.to_glib_none_mut().0);
132        }
133    }
134
135    #[cfg(feature = "v1_50")]
136    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
137    #[doc(alias = "pango_tab_array_to_string")]
138    #[doc(alias = "to_string")]
139    pub fn to_str(&self) -> glib::GString {
140        unsafe {
141            from_glib_full(ffi::pango_tab_array_to_string(mut_override(
142                self.to_glib_none().0,
143            )))
144        }
145    }
146
147    #[cfg(feature = "v1_50")]
148    #[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
149    #[doc(alias = "pango_tab_array_from_string")]
150    pub fn from_string(text: &str) -> Result<TabArray, glib::BoolError> {
151        unsafe {
152            Option::<_>::from_glib_full(ffi::pango_tab_array_from_string(text.to_glib_none().0))
153                .ok_or_else(|| glib::bool_error!("Can't parse a TabArray"))
154        }
155    }
156}
157
158#[cfg(feature = "v1_50")]
159#[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
160impl std::fmt::Display for TabArray {
161    #[inline]
162    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
163        f.write_str(&self.to_str())
164    }
165}
166
167unsafe impl Send for TabArray {}
168unsafe impl Sync for TabArray {}