1use atk_sys;
6use glib;
7use glib::object::IsA;
8use glib::translate::*;
9use std::fmt;
10use ObjectFactory;
11
12glib_wrapper! {
13 pub struct Registry(Object<atk_sys::AtkRegistry, atk_sys::AtkRegistryClass, RegistryClass>);
14
15 match fn {
16 get_type => || atk_sys::atk_registry_get_type(),
17 }
18}
19
20pub const NONE_REGISTRY: Option<&Registry> = None;
21
22pub trait RegistryExt: 'static {
23 fn get_factory(&self, type_: glib::types::Type) -> Option<ObjectFactory>;
24
25 fn get_factory_type(&self, type_: glib::types::Type) -> glib::types::Type;
26
27 fn set_factory_type(&self, type_: glib::types::Type, factory_type: glib::types::Type);
28}
29
30impl<O: IsA<Registry>> RegistryExt for O {
31 fn get_factory(&self, type_: glib::types::Type) -> Option<ObjectFactory> {
32 unsafe {
33 from_glib_none(atk_sys::atk_registry_get_factory(
34 self.as_ref().to_glib_none().0,
35 type_.to_glib(),
36 ))
37 }
38 }
39
40 fn get_factory_type(&self, type_: glib::types::Type) -> glib::types::Type {
41 unsafe {
42 from_glib(atk_sys::atk_registry_get_factory_type(
43 self.as_ref().to_glib_none().0,
44 type_.to_glib(),
45 ))
46 }
47 }
48
49 fn set_factory_type(&self, type_: glib::types::Type, factory_type: glib::types::Type) {
50 unsafe {
51 atk_sys::atk_registry_set_factory_type(
52 self.as_ref().to_glib_none().0,
53 type_.to_glib(),
54 factory_type.to_glib(),
55 );
56 }
57 }
58}
59
60impl fmt::Display for Registry {
61 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
62 write!(f, "Registry")
63 }
64}