atk/auto/registry.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 crate::ObjectFactory;
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10 /// An object used to store the GType of the
11 /// factories used to create an accessible object for an object of a
12 /// particular GType.
13 ///
14 /// The AtkRegistry is normally used to create appropriate ATK "peers"
15 /// for user interface components. Application developers usually need
16 /// only interact with the AtkRegistry by associating appropriate ATK
17 /// implementation classes with GObject classes via the
18 /// atk_registry_set_factory_type call, passing the appropriate GType
19 /// for application custom widget classes.
20 ///
21 /// # Implements
22 ///
23 /// [`RegistryExt`][trait@crate::prelude::RegistryExt], [`trait@glib::ObjectExt`]
24 #[doc(alias = "AtkRegistry")]
25 pub struct Registry(Object<ffi::AtkRegistry, ffi::AtkRegistryClass>);
26
27 match fn {
28 type_ => || ffi::atk_registry_get_type(),
29 }
30}
31
32impl Registry {
33 pub const NONE: Option<&'static Registry> = None;
34}
35
36mod sealed {
37 pub trait Sealed {}
38 impl<T: super::IsA<super::Registry>> Sealed for T {}
39}
40
41/// Trait containing all [`struct@Registry`] methods.
42///
43/// # Implementors
44///
45/// [`Registry`][struct@crate::Registry]
46pub trait RegistryExt: IsA<Registry> + sealed::Sealed + 'static {
47 /// Gets an [`ObjectFactory`][crate::ObjectFactory] appropriate for creating `AtkObjects`
48 /// appropriate for `type_`.
49 /// ## `type_`
50 /// a `GType` with which to look up the associated [`ObjectFactory`][crate::ObjectFactory]
51 ///
52 /// # Returns
53 ///
54 /// an [`ObjectFactory`][crate::ObjectFactory] appropriate for creating
55 /// `AtkObjects` appropriate for `type_`.
56 #[doc(alias = "atk_registry_get_factory")]
57 #[doc(alias = "get_factory")]
58 fn factory(&self, type_: glib::types::Type) -> Option<ObjectFactory> {
59 unsafe {
60 from_glib_none(ffi::atk_registry_get_factory(
61 self.as_ref().to_glib_none().0,
62 type_.into_glib(),
63 ))
64 }
65 }
66
67 /// Provides a `GType` indicating the [`ObjectFactory`][crate::ObjectFactory] subclass
68 /// associated with `type_`.
69 /// ## `type_`
70 /// a `GType` with which to look up the associated [`ObjectFactory`][crate::ObjectFactory]
71 /// subclass
72 ///
73 /// # Returns
74 ///
75 /// a `GType` associated with type `type_`
76 #[doc(alias = "atk_registry_get_factory_type")]
77 #[doc(alias = "get_factory_type")]
78 fn factory_type(&self, type_: glib::types::Type) -> glib::types::Type {
79 unsafe {
80 from_glib(ffi::atk_registry_get_factory_type(
81 self.as_ref().to_glib_none().0,
82 type_.into_glib(),
83 ))
84 }
85 }
86
87 /// Associate an [`ObjectFactory`][crate::ObjectFactory] subclass with a `GType`. Note:
88 /// The associated `factory_type` will thereafter be responsible for
89 /// the creation of new [`Object`][crate::Object] implementations for instances
90 /// appropriate for `type_`.
91 /// ## `type_`
92 /// an [`Object`][crate::Object] type
93 /// ## `factory_type`
94 /// an [`ObjectFactory`][crate::ObjectFactory] type to associate with `type_`. Must
95 /// implement AtkObject appropriate for `type_`.
96 #[doc(alias = "atk_registry_set_factory_type")]
97 fn set_factory_type(&self, type_: glib::types::Type, factory_type: glib::types::Type) {
98 unsafe {
99 ffi::atk_registry_set_factory_type(
100 self.as_ref().to_glib_none().0,
101 type_.into_glib(),
102 factory_type.into_glib(),
103 );
104 }
105 }
106}
107
108impl<O: IsA<Registry>> RegistryExt for O {}
109
110impl fmt::Display for Registry {
111 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
112 f.write_str("Registry")
113 }
114}