From 0cd5b44ee20e441293bfccd07bf1d573f18422bd Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Wed, 18 Nov 2020 19:45:23 +0100 Subject: [PATCH] Regenerate with automatic enum functions --- atk/src/auto/enums.rs | 90 ++++++++++++++++++++++++++++++++ atk/src/auto/flags.rs | 1 + gdk/src/auto/flags.rs | 1 + gio/src/auto/flags.rs | 1 + gio/src/auto/unix_mount_point.rs | 4 ++ glib/src/auto/flags.rs | 1 + glib/src/auto/uri.rs | 2 + glib/src/gobject/auto/flags.rs | 1 + graphene/src/auto/matrix.rs | 2 + gtk/src/auto/enums.rs | 23 ++++++++ gtk/src/auto/flags.rs | 1 + gtk/src/auto/widget.rs | 4 +- pango/src/auto/enums.rs | 65 +++++++++++++++++++++++ pango/src/auto/flags.rs | 1 + 14 files changed, 195 insertions(+), 2 deletions(-) diff --git a/atk/src/auto/enums.rs b/atk/src/auto/enums.rs index d8dcbce77c23..0295d99052b6 100644 --- a/atk/src/auto/enums.rs +++ b/atk/src/auto/enums.rs @@ -212,6 +212,23 @@ 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 { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::atk_relation_type_get_name(self.to_glib())) } + } + + pub fn register(name: &str) -> RelationType { + assert_initialized_main_thread!(); + unsafe { from_glib(ffi::atk_relation_type_register(name.to_glib_none().0)) } + } +} + impl fmt::Display for RelationType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( @@ -470,6 +487,28 @@ 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 { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::atk_role_get_localized_name(self.to_glib())) } + } + + pub fn get_name(self) -> Option { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::atk_role_get_name(self.to_glib())) } + } + + pub fn register(name: &str) -> Role { + assert_initialized_main_thread!(); + unsafe { from_glib(ffi::atk_role_register(name.to_glib_none().0)) } + } +} + impl fmt::Display for Role { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( @@ -1070,6 +1109,23 @@ 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 { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::atk_state_type_get_name(self.to_glib())) } + } + + pub fn register(name: &str) -> StateType { + assert_initialized_main_thread!(); + unsafe { from_glib(ffi::atk_state_type_register(name.to_glib_none().0)) } + } +} + impl fmt::Display for StateType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( @@ -1296,6 +1352,28 @@ 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 { + 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 { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::atk_text_attribute_get_value(self.to_glib(), index_)) } + } + + pub fn register(name: &str) -> TextAttribute { + assert_initialized_main_thread!(); + unsafe { from_glib(ffi::atk_text_attribute_register(name.to_glib_none().0)) } + } +} + impl fmt::Display for TextAttribute { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( @@ -1722,6 +1800,18 @@ pub enum ValueType { __Unknown(i32), } +impl ValueType { + pub fn get_localized_name(self) -> Option { + assert_initialized_main_thread!(); + unsafe { from_glib_none(ffi::atk_value_type_get_localized_name(self.to_glib())) } + } + + pub fn get_name(self) -> Option { + 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!( diff --git a/atk/src/auto/flags.rs b/atk/src/auto/flags.rs index 2c754dae1d90..f9d4f288a8fb 100644 --- a/atk/src/auto/flags.rs +++ b/atk/src/auto/flags.rs @@ -10,6 +10,7 @@ use glib::value::SetValue; use glib::value::Value; use glib::StaticType; use glib::Type; +use std::fmt; bitflags! { pub struct HyperlinkStateFlags: u32 { diff --git a/gdk/src/auto/flags.rs b/gdk/src/auto/flags.rs index 4d11f5380f1c..751a2c12440c 100644 --- a/gdk/src/auto/flags.rs +++ b/gdk/src/auto/flags.rs @@ -10,6 +10,7 @@ use glib::value::SetValue; use glib::value::Value; 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")))] diff --git a/gio/src/auto/flags.rs b/gio/src/auto/flags.rs index 77f52f24ed5d..86db63e78a8d 100644 --- a/gio/src/auto/flags.rs +++ b/gio/src/auto/flags.rs @@ -10,6 +10,7 @@ use glib::value::SetValue; use glib::value::Value; use glib::StaticType; use glib::Type; +use std::fmt; bitflags! { pub struct AppInfoCreateFlags: u32 { diff --git a/gio/src/auto/unix_mount_point.rs b/gio/src/auto/unix_mount_point.rs index 2ae45665b725..41ab6897cb1d 100644 --- a/gio/src/auto/unix_mount_point.rs +++ b/gio/src/auto/unix_mount_point.rs @@ -161,6 +161,8 @@ impl UnixMountPoint { } } +#[cfg(any(feature = "v2_54", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_54")))] impl PartialEq for UnixMountPoint { #[inline] fn eq(&self, other: &Self) -> bool { @@ -170,6 +172,8 @@ impl PartialEq for UnixMountPoint { impl Eq for UnixMountPoint {} +#[cfg(any(feature = "v2_54", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_54")))] impl PartialOrd for UnixMountPoint { #[inline] fn partial_cmp(&self, other: &Self) -> Option { diff --git a/glib/src/auto/flags.rs b/glib/src/auto/flags.rs index 76acf034b137..296369f6a193 100644 --- a/glib/src/auto/flags.rs +++ b/glib/src/auto/flags.rs @@ -10,6 +10,7 @@ use crate::value::Value; use crate::StaticType; use crate::Type; use bitflags::bitflags; +use std::fmt; #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] diff --git a/glib/src/auto/uri.rs b/glib/src/auto/uri.rs index 4cde69db2fef..e19bc1bfd7d7 100644 --- a/glib/src/auto/uri.rs +++ b/glib/src/auto/uri.rs @@ -547,6 +547,8 @@ impl Uri { } } +#[cfg(any(feature = "v2_66", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] impl fmt::Display for Uri { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/glib/src/gobject/auto/flags.rs b/glib/src/gobject/auto/flags.rs index 00a5bc9b7fff..b5635ae32f23 100644 --- a/glib/src/gobject/auto/flags.rs +++ b/glib/src/gobject/auto/flags.rs @@ -11,6 +11,7 @@ use crate::value::Value; use crate::StaticType; use crate::Type; use bitflags::bitflags; +use std::fmt; bitflags! { pub struct BindingFlags: u32 { diff --git a/graphene/src/auto/matrix.rs b/graphene/src/auto/matrix.rs index 5fa4acdc37e5..7478e4325c87 100644 --- a/graphene/src/auto/matrix.rs +++ b/graphene/src/auto/matrix.rs @@ -645,6 +645,8 @@ impl Matrix { } } +#[cfg(any(feature = "v1_10", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_10")))] impl PartialEq for Matrix { #[inline] fn eq(&self, other: &Self) -> bool { diff --git a/gtk/src/auto/enums.rs b/gtk/src/auto/enums.rs index c37e9ccde3f5..812dbe139c27 100644 --- a/gtk/src/auto/enums.rs +++ b/gtk/src/auto/enums.rs @@ -12,6 +12,7 @@ use glib::Quark; use glib::StaticType; use glib::Type; use std::fmt; +use std::mem; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] @@ -2164,6 +2165,28 @@ pub enum IconSize { __Unknown(i32), } +impl IconSize { + pub fn lookup(self) -> Option<(i32, i32)> { + assert_initialized_main_thread!(); + unsafe { + let mut width = mem::MaybeUninit::uninit(); + let mut height = mem::MaybeUninit::uninit(); + let ret = from_glib(ffi::gtk_icon_size_lookup( + self.to_glib(), + width.as_mut_ptr(), + height.as_mut_ptr(), + )); + let width = width.assume_init(); + let height = height.assume_init(); + if ret { + Some((width, height)) + } else { + None + } + } + } +} + impl fmt::Display for IconSize { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( diff --git a/gtk/src/auto/flags.rs b/gtk/src/auto/flags.rs index 52f90507ef01..0726954ab190 100644 --- a/gtk/src/auto/flags.rs +++ b/gtk/src/auto/flags.rs @@ -10,6 +10,7 @@ use glib::value::SetValue; use glib::value::Value; use glib::StaticType; use glib::Type; +use std::fmt; bitflags! { pub struct AccelFlags: u32 { diff --git a/gtk/src/auto/widget.rs b/gtk/src/auto/widget.rs index 80300312ed68..bc6068cb50d3 100644 --- a/gtk/src/auto/widget.rs +++ b/gtk/src/auto/widget.rs @@ -92,7 +92,7 @@ pub trait WidgetExt: 'static { fn create_pango_layout(&self, text: Option<&str>) -> pango::Layout; - //fn destroyed>(&self, widget_pointer: &P); + //fn destroyed>(&self, widget_pointer: P); fn device_is_shadowed(&self, device: &gdk::Device) -> bool; @@ -1110,7 +1110,7 @@ impl> WidgetExt for O { } } - //fn destroyed>(&self, widget_pointer: &P) { + //fn destroyed>(&self, widget_pointer: P) { // unsafe { TODO: call ffi:gtk_widget_destroyed() } //} diff --git a/pango/src/auto/enums.rs b/pango/src/auto/enums.rs index 0b26ce86fa15..3ecad8d705b7 100644 --- a/pango/src/auto/enums.rs +++ b/pango/src/auto/enums.rs @@ -2,6 +2,8 @@ // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT +use crate::Language; +use crate::Matrix; use glib::translate::*; use glib::value::FromValue; use glib::value::FromValueOptional; @@ -124,6 +126,16 @@ pub enum AttrType { __Unknown(i32), } +impl AttrType { + pub fn get_name(self) -> Option { + unsafe { from_glib_none(ffi::pango_attr_type_get_name(self.to_glib())) } + } + + pub fn register(name: &str) -> AttrType { + unsafe { from_glib(ffi::pango_attr_type_register(name.to_glib_none().0)) } + } +} + impl fmt::Display for AttrType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( @@ -300,6 +312,12 @@ pub enum BidiType { __Unknown(i32), } +impl BidiType { + pub fn for_unichar(ch: char) -> BidiType { + unsafe { from_glib(ffi::pango_bidi_type_for_unichar(ch.to_glib())) } + } +} + impl fmt::Display for BidiType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( @@ -674,6 +692,42 @@ pub enum Gravity { __Unknown(i32), } +impl Gravity { + pub fn get_for_matrix(matrix: Option<&Matrix>) -> Gravity { + unsafe { from_glib(ffi::pango_gravity_get_for_matrix(matrix.to_glib_none().0)) } + } + + pub fn get_for_script(script: Script, base_gravity: Gravity, hint: GravityHint) -> Gravity { + unsafe { + from_glib(ffi::pango_gravity_get_for_script( + script.to_glib(), + base_gravity.to_glib(), + hint.to_glib(), + )) + } + } + + pub fn get_for_script_and_width( + script: Script, + wide: bool, + base_gravity: Gravity, + hint: GravityHint, + ) -> Gravity { + unsafe { + from_glib(ffi::pango_gravity_get_for_script_and_width( + script.to_glib(), + wide.to_glib(), + base_gravity.to_glib(), + hint.to_glib(), + )) + } + } + + pub fn to_rotation(self) -> f64 { + unsafe { ffi::pango_gravity_to_rotation(self.to_glib()) } + } +} + impl fmt::Display for Gravity { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( @@ -1115,6 +1169,17 @@ pub enum Script { __Unknown(i32), } +impl Script { + #[cfg_attr(feature = "v1_44", deprecated)] + pub fn for_unichar(ch: char) -> Script { + unsafe { from_glib(ffi::pango_script_for_unichar(ch.to_glib())) } + } + + pub fn get_sample_language(self) -> Option { + unsafe { from_glib_full(ffi::pango_script_get_sample_language(self.to_glib())) } + } +} + impl fmt::Display for Script { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( diff --git a/pango/src/auto/flags.rs b/pango/src/auto/flags.rs index b3084771036c..33e05710dab6 100644 --- a/pango/src/auto/flags.rs +++ b/pango/src/auto/flags.rs @@ -10,6 +10,7 @@ use glib::value::SetValue; use glib::value::Value; use glib::StaticType; use glib::Type; +use std::fmt; bitflags! { pub struct FontMask: u32 {