Skip to main content

pango/auto/
color.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;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// The [`Color`][crate::Color] structure is used to
10    /// represent a color in an uncalibrated RGB color-space.
11    pub struct Color(BoxedInline<ffi::PangoColor>);
12
13    match fn {
14        copy => |ptr| ffi::pango_color_copy(ptr),
15        free => |ptr| ffi::pango_color_free(ptr),
16        type_ => || ffi::pango_color_get_type(),
17    }
18}
19
20impl Color {
21    /// Returns a textual specification of @self.
22    ///
23    /// The string is in the hexadecimal form `#rrrrggggbbbb`,
24    /// where `r`, `g` and `b` are hex digits representing the
25    /// red, green, and blue components respectively.
26    ///
27    /// # Returns
28    ///
29    /// a newly-allocated text string that must
30    ///   be freed with g_free().
31    #[doc(alias = "pango_color_to_string")]
32    #[doc(alias = "to_string")]
33    pub fn to_str(&self) -> glib::GString {
34        unsafe { from_glib_full(ffi::pango_color_to_string(self.to_glib_none().0)) }
35    }
36}
37
38impl std::fmt::Display for Color {
39    #[inline]
40    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
41        f.write_str(&self.to_str())
42    }
43}