Skip to main content

atk/auto/
plug.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    /// Toplevel for embedding into other processes
11    ///
12    /// See [class[`Socket`][crate::Socket]]
13    ///
14    /// # Implements
15    ///
16    /// [`AtkPlugExt`][trait@crate::prelude::AtkPlugExt], [`AtkObjectExt`][trait@crate::prelude::AtkObjectExt], [`trait@glib::ObjectExt`], [`ComponentExt`][trait@crate::prelude::ComponentExt]
17    #[doc(alias = "AtkPlug")]
18    pub struct Plug(Object<ffi::AtkPlug, ffi::AtkPlugClass>) @extends Object, @implements Component;
19
20    match fn {
21        type_ => || ffi::atk_plug_get_type(),
22    }
23}
24
25impl Plug {
26    pub const NONE: Option<&'static Plug> = None;
27
28    /// Creates a new [`Plug`][crate::Plug] instance.
29    ///
30    /// # Returns
31    ///
32    /// the newly created [`Plug`][crate::Plug]
33    #[doc(alias = "atk_plug_new")]
34    pub fn new() -> Plug {
35        assert_initialized_main_thread!();
36        unsafe { Object::from_glib_full(ffi::atk_plug_new()).unsafe_cast() }
37    }
38}
39
40impl Default for Plug {
41    fn default() -> Self {
42        Self::new()
43    }
44}
45
46mod sealed {
47    pub trait Sealed {}
48    impl<T: super::IsA<super::Plug>> Sealed for T {}
49}
50
51/// Trait containing all [`struct@Plug`] methods.
52///
53/// # Implementors
54///
55/// [`Plug`][struct@crate::Plug]
56pub trait AtkPlugExt: IsA<Plug> + sealed::Sealed + 'static {
57    /// Gets the unique ID of an [`Plug`][crate::Plug] object, which can be used to
58    /// embed inside of an [`Socket`][crate::Socket] using [`AtkSocketExt::embed()`][crate::prelude::AtkSocketExt::embed()].
59    ///
60    /// Internally, this calls a class function that should be registered
61    /// by the IPC layer (usually at-spi2-atk). The implementor of an
62    /// [`Plug`][crate::Plug] object should call this function (after atk-bridge is
63    /// loaded) and pass the value to the process implementing the
64    /// [`Socket`][crate::Socket], so it could embed the plug.
65    ///
66    /// # Returns
67    ///
68    /// the unique ID for the plug
69    #[doc(alias = "atk_plug_get_id")]
70    #[doc(alias = "get_id")]
71    fn id(&self) -> Option<glib::GString> {
72        unsafe { from_glib_full(ffi::atk_plug_get_id(self.as_ref().to_glib_none().0)) }
73    }
74}
75
76impl<O: IsA<Plug>> AtkPlugExt for O {}
77
78impl fmt::Display for Plug {
79    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
80        f.write_str("Plug")
81    }
82}