1use glib::translate::*;
6use std::{fmt, hash};
7
8glib::wrapper! {
9 pub struct RGBA(BoxedInline<ffi::GdkRGBA>);
12
13 match fn {
14 copy => |ptr| ffi::gdk_rgba_copy(ptr),
15 free => |ptr| ffi::gdk_rgba_free(ptr),
16 type_ => || ffi::gdk_rgba_get_type(),
17 }
18}
19
20impl RGBA {
21 #[doc(alias = "gdk_rgba_equal")]
22 fn equal(&self, p2: &RGBA) -> bool {
23 unsafe {
24 from_glib(ffi::gdk_rgba_equal(
25 ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(self).0 as glib::ffi::gconstpointer,
26 ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(p2).0 as glib::ffi::gconstpointer,
27 ))
28 }
29 }
30
31 #[doc(alias = "gdk_rgba_hash")]
32 fn hash(&self) -> u32 {
33 unsafe {
34 ffi::gdk_rgba_hash(
35 ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(self).0 as glib::ffi::gconstpointer,
36 )
37 }
38 }
39
40 #[doc(alias = "gdk_rgba_to_string")]
60 #[doc(alias = "to_string")]
61 pub fn to_str(&self) -> glib::GString {
62 unsafe { from_glib_full(ffi::gdk_rgba_to_string(self.to_glib_none().0)) }
63 }
64}
65
66impl PartialEq for RGBA {
67 #[inline]
68 fn eq(&self, other: &Self) -> bool {
69 self.equal(other)
70 }
71}
72
73impl Eq for RGBA {}
74
75impl fmt::Display for RGBA {
76 #[inline]
77 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
78 f.write_str(&self.to_str())
79 }
80}
81
82impl hash::Hash for RGBA {
83 #[inline]
84 fn hash<H>(&self, state: &mut H)
85 where
86 H: hash::Hasher,
87 {
88 hash::Hash::hash(&self.hash(), state)
89 }
90}