1use glib::translate::*;
6use glib::GString;
7use pango_sys;
8use std::fmt;
9
10glib_wrapper! {
11 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
12 pub struct Color(Boxed<pango_sys::PangoColor>);
13
14 match fn {
15 copy => |ptr| pango_sys::pango_color_copy(mut_override(ptr)),
16 free => |ptr| pango_sys::pango_color_free(ptr),
17 get_type => || pango_sys::pango_color_get_type(),
18 }
19}
20
21impl Color {
22 pub fn parse(&mut self, spec: &str) -> bool {
23 unsafe {
24 from_glib(pango_sys::pango_color_parse(
25 self.to_glib_none_mut().0,
26 spec.to_glib_none().0,
27 ))
28 }
29 }
30
31 fn to_string(&self) -> GString {
32 unsafe { from_glib_full(pango_sys::pango_color_to_string(self.to_glib_none().0)) }
33 }
34}
35
36impl fmt::Display for Color {
37 #[inline]
38 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
39 write!(f, "{}", self.to_string())
40 }
41}