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

Commit

Permalink
Regenerate with automatic enum functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 24, 2020
1 parent 0611ac8 commit 0cd5b44
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 2 deletions.
90 changes: 90 additions & 0 deletions atk/src/auto/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<glib::GString> {
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!(
Expand Down Expand Up @@ -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<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())) }
}

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!(
Expand Down Expand Up @@ -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<glib::GString> {
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!(
Expand Down Expand Up @@ -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<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_)) }
}

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!(
Expand Down Expand Up @@ -1722,6 +1800,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
1 change: 1 addition & 0 deletions atk/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions gdk/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))]
Expand Down
1 change: 1 addition & 0 deletions gio/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions gio/src/auto/unix_mount_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<cmp::Ordering> {
Expand Down
1 change: 1 addition & 0 deletions glib/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))]
Expand Down
2 changes: 2 additions & 0 deletions glib/src/auto/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions glib/src/gobject/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions graphene/src/auto/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
23 changes: 23 additions & 0 deletions gtk/src/auto/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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!(
Expand Down
1 change: 1 addition & 0 deletions gtk/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/auto/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub trait WidgetExt: 'static {

fn create_pango_layout(&self, text: Option<&str>) -> pango::Layout;

//fn destroyed<P: IsA<Widget>>(&self, widget_pointer: &P);
//fn destroyed<P: IsA<Widget>>(&self, widget_pointer: P);

fn device_is_shadowed(&self, device: &gdk::Device) -> bool;

Expand Down Expand Up @@ -1110,7 +1110,7 @@ impl<O: IsA<Widget>> WidgetExt for O {
}
}

//fn destroyed<P: IsA<Widget>>(&self, widget_pointer: &P) {
//fn destroyed<P: IsA<Widget>>(&self, widget_pointer: P) {
// unsafe { TODO: call ffi:gtk_widget_destroyed() }
//}

Expand Down
65 changes: 65 additions & 0 deletions pango/src/auto/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -124,6 +126,16 @@ pub enum AttrType {
__Unknown(i32),
}

impl AttrType {
pub fn get_name(self) -> Option<glib::GString> {
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!(
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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!(
Expand Down Expand Up @@ -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<Language> {
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!(
Expand Down
1 change: 1 addition & 0 deletions pango/src/auto/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0cd5b44

Please sign in to comment.