Skip to content

Commit 6be5336

Browse files
committed
gtk: Generate new InterfaceContrast / InterfaceColorScheme enums
1 parent 89e9e93 commit 6be5336

File tree

5 files changed

+346
-67
lines changed

5 files changed

+346
-67
lines changed

gtk4/Gir.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ generate = [
148148
"Gtk.InputPurpose",
149149
"Gtk.Inscription",
150150
"Gtk.InscriptionOverflow",
151+
"Gtk.InterfaceColorScheme",
152+
"Gtk.InterfaceContrast",
151153
"Gtk.Justification",
152154
"Gtk.LayoutChild",
153155
"Gtk.LayoutManager",

gtk4/src/auto/css_provider.rs

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
#![allow(deprecated)]
55

66
use crate::{ffi, CssSection, StyleProvider};
7+
#[cfg(feature = "v4_20")]
8+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
9+
use crate::{InterfaceColorScheme, InterfaceContrast};
710
use glib::{
811
object::ObjectType as _,
912
prelude::*,
@@ -117,33 +120,33 @@ impl CssProvider {
117120
unsafe { from_glib_full(ffi::gtk_css_provider_to_string(self.to_glib_none().0)) }
118121
}
119122

120-
//#[cfg(feature = "v4_20")]
121-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
122-
//#[doc(alias = "prefers-color-scheme")]
123-
//pub fn prefers_color_scheme(&self) -> /*Ignored*/InterfaceColorScheme {
124-
// ObjectExt::property(self, "prefers-color-scheme")
125-
//}
123+
#[cfg(feature = "v4_20")]
124+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
125+
#[doc(alias = "prefers-color-scheme")]
126+
pub fn prefers_color_scheme(&self) -> InterfaceColorScheme {
127+
ObjectExt::property(self, "prefers-color-scheme")
128+
}
126129

127-
//#[cfg(feature = "v4_20")]
128-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
129-
//#[doc(alias = "prefers-color-scheme")]
130-
//pub fn set_prefers_color_scheme(&self, prefers_color_scheme: /*Ignored*/InterfaceColorScheme) {
131-
// ObjectExt::set_property(self,"prefers-color-scheme", prefers_color_scheme)
132-
//}
130+
#[cfg(feature = "v4_20")]
131+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
132+
#[doc(alias = "prefers-color-scheme")]
133+
pub fn set_prefers_color_scheme(&self, prefers_color_scheme: InterfaceColorScheme) {
134+
ObjectExt::set_property(self, "prefers-color-scheme", prefers_color_scheme)
135+
}
133136

134-
//#[cfg(feature = "v4_20")]
135-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
136-
//#[doc(alias = "prefers-contrast")]
137-
//pub fn prefers_contrast(&self) -> /*Ignored*/InterfaceContrast {
138-
// ObjectExt::property(self, "prefers-contrast")
139-
//}
137+
#[cfg(feature = "v4_20")]
138+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
139+
#[doc(alias = "prefers-contrast")]
140+
pub fn prefers_contrast(&self) -> InterfaceContrast {
141+
ObjectExt::property(self, "prefers-contrast")
142+
}
140143

141-
//#[cfg(feature = "v4_20")]
142-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
143-
//#[doc(alias = "prefers-contrast")]
144-
//pub fn set_prefers_contrast(&self, prefers_contrast: /*Ignored*/InterfaceContrast) {
145-
// ObjectExt::set_property(self,"prefers-contrast", prefers_contrast)
146-
//}
144+
#[cfg(feature = "v4_20")]
145+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
146+
#[doc(alias = "prefers-contrast")]
147+
pub fn set_prefers_contrast(&self, prefers_contrast: InterfaceContrast) {
148+
ObjectExt::set_property(self, "prefers-contrast", prefers_contrast)
149+
}
147150

148151
#[doc(alias = "parsing-error")]
149152
pub fn connect_parsing_error<F: Fn(&Self, &CssSection, &glib::Error) + 'static>(
@@ -263,17 +266,23 @@ impl CssProviderBuilder {
263266
}
264267
}
265268

266-
// #[cfg(feature = "v4_20")]
269+
#[cfg(feature = "v4_20")]
267270
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
268-
//pub fn prefers_color_scheme(self, prefers_color_scheme: /*Ignored*/InterfaceColorScheme) -> Self {
269-
// Self { builder: self.builder.property("prefers-color-scheme", prefers_color_scheme), }
270-
//}
271+
pub fn prefers_color_scheme(self, prefers_color_scheme: InterfaceColorScheme) -> Self {
272+
Self {
273+
builder: self
274+
.builder
275+
.property("prefers-color-scheme", prefers_color_scheme),
276+
}
277+
}
271278

272-
// #[cfg(feature = "v4_20")]
279+
#[cfg(feature = "v4_20")]
273280
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
274-
//pub fn prefers_contrast(self, prefers_contrast: /*Ignored*/InterfaceContrast) -> Self {
275-
// Self { builder: self.builder.property("prefers-contrast", prefers_contrast), }
276-
//}
281+
pub fn prefers_contrast(self, prefers_contrast: InterfaceContrast) -> Self {
282+
Self {
283+
builder: self.builder.property("prefers-contrast", prefers_contrast),
284+
}
285+
}
277286

278287
// rustdoc-stripper-ignore-next
279288
/// Build the [`CssProvider`].

gtk4/src/auto/enums.rs

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5978,6 +5978,250 @@ impl From<InscriptionOverflow> for glib::Value {
59785978
}
59795979
}
59805980

5981+
#[cfg(feature = "v4_20")]
5982+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
5983+
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
5984+
#[non_exhaustive]
5985+
#[doc(alias = "GtkInterfaceColorScheme")]
5986+
pub enum InterfaceColorScheme {
5987+
#[doc(alias = "GTK_INTERFACE_COLOR_SCHEME_UNSUPPORTED")]
5988+
Unsupported,
5989+
#[doc(alias = "GTK_INTERFACE_COLOR_SCHEME_DEFAULT")]
5990+
Default,
5991+
#[doc(alias = "GTK_INTERFACE_COLOR_SCHEME_DARK")]
5992+
Dark,
5993+
#[doc(alias = "GTK_INTERFACE_COLOR_SCHEME_LIGHT")]
5994+
Light,
5995+
#[doc(hidden)]
5996+
__Unknown(i32),
5997+
}
5998+
5999+
#[cfg(feature = "v4_20")]
6000+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6001+
#[doc(hidden)]
6002+
impl IntoGlib for InterfaceColorScheme {
6003+
type GlibType = ffi::GtkInterfaceColorScheme;
6004+
6005+
#[inline]
6006+
fn into_glib(self) -> ffi::GtkInterfaceColorScheme {
6007+
match self {
6008+
Self::Unsupported => ffi::GTK_INTERFACE_COLOR_SCHEME_UNSUPPORTED,
6009+
Self::Default => ffi::GTK_INTERFACE_COLOR_SCHEME_DEFAULT,
6010+
Self::Dark => ffi::GTK_INTERFACE_COLOR_SCHEME_DARK,
6011+
Self::Light => ffi::GTK_INTERFACE_COLOR_SCHEME_LIGHT,
6012+
Self::__Unknown(value) => value,
6013+
}
6014+
}
6015+
}
6016+
6017+
#[cfg(feature = "v4_20")]
6018+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6019+
#[doc(hidden)]
6020+
impl FromGlib<ffi::GtkInterfaceColorScheme> for InterfaceColorScheme {
6021+
#[inline]
6022+
unsafe fn from_glib(value: ffi::GtkInterfaceColorScheme) -> Self {
6023+
skip_assert_initialized!();
6024+
6025+
match value {
6026+
ffi::GTK_INTERFACE_COLOR_SCHEME_UNSUPPORTED => Self::Unsupported,
6027+
ffi::GTK_INTERFACE_COLOR_SCHEME_DEFAULT => Self::Default,
6028+
ffi::GTK_INTERFACE_COLOR_SCHEME_DARK => Self::Dark,
6029+
ffi::GTK_INTERFACE_COLOR_SCHEME_LIGHT => Self::Light,
6030+
value => Self::__Unknown(value),
6031+
}
6032+
}
6033+
}
6034+
6035+
#[cfg(feature = "v4_20")]
6036+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6037+
impl StaticType for InterfaceColorScheme {
6038+
#[inline]
6039+
#[doc(alias = "gtk_interface_color_scheme_get_type")]
6040+
fn static_type() -> glib::Type {
6041+
unsafe { from_glib(ffi::gtk_interface_color_scheme_get_type()) }
6042+
}
6043+
}
6044+
6045+
#[cfg(feature = "v4_20")]
6046+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6047+
impl glib::HasParamSpec for InterfaceColorScheme {
6048+
type ParamSpec = glib::ParamSpecEnum;
6049+
type SetValue = Self;
6050+
type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
6051+
6052+
fn param_spec_builder() -> Self::BuilderFn {
6053+
Self::ParamSpec::builder_with_default
6054+
}
6055+
}
6056+
6057+
#[cfg(feature = "v4_20")]
6058+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6059+
impl glib::value::ValueType for InterfaceColorScheme {
6060+
type Type = Self;
6061+
}
6062+
6063+
#[cfg(feature = "v4_20")]
6064+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6065+
unsafe impl<'a> glib::value::FromValue<'a> for InterfaceColorScheme {
6066+
type Checker = glib::value::GenericValueTypeChecker<Self>;
6067+
6068+
#[inline]
6069+
unsafe fn from_value(value: &'a glib::Value) -> Self {
6070+
skip_assert_initialized!();
6071+
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
6072+
}
6073+
}
6074+
6075+
#[cfg(feature = "v4_20")]
6076+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6077+
impl ToValue for InterfaceColorScheme {
6078+
#[inline]
6079+
fn to_value(&self) -> glib::Value {
6080+
let mut value = glib::Value::for_value_type::<Self>();
6081+
unsafe {
6082+
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
6083+
}
6084+
value
6085+
}
6086+
6087+
#[inline]
6088+
fn value_type(&self) -> glib::Type {
6089+
Self::static_type()
6090+
}
6091+
}
6092+
6093+
#[cfg(feature = "v4_20")]
6094+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6095+
impl From<InterfaceColorScheme> for glib::Value {
6096+
#[inline]
6097+
fn from(v: InterfaceColorScheme) -> Self {
6098+
skip_assert_initialized!();
6099+
ToValue::to_value(&v)
6100+
}
6101+
}
6102+
6103+
#[cfg(feature = "v4_20")]
6104+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6105+
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
6106+
#[non_exhaustive]
6107+
#[doc(alias = "GtkInterfaceContrast")]
6108+
pub enum InterfaceContrast {
6109+
#[doc(alias = "GTK_INTERFACE_CONTRAST_UNSUPPORTED")]
6110+
Unsupported,
6111+
#[doc(alias = "GTK_INTERFACE_CONTRAST_NO_PREFERENCE")]
6112+
NoPreference,
6113+
#[doc(alias = "GTK_INTERFACE_CONTRAST_MORE")]
6114+
More,
6115+
#[doc(alias = "GTK_INTERFACE_CONTRAST_LESS")]
6116+
Less,
6117+
#[doc(hidden)]
6118+
__Unknown(i32),
6119+
}
6120+
6121+
#[cfg(feature = "v4_20")]
6122+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6123+
#[doc(hidden)]
6124+
impl IntoGlib for InterfaceContrast {
6125+
type GlibType = ffi::GtkInterfaceContrast;
6126+
6127+
#[inline]
6128+
fn into_glib(self) -> ffi::GtkInterfaceContrast {
6129+
match self {
6130+
Self::Unsupported => ffi::GTK_INTERFACE_CONTRAST_UNSUPPORTED,
6131+
Self::NoPreference => ffi::GTK_INTERFACE_CONTRAST_NO_PREFERENCE,
6132+
Self::More => ffi::GTK_INTERFACE_CONTRAST_MORE,
6133+
Self::Less => ffi::GTK_INTERFACE_CONTRAST_LESS,
6134+
Self::__Unknown(value) => value,
6135+
}
6136+
}
6137+
}
6138+
6139+
#[cfg(feature = "v4_20")]
6140+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6141+
#[doc(hidden)]
6142+
impl FromGlib<ffi::GtkInterfaceContrast> for InterfaceContrast {
6143+
#[inline]
6144+
unsafe fn from_glib(value: ffi::GtkInterfaceContrast) -> Self {
6145+
skip_assert_initialized!();
6146+
6147+
match value {
6148+
ffi::GTK_INTERFACE_CONTRAST_UNSUPPORTED => Self::Unsupported,
6149+
ffi::GTK_INTERFACE_CONTRAST_NO_PREFERENCE => Self::NoPreference,
6150+
ffi::GTK_INTERFACE_CONTRAST_MORE => Self::More,
6151+
ffi::GTK_INTERFACE_CONTRAST_LESS => Self::Less,
6152+
value => Self::__Unknown(value),
6153+
}
6154+
}
6155+
}
6156+
6157+
#[cfg(feature = "v4_20")]
6158+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6159+
impl StaticType for InterfaceContrast {
6160+
#[inline]
6161+
#[doc(alias = "gtk_interface_contrast_get_type")]
6162+
fn static_type() -> glib::Type {
6163+
unsafe { from_glib(ffi::gtk_interface_contrast_get_type()) }
6164+
}
6165+
}
6166+
6167+
#[cfg(feature = "v4_20")]
6168+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6169+
impl glib::HasParamSpec for InterfaceContrast {
6170+
type ParamSpec = glib::ParamSpecEnum;
6171+
type SetValue = Self;
6172+
type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;
6173+
6174+
fn param_spec_builder() -> Self::BuilderFn {
6175+
Self::ParamSpec::builder_with_default
6176+
}
6177+
}
6178+
6179+
#[cfg(feature = "v4_20")]
6180+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6181+
impl glib::value::ValueType for InterfaceContrast {
6182+
type Type = Self;
6183+
}
6184+
6185+
#[cfg(feature = "v4_20")]
6186+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6187+
unsafe impl<'a> glib::value::FromValue<'a> for InterfaceContrast {
6188+
type Checker = glib::value::GenericValueTypeChecker<Self>;
6189+
6190+
#[inline]
6191+
unsafe fn from_value(value: &'a glib::Value) -> Self {
6192+
skip_assert_initialized!();
6193+
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
6194+
}
6195+
}
6196+
6197+
#[cfg(feature = "v4_20")]
6198+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6199+
impl ToValue for InterfaceContrast {
6200+
#[inline]
6201+
fn to_value(&self) -> glib::Value {
6202+
let mut value = glib::Value::for_value_type::<Self>();
6203+
unsafe {
6204+
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
6205+
}
6206+
value
6207+
}
6208+
6209+
#[inline]
6210+
fn value_type(&self) -> glib::Type {
6211+
Self::static_type()
6212+
}
6213+
}
6214+
6215+
#[cfg(feature = "v4_20")]
6216+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
6217+
impl From<InterfaceContrast> for glib::Value {
6218+
#[inline]
6219+
fn from(v: InterfaceContrast) -> Self {
6220+
skip_assert_initialized!();
6221+
ToValue::to_value(&v)
6222+
}
6223+
}
6224+
59816225
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
59826226
#[non_exhaustive]
59836227
#[doc(alias = "GtkJustification")]

gtk4/src/auto/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,12 @@ pub use self::enums::InputPurpose;
12061206
#[cfg(feature = "v4_8")]
12071207
#[cfg_attr(docsrs, doc(cfg(feature = "v4_8")))]
12081208
pub use self::enums::InscriptionOverflow;
1209+
#[cfg(feature = "v4_20")]
1210+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1211+
pub use self::enums::InterfaceColorScheme;
1212+
#[cfg(feature = "v4_20")]
1213+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
1214+
pub use self::enums::InterfaceContrast;
12091215
pub use self::enums::Justification;
12101216
pub use self::enums::LevelBarMode;
12111217
pub use self::enums::License;

0 commit comments

Comments
 (0)