Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Generate bindings for atk::Live enum with correct version
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 12, 2023
1 parent 56a9bfc commit c44f7e2
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 0 deletions.
5 changes: 5 additions & 0 deletions atk/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ name = "Atk.Image"
status = "generate"
trait_name = "AtkImageExt" # duplicate with gtk

[[object]]
name = "Atk.Live"
status = "generate"
version = "2.50"

[[object]]
name = "Atk.Misc"
status = "generate"
Expand Down
134 changes: 134 additions & 0 deletions atk/src/auto/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,140 @@ impl From<Layer> for glib::Value {
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "AtkLive")]
pub enum Live {
#[doc(alias = "ATK_LIVE_NONE")]
None,
#[doc(alias = "ATK_LIVE_POLITE")]
Polite,
#[doc(alias = "ATK_LIVE_ASSERTIVE")]
Assertive,
#[doc(hidden)]
__Unknown(i32),
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
impl fmt::Display for Live {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"Live::{}",
match *self {
Self::None => "None",
Self::Polite => "Polite",
Self::Assertive => "Assertive",
_ => "Unknown",
}
)
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
#[doc(hidden)]
impl IntoGlib for Live {
type GlibType = ffi::AtkLive;

#[inline]
fn into_glib(self) -> ffi::AtkLive {
match self {
Self::None => ffi::ATK_LIVE_NONE,
Self::Polite => ffi::ATK_LIVE_POLITE,
Self::Assertive => ffi::ATK_LIVE_ASSERTIVE,
Self::__Unknown(value) => value,
}
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
#[doc(hidden)]
impl FromGlib<ffi::AtkLive> for Live {
#[inline]
unsafe fn from_glib(value: ffi::AtkLive) -> Self {
skip_assert_initialized!();

match value {
ffi::ATK_LIVE_NONE => Self::None,
ffi::ATK_LIVE_POLITE => Self::Polite,
ffi::ATK_LIVE_ASSERTIVE => Self::Assertive,
value => Self::__Unknown(value),
}
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
impl StaticType for Live {
#[inline]
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::atk_live_get_type()) }
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
impl glib::HasParamSpec for Live {
type ParamSpec = glib::ParamSpecEnum;
type SetValue = Self;
type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

fn param_spec_builder() -> Self::BuilderFn {
|name, default_value| Self::ParamSpec::builder_with_default(name, default_value)
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
impl glib::value::ValueType for Live {
type Type = Self;
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
unsafe impl<'a> glib::value::FromValue<'a> for Live {
type Checker = glib::value::GenericValueTypeChecker<Self>;

#[inline]
unsafe fn from_value(value: &'a glib::Value) -> Self {
skip_assert_initialized!();
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
impl ToValue for Live {
#[inline]
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
}
value
}

#[inline]
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}

#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
impl From<Live> for glib::Value {
#[inline]
fn from(v: Live) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "AtkRelationType")]
Expand Down
3 changes: 3 additions & 0 deletions atk/src/auto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pub use self::text_range::TextRange;
mod enums;
pub use self::enums::CoordType;
pub use self::enums::Layer;
#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
pub use self::enums::Live;
pub use self::enums::RelationType;
pub use self::enums::Role;
#[cfg(feature = "v2_30")]
Expand Down
5 changes: 5 additions & 0 deletions atk/sys/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ extra_versions = [
"2.38"
]

[[object]]
name = "Atk.Live"
status = "generate"
version = "2.50"

[[object]]
name = "Atk.StateType"
status = "generate"
Expand Down
2 changes: 2 additions & 0 deletions atk/sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,8 @@ extern "C" {
//=========================================================================
// AtkLive
//=========================================================================
#[cfg(feature = "v2_50")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_50")))]
pub fn atk_live_get_type() -> GType;

//=========================================================================
Expand Down

0 comments on commit c44f7e2

Please sign in to comment.