1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use StateType;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;

glib_wrapper! {
    pub struct StateSet(Object<ffi::AtkStateSet, ffi::AtkStateSetClass, StateSetClass>);

    match fn {
        get_type => || ffi::atk_state_set_get_type(),
    }
}

impl StateSet {
    pub fn new() -> StateSet {
        assert_initialized_main_thread!();
        unsafe {
            from_glib_full(ffi::atk_state_set_new())
        }
    }
}

impl Default for StateSet {
    fn default() -> Self {
        Self::new()
    }
}

pub const NONE_STATE_SET: Option<&StateSet> = None;

pub trait StateSetExt: 'static {
    fn add_state(&self, type_: StateType) -> bool;

    //fn add_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 });

    fn and_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet>;

    fn clear_states(&self);

    fn contains_state(&self, type_: StateType) -> bool;

    //fn contains_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 }) -> bool;

    fn is_empty(&self) -> bool;

    fn or_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet>;

    fn remove_state(&self, type_: StateType) -> bool;

    fn xor_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet>;
}

impl<O: IsA<StateSet>> StateSetExt for O {
    fn add_state(&self, type_: StateType) -> bool {
        unsafe {
            from_glib(ffi::atk_state_set_add_state(self.as_ref().to_glib_none().0, type_.to_glib()))
        }
    }

    //fn add_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 }) {
    //    unsafe { TODO: call ffi::atk_state_set_add_states() }
    //}

    fn and_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet> {
        unsafe {
            from_glib_full(ffi::atk_state_set_and_sets(self.as_ref().to_glib_none().0, compare_set.as_ref().to_glib_none().0))
        }
    }

    fn clear_states(&self) {
        unsafe {
            ffi::atk_state_set_clear_states(self.as_ref().to_glib_none().0);
        }
    }

    fn contains_state(&self, type_: StateType) -> bool {
        unsafe {
            from_glib(ffi::atk_state_set_contains_state(self.as_ref().to_glib_none().0, type_.to_glib()))
        }
    }

    //fn contains_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 }) -> bool {
    //    unsafe { TODO: call ffi::atk_state_set_contains_states() }
    //}

    fn is_empty(&self) -> bool {
        unsafe {
            from_glib(ffi::atk_state_set_is_empty(self.as_ref().to_glib_none().0))
        }
    }

    fn or_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet> {
        unsafe {
            from_glib_full(ffi::atk_state_set_or_sets(self.as_ref().to_glib_none().0, compare_set.as_ref().to_glib_none().0))
        }
    }

    fn remove_state(&self, type_: StateType) -> bool {
        unsafe {
            from_glib(ffi::atk_state_set_remove_state(self.as_ref().to_glib_none().0, type_.to_glib()))
        }
    }

    fn xor_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet> {
        unsafe {
            from_glib_full(ffi::atk_state_set_xor_sets(self.as_ref().to_glib_none().0, compare_set.as_ref().to_glib_none().0))
        }
    }
}

impl fmt::Display for StateSet {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "StateSet")
    }
}