Skip to content

Commit 223292a

Browse files
committed
pango: Generate new FontColor enum
1 parent 3994d54 commit 223292a

File tree

4 files changed

+136
-13
lines changed

4 files changed

+136
-13
lines changed

pango/Gir.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ generate = [
2020
"Pango.CoverageLevel",
2121
"Pango.Direction",
2222
"Pango.EllipsizeMode",
23+
"Pango.FontColor",
2324
"Pango.FontFace",
2425
"Pango.FontMask",
2526
"Pango.FontMetrics",

pango/src/auto/enums.rs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,120 @@ impl From<EllipsizeMode> for glib::Value {
988988
}
989989
}
990990

991+
#[cfg(feature = "v1_57")]
992+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
993+
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
994+
#[non_exhaustive]
995+
#[doc(alias = "PangoFontColor")]
996+
pub enum FontColor {
997+
#[doc(alias = "PANGO_FONT_COLOR_FORBIDDEN")]
998+
Forbidden,
999+
#[doc(alias = "PANGO_FONT_COLOR_REQUIRED")]
1000+
Required,
1001+
#[doc(alias = "PANGO_FONT_COLOR_DONT_CARE")]
1002+
DontCare,
1003+
#[doc(hidden)]
1004+
__Unknown(i32),
1005+
}
1006+
1007+
#[cfg(feature = "v1_57")]
1008+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1009+
#[doc(hidden)]
1010+
impl IntoGlib for FontColor {
1011+
type GlibType = ffi::PangoFontColor;
1012+
1013+
#[inline]
1014+
fn into_glib(self) -> ffi::PangoFontColor {
1015+
match self {
1016+
Self::Forbidden => ffi::PANGO_FONT_COLOR_FORBIDDEN,
1017+
Self::Required => ffi::PANGO_FONT_COLOR_REQUIRED,
1018+
Self::DontCare => ffi::PANGO_FONT_COLOR_DONT_CARE,
1019+
Self::__Unknown(value) => value,
1020+
}
1021+
}
1022+
}
1023+
1024+
#[cfg(feature = "v1_57")]
1025+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1026+
#[doc(hidden)]
1027+
impl FromGlib<ffi::PangoFontColor> for FontColor {
1028+
#[inline]
1029+
unsafe fn from_glib(value: ffi::PangoFontColor) -> Self {
1030+
match value {
1031+
ffi::PANGO_FONT_COLOR_FORBIDDEN => Self::Forbidden,
1032+
ffi::PANGO_FONT_COLOR_REQUIRED => Self::Required,
1033+
ffi::PANGO_FONT_COLOR_DONT_CARE => Self::DontCare,
1034+
value => Self::__Unknown(value),
1035+
}
1036+
}
1037+
}
1038+
1039+
#[cfg(feature = "v1_57")]
1040+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1041+
impl StaticType for FontColor {
1042+
#[inline]
1043+
#[doc(alias = "pango_font_color_get_type")]
1044+
fn static_type() -> glib::Type {
1045+
unsafe { from_glib(ffi::pango_font_color_get_type()) }
1046+
}
1047+
}
1048+
1049+
#[cfg(feature = "v1_57")]
1050+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1051+
impl glib::HasParamSpec for FontColor {
1052+
type ParamSpec = glib::ParamSpecEnum;
1053+
type SetValue = Self;
1054+
type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
1055+
1056+
fn param_spec_builder() -> Self::BuilderFn {
1057+
Self::ParamSpec::builder_with_default
1058+
}
1059+
}
1060+
1061+
#[cfg(feature = "v1_57")]
1062+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1063+
impl glib::value::ValueType for FontColor {
1064+
type Type = Self;
1065+
}
1066+
1067+
#[cfg(feature = "v1_57")]
1068+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1069+
unsafe impl<'a> glib::value::FromValue<'a> for FontColor {
1070+
type Checker = glib::value::GenericValueTypeChecker<Self>;
1071+
1072+
#[inline]
1073+
unsafe fn from_value(value: &'a glib::Value) -> Self {
1074+
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
1075+
}
1076+
}
1077+
1078+
#[cfg(feature = "v1_57")]
1079+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1080+
impl ToValue for FontColor {
1081+
#[inline]
1082+
fn to_value(&self) -> glib::Value {
1083+
let mut value = glib::Value::for_value_type::<Self>();
1084+
unsafe {
1085+
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
1086+
}
1087+
value
1088+
}
1089+
1090+
#[inline]
1091+
fn value_type(&self) -> glib::Type {
1092+
Self::static_type()
1093+
}
1094+
}
1095+
1096+
#[cfg(feature = "v1_57")]
1097+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
1098+
impl From<FontColor> for glib::Value {
1099+
#[inline]
1100+
fn from(v: FontColor) -> Self {
1101+
ToValue::to_value(&v)
1102+
}
1103+
}
1104+
9911105
#[cfg(feature = "v1_50")]
9921106
#[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
9931107
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]

pango/src/auto/font_description.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

5+
#[cfg(feature = "v1_57")]
6+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
7+
use crate::FontColor;
58
use crate::{ffi, FontMask, Gravity, Stretch, Style, Variant, Weight};
69
use glib::translate::*;
710

@@ -47,13 +50,13 @@ impl FontDescription {
4750
}
4851
}
4952

50-
//#[cfg(feature = "v1_57")]
51-
//#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
52-
//#[doc(alias = "pango_font_description_get_color")]
53-
//#[doc(alias = "get_color")]
54-
//pub fn color(&self) -> /*Ignored*/FontColor {
55-
// unsafe { TODO: call ffi:pango_font_description_get_color() }
56-
//}
53+
#[cfg(feature = "v1_57")]
54+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
55+
#[doc(alias = "pango_font_description_get_color")]
56+
#[doc(alias = "get_color")]
57+
pub fn color(&self) -> FontColor {
58+
unsafe { from_glib(ffi::pango_font_description_get_color(self.to_glib_none().0)) }
59+
}
5760

5861
#[doc(alias = "pango_font_description_get_family")]
5962
#[doc(alias = "get_family")]
@@ -184,12 +187,14 @@ impl FontDescription {
184187
}
185188
}
186189

187-
//#[cfg(feature = "v1_57")]
188-
//#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
189-
//#[doc(alias = "pango_font_description_set_color")]
190-
//pub fn set_color(&mut self, color: /*Ignored*/FontColor) {
191-
// unsafe { TODO: call ffi:pango_font_description_set_color() }
192-
//}
190+
#[cfg(feature = "v1_57")]
191+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
192+
#[doc(alias = "pango_font_description_set_color")]
193+
pub fn set_color(&mut self, color: FontColor) {
194+
unsafe {
195+
ffi::pango_font_description_set_color(self.to_glib_none_mut().0, color.into_glib());
196+
}
197+
}
193198

194199
#[doc(alias = "pango_font_description_set_family")]
195200
pub fn set_family(&mut self, family: &str) {

pango/src/auto/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ pub use self::enums::BidiType;
7979
pub use self::enums::CoverageLevel;
8080
pub use self::enums::Direction;
8181
pub use self::enums::EllipsizeMode;
82+
#[cfg(feature = "v1_57")]
83+
#[cfg_attr(docsrs, doc(cfg(feature = "v1_57")))]
84+
pub use self::enums::FontColor;
8285
#[cfg(feature = "v1_50")]
8386
#[cfg_attr(docsrs, doc(cfg(feature = "v1_50")))]
8487
pub use self::enums::FontScale;

0 commit comments

Comments
 (0)