atk/auto/
state_set.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use atk_sys;
6use glib::object::IsA;
7use glib::translate::*;
8use std::fmt;
9use StateType;
10
11glib_wrapper! {
12    pub struct StateSet(Object<atk_sys::AtkStateSet, atk_sys::AtkStateSetClass, StateSetClass>);
13
14    match fn {
15        get_type => || atk_sys::atk_state_set_get_type(),
16    }
17}
18
19impl StateSet {
20    pub fn new() -> StateSet {
21        assert_initialized_main_thread!();
22        unsafe { from_glib_full(atk_sys::atk_state_set_new()) }
23    }
24}
25
26impl Default for StateSet {
27    fn default() -> Self {
28        Self::new()
29    }
30}
31
32pub const NONE_STATE_SET: Option<&StateSet> = None;
33
34pub trait StateSetExt: 'static {
35    fn add_state(&self, type_: StateType) -> bool;
36
37    //fn add_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 });
38
39    fn and_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet>;
40
41    fn clear_states(&self);
42
43    fn contains_state(&self, type_: StateType) -> bool;
44
45    //fn contains_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 }) -> bool;
46
47    fn is_empty(&self) -> bool;
48
49    fn or_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet>;
50
51    fn remove_state(&self, type_: StateType) -> bool;
52
53    fn xor_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet>;
54}
55
56impl<O: IsA<StateSet>> StateSetExt for O {
57    fn add_state(&self, type_: StateType) -> bool {
58        unsafe {
59            from_glib(atk_sys::atk_state_set_add_state(
60                self.as_ref().to_glib_none().0,
61                type_.to_glib(),
62            ))
63        }
64    }
65
66    //fn add_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 }) {
67    //    unsafe { TODO: call atk_sys:atk_state_set_add_states() }
68    //}
69
70    fn and_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet> {
71        unsafe {
72            from_glib_full(atk_sys::atk_state_set_and_sets(
73                self.as_ref().to_glib_none().0,
74                compare_set.as_ref().to_glib_none().0,
75            ))
76        }
77    }
78
79    fn clear_states(&self) {
80        unsafe {
81            atk_sys::atk_state_set_clear_states(self.as_ref().to_glib_none().0);
82        }
83    }
84
85    fn contains_state(&self, type_: StateType) -> bool {
86        unsafe {
87            from_glib(atk_sys::atk_state_set_contains_state(
88                self.as_ref().to_glib_none().0,
89                type_.to_glib(),
90            ))
91        }
92    }
93
94    //fn contains_states(&self, types: /*Unimplemented*/&CArray TypeId { ns_id: 1, id: 68 }) -> bool {
95    //    unsafe { TODO: call atk_sys:atk_state_set_contains_states() }
96    //}
97
98    fn is_empty(&self) -> bool {
99        unsafe {
100            from_glib(atk_sys::atk_state_set_is_empty(
101                self.as_ref().to_glib_none().0,
102            ))
103        }
104    }
105
106    fn or_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet> {
107        unsafe {
108            from_glib_full(atk_sys::atk_state_set_or_sets(
109                self.as_ref().to_glib_none().0,
110                compare_set.as_ref().to_glib_none().0,
111            ))
112        }
113    }
114
115    fn remove_state(&self, type_: StateType) -> bool {
116        unsafe {
117            from_glib(atk_sys::atk_state_set_remove_state(
118                self.as_ref().to_glib_none().0,
119                type_.to_glib(),
120            ))
121        }
122    }
123
124    fn xor_sets<P: IsA<StateSet>>(&self, compare_set: &P) -> Option<StateSet> {
125        unsafe {
126            from_glib_full(atk_sys::atk_state_set_xor_sets(
127                self.as_ref().to_glib_none().0,
128                compare_set.as_ref().to_glib_none().0,
129            ))
130        }
131    }
132}
133
134impl fmt::Display for StateSet {
135    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
136        write!(f, "StateSet")
137    }
138}