Skip to main content

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