atk/auto/object_factory.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::Object;
6use glib::{prelude::*, translate::*};
7use std::fmt;
8
9glib::wrapper! {
10 /// The base object class for a factory used to
11 /// create accessible objects for objects of a specific GType.
12 ///
13 /// This class is the base object class for a factory used to create an
14 /// accessible object for a specific GType. The function
15 /// [`RegistryExt::set_factory_type()`][crate::prelude::RegistryExt::set_factory_type()] is normally called to store in the
16 /// registry the factory type to be used to create an accessible of a
17 /// particular GType.
18 ///
19 /// # Implements
20 ///
21 /// [`ObjectFactoryExt`][trait@crate::prelude::ObjectFactoryExt], [`trait@glib::ObjectExt`]
22 #[doc(alias = "AtkObjectFactory")]
23 pub struct ObjectFactory(Object<ffi::AtkObjectFactory, ffi::AtkObjectFactoryClass>);
24
25 match fn {
26 type_ => || ffi::atk_object_factory_get_type(),
27 }
28}
29
30impl ObjectFactory {
31 pub const NONE: Option<&'static ObjectFactory> = None;
32}
33
34mod sealed {
35 pub trait Sealed {}
36 impl<T: super::IsA<super::ObjectFactory>> Sealed for T {}
37}
38
39/// Trait containing all [`struct@ObjectFactory`] methods.
40///
41/// # Implementors
42///
43/// [`NoOpObjectFactory`][struct@crate::NoOpObjectFactory], [`ObjectFactory`][struct@crate::ObjectFactory]
44pub trait ObjectFactoryExt: IsA<ObjectFactory> + sealed::Sealed + 'static {
45 /// Provides an [`Object`][crate::Object] that implements an accessibility interface
46 /// on behalf of `obj`
47 /// ## `obj`
48 /// a [`glib::Object`][crate::glib::Object]
49 ///
50 /// # Returns
51 ///
52 /// an [`Object`][crate::Object] that implements an accessibility
53 /// interface on behalf of `obj`
54 #[doc(alias = "atk_object_factory_create_accessible")]
55 fn create_accessible(&self, obj: &impl IsA<glib::Object>) -> Option<Object> {
56 unsafe {
57 from_glib_full(ffi::atk_object_factory_create_accessible(
58 self.as_ref().to_glib_none().0,
59 obj.as_ref().to_glib_none().0,
60 ))
61 }
62 }
63
64 /// Gets the GType of the accessible which is created by the factory.
65 ///
66 /// # Returns
67 ///
68 /// the type of the accessible which is created by the `self`.
69 /// The value G_TYPE_INVALID is returned if no type if found.
70 #[doc(alias = "atk_object_factory_get_accessible_type")]
71 #[doc(alias = "get_accessible_type")]
72 fn accessible_type(&self) -> glib::types::Type {
73 unsafe {
74 from_glib(ffi::atk_object_factory_get_accessible_type(
75 self.as_ref().to_glib_none().0,
76 ))
77 }
78 }
79
80 /// Inform `self` that it is no longer being used to create
81 /// accessibles. When called, `self` may need to inform
82 /// `AtkObjects` which it has created that they need to be re-instantiated.
83 /// Note: primarily used for runtime replacement of `AtkObjectFactorys`
84 /// in object registries.
85 #[doc(alias = "atk_object_factory_invalidate")]
86 fn invalidate(&self) {
87 unsafe {
88 ffi::atk_object_factory_invalidate(self.as_ref().to_glib_none().0);
89 }
90 }
91}
92
93impl<O: IsA<ObjectFactory>> ObjectFactoryExt for O {}
94
95impl fmt::Display for ObjectFactory {
96 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
97 f.write_str("ObjectFactory")
98 }
99}