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

Replace manual enum functions with autogenerated ones #155

Merged
merged 11 commits into from
Dec 7, 2020
Merged
36 changes: 32 additions & 4 deletions atk/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ generate = [
"Atk.Rectangle",
"Atk.Registry",
"Atk.Relation",
"Atk.RelationType",
"Atk.RelationSet",
"Atk.Role",
"Atk.ScrollType",
"Atk.Selection",
"Atk.State",
"Atk.StateType",
"Atk.StateSet",
"Atk.StreamableContent",
"Atk.TableCell",
"Atk.TextAttribute",
"Atk.TextBoundary",
"Atk.TextClipType",
"Atk.TextGranularity",
Expand Down Expand Up @@ -136,3 +132,35 @@ trait_name = "AtkPlugExt"
name = "Atk.Socket"
status = "generate"
trait_name = "AtkSocketExt"

[[object]]
name = "Atk.RelationType"
status = "generate"
[[object.function]]
name = "register"
# Problematic function needs manual implementation
ignore = true

[[object]]
name = "Atk.Role"
status = "generate"
[[object.function]]
name = "register"
# Problematic function needs manual implementation
ignore = true

[[object]]
name = "Atk.StateType"
status = "generate"
[[object.function]]
name = "register"
# Problematic function needs manual implementation
ignore = true

[[object]]
name = "Atk.TextAttribute"
status = "generate"
[[object.function]]
name = "register"
# Problematic function needs manual implementation
ignore = true
70 changes: 70 additions & 0 deletions atk/src/auto/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ pub enum RelationType {
__Unknown(i32),
}

impl RelationType {
pub fn for_name(name: &str) -> RelationType {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::atk_relation_type_for_name(name.to_glib_none().0)) }
}

pub fn get_name(self) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_relation_type_get_name(self.to_glib())) }
}
}

impl fmt::Display for RelationType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
Expand Down Expand Up @@ -469,6 +481,23 @@ pub enum Role {
__Unknown(i32),
}

impl Role {
pub fn for_name(name: &str) -> Role {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::atk_role_for_name(name.to_glib_none().0)) }
}

pub fn get_localized_name(self) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_role_get_localized_name(self.to_glib())) }
}

pub fn get_name(self) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_role_get_name(self.to_glib())) }
}
}

impl fmt::Display for Role {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
Expand Down Expand Up @@ -1069,6 +1098,18 @@ pub enum StateType {
__Unknown(i32),
}

impl StateType {
pub fn for_name(name: &str) -> StateType {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::atk_state_type_for_name(name.to_glib_none().0)) }
}

pub fn get_name(self) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_state_type_get_name(self.to_glib())) }
}
}

impl fmt::Display for StateType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
Expand Down Expand Up @@ -1295,6 +1336,23 @@ pub enum TextAttribute {
__Unknown(i32),
}

impl TextAttribute {
pub fn for_name(name: &str) -> TextAttribute {
assert_initialized_main_thread!();
unsafe { from_glib(ffi::atk_text_attribute_for_name(name.to_glib_none().0)) }
}

pub fn get_name(self) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_text_attribute_get_name(self.to_glib())) }
}

pub fn get_value(self, index_: i32) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_text_attribute_get_value(self.to_glib(), index_)) }
}
}

impl fmt::Display for TextAttribute {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
Expand Down Expand Up @@ -1721,6 +1779,18 @@ pub enum ValueType {
__Unknown(i32),
}

impl ValueType {
pub fn get_localized_name(self) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_value_type_get_localized_name(self.to_glib())) }
}

pub fn get_name(self) -> Option<glib::GString> {
assert_initialized_main_thread!();
unsafe { from_glib_none(ffi::atk_value_type_get_name(self.to_glib())) }
}
}

impl fmt::Display for ValueType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
Expand Down
7 changes: 7 additions & 0 deletions atk/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@ use glib::value::FromValueOptional;
use glib::value::SetValue;
use glib::StaticType;
use glib::Type;
use std::fmt;

bitflags! {
pub struct HyperlinkStateFlags: u32 {
const INLINE = 1;
}
}

impl fmt::Display for HyperlinkStateFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for HyperlinkStateFlags {
type GlibType = ffi::AtkHyperlinkStateFlags;
Expand Down
2 changes: 1 addition & 1 deletion atk/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e941700)
Generated by gir (https://github.com/gtk-rs/gir @ 1c1a8d7)
from gir-files (https://github.com/gtk-rs/gir-files @ 8de1aa1)
2 changes: 1 addition & 1 deletion atk/sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = system_deps::Config::new().probe() {
let _ = eprintln!("{}", s);
println!("cargo:warning={}", s);
process::exit(1);
}
}
2 changes: 1 addition & 1 deletion atk/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e941700)
Generated by gir (https://github.com/gtk-rs/gir @ 1c1a8d7)
from gir-files (https://github.com/gtk-rs/gir-files @ 8de1aa1)
2 changes: 1 addition & 1 deletion cairo/src/surface_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ macro_rules! declare_surface {

impl fmt::Display for $surf_name {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", stringify!($surf_name))
f.write_str(stringify!($surf_name))
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion gdk-pixbuf/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e941700)
Generated by gir (https://github.com/gtk-rs/gir @ 1c1a8d7)
from gir-files (https://github.com/gtk-rs/gir-files @ 8de1aa1)
2 changes: 1 addition & 1 deletion gdk-pixbuf/sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = system_deps::Config::new().probe() {
let _ = eprintln!("{}", s);
println!("cargo:warning={}", s);
process::exit(1);
}
}
2 changes: 1 addition & 1 deletion gdk-pixbuf/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e941700)
Generated by gir (https://github.com/gtk-rs/gir @ 1c1a8d7)
from gir-files (https://github.com/gtk-rs/gir-files @ 8de1aa1)
3 changes: 2 additions & 1 deletion gdk/src/auto/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ impl Display {
}

impl fmt::Display for Display {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Display")
f.write_str(&self.get_name())
}
}
73 changes: 73 additions & 0 deletions gdk/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use glib::value::FromValueOptional;
use glib::value::SetValue;
use glib::StaticType;
use glib::Type;
use std::fmt;

#[cfg(any(feature = "v3_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
Expand All @@ -26,6 +27,14 @@ bitflags! {
}
}

#[cfg(any(feature = "v3_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
impl fmt::Display for AnchorHints {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[cfg(any(feature = "v3_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
#[doc(hidden)]
Expand Down Expand Up @@ -95,6 +104,14 @@ bitflags! {
}
}

#[cfg(any(feature = "v3_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
impl fmt::Display for AxisFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[cfg(any(feature = "v3_22", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))]
#[doc(hidden)]
Expand Down Expand Up @@ -159,6 +176,12 @@ bitflags! {
}
}

impl fmt::Display for DragAction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for DragAction {
type GlibType = ffi::GdkDragAction;
Expand Down Expand Up @@ -231,6 +254,12 @@ bitflags! {
}
}

impl fmt::Display for EventMask {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for EventMask {
type GlibType = ffi::GdkEventMask;
Expand Down Expand Up @@ -285,6 +314,12 @@ bitflags! {
}
}

impl fmt::Display for FrameClockPhase {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for FrameClockPhase {
type GlibType = ffi::GdkFrameClockPhase;
Expand Down Expand Up @@ -363,6 +398,12 @@ bitflags! {
}
}

impl fmt::Display for ModifierType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for ModifierType {
type GlibType = ffi::GdkModifierType;
Expand Down Expand Up @@ -418,6 +459,14 @@ bitflags! {
}
}

#[cfg(any(feature = "v3_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
impl fmt::Display for SeatCapabilities {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[cfg(any(feature = "v3_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
#[doc(hidden)]
Expand Down Expand Up @@ -483,6 +532,12 @@ bitflags! {
}
}

impl fmt::Display for WMDecoration {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for WMDecoration {
type GlibType = ffi::GdkWMDecoration;
Expand Down Expand Up @@ -535,6 +590,12 @@ bitflags! {
}
}

impl fmt::Display for WMFunction {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for WMFunction {
type GlibType = ffi::GdkWMFunction;
Expand Down Expand Up @@ -590,6 +651,12 @@ bitflags! {
}
}

impl fmt::Display for WindowHints {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for WindowHints {
type GlibType = ffi::GdkWindowHints;
Expand Down Expand Up @@ -653,6 +720,12 @@ bitflags! {
}
}

impl fmt::Display for WindowState {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}

#[doc(hidden)]
impl ToGlib for WindowState {
type GlibType = ffi::GdkWindowState;
Expand Down
2 changes: 1 addition & 1 deletion gdk/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e941700)
Generated by gir (https://github.com/gtk-rs/gir @ 1c1a8d7)
from gir-files (https://github.com/gtk-rs/gir-files @ 8de1aa1)
2 changes: 1 addition & 1 deletion gdk/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ e941700)
Generated by gir (https://github.com/gtk-rs/gir @ 1c1a8d7)
from gir-files (https://github.com/gtk-rs/gir-files @ 8de1aa1)
Loading