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