atk/auto/socket.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::{Component, Object, ffi};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// Container for AtkPlug objects from other processes
10 ///
11 /// Together with [`Plug`][crate::Plug], [`Socket`][crate::Socket] provides the ability to embed
12 /// accessibles from one process into another in a fashion that is
13 /// transparent to assistive technologies. [`Socket`][crate::Socket] works as the
14 /// container of [`Plug`][crate::Plug], embedding it using the method
15 /// [`AtkSocketExt::embed()`][crate::prelude::AtkSocketExt::embed()]. Any accessible contained in the [`Plug`][crate::Plug] will
16 /// appear to the assistive technologies as being inside the
17 /// application that created the [`Socket`][crate::Socket].
18 ///
19 /// The communication between a [`Socket`][crate::Socket] and a [`Plug`][crate::Plug] is done by
20 /// the IPC layer of the accessibility framework, normally implemented
21 /// by the D-Bus based implementation of AT-SPI (at-spi2). If that is
22 /// the case, at-spi-atk2 is the responsible to implement the abstract
23 /// methods [`AtkPlugExt::id()`][crate::prelude::AtkPlugExt::id()] and [`AtkSocketExt::embed()`][crate::prelude::AtkSocketExt::embed()], so an ATK
24 /// implementor shouldn't reimplement them. The process that contains
25 /// the [`Plug`][crate::Plug] is responsible to send the ID returned by
26 /// `atk_plug_id()` to the process that contains the [`Socket`][crate::Socket], so it
27 /// could call the method [`AtkSocketExt::embed()`][crate::prelude::AtkSocketExt::embed()] in order to embed it.
28 ///
29 /// For the same reasons, an implementor doesn't need to implement
30 /// [`AtkObjectExt::n_accessible_children()`][crate::prelude::AtkObjectExt::n_accessible_children()] and
31 /// [`AtkObjectExt::ref_accessible_child()`][crate::prelude::AtkObjectExt::ref_accessible_child()]. All the logic related to those
32 /// functions will be implemented by the IPC layer.
33 ///
34 /// See [class[`Plug`][crate::Plug]]
35 ///
36 /// # Implements
37 ///
38 /// [`AtkSocketExt`][trait@crate::prelude::AtkSocketExt], [`AtkObjectExt`][trait@crate::prelude::AtkObjectExt], [`trait@glib::ObjectExt`], [`ComponentExt`][trait@crate::prelude::ComponentExt]
39 #[doc(alias = "AtkSocket")]
40 pub struct Socket(Object<ffi::AtkSocket, ffi::AtkSocketClass>) @extends Object, @implements Component;
41
42 match fn {
43 type_ => || ffi::atk_socket_get_type(),
44 }
45}
46
47impl Socket {
48 pub const NONE: Option<&'static Socket> = None;
49
50 /// Creates a new [`Socket`][crate::Socket].
51 ///
52 /// # Returns
53 ///
54 /// the newly created [`Socket`][crate::Socket] instance
55 #[doc(alias = "atk_socket_new")]
56 pub fn new() -> Socket {
57 assert_initialized_main_thread!();
58 unsafe { Object::from_glib_full(ffi::atk_socket_new()).unsafe_cast() }
59 }
60}
61
62impl Default for Socket {
63 fn default() -> Self {
64 Self::new()
65 }
66}
67
68/// Trait containing all [`struct@Socket`] methods.
69///
70/// # Implementors
71///
72/// [`Socket`][struct@crate::Socket]
73pub trait AtkSocketExt: IsA<Socket> + 'static {
74 /// Embeds the children of an [`Plug`][crate::Plug] as the children of the
75 /// [`Socket`][crate::Socket]. The plug may be in the same process or in a different
76 /// process.
77 ///
78 /// The class item used by this function should be filled in by the IPC
79 /// layer (usually at-spi2-atk). The implementor of the AtkSocket
80 /// should call this function and pass the id for the plug as returned
81 /// by [`AtkPlugExt::id()`][crate::prelude::AtkPlugExt::id()]. It is the responsibility of the application
82 /// to pass the plug id on to the process implementing the [`Socket`][crate::Socket]
83 /// as needed.
84 /// ## `plug_id`
85 /// the ID of an [`Plug`][crate::Plug]
86 #[doc(alias = "atk_socket_embed")]
87 fn embed(&self, plug_id: &str) {
88 unsafe {
89 ffi::atk_socket_embed(self.as_ref().to_glib_none().0, plug_id.to_glib_none().0);
90 }
91 }
92
93 /// Determines whether or not the socket has an embedded plug.
94 ///
95 /// # Returns
96 ///
97 /// TRUE if a plug is embedded in the socket
98 #[doc(alias = "atk_socket_is_occupied")]
99 fn is_occupied(&self) -> bool {
100 unsafe { from_glib(ffi::atk_socket_is_occupied(self.as_ref().to_glib_none().0)) }
101 }
102}
103
104impl<O: IsA<Socket>> AtkSocketExt for O {}