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 atk_sys;
6use glib::object::Cast;
7use glib::object::IsA;
8use glib::translate::*;
9use std::fmt;
10use Component;
11use Object;
12
13glib_wrapper! {
14    pub struct Socket(Object<atk_sys::AtkSocket, atk_sys::AtkSocketClass, SocketClass>) @extends Object, @implements Component;
15
16    match fn {
17        get_type => || atk_sys::atk_socket_get_type(),
18    }
19}
20
21impl Socket {
22    pub fn new() -> Socket {
23        assert_initialized_main_thread!();
24        unsafe { Object::from_glib_full(atk_sys::atk_socket_new()).unsafe_cast() }
25    }
26}
27
28impl Default for Socket {
29    fn default() -> Self {
30        Self::new()
31    }
32}
33
34pub const NONE_SOCKET: Option<&Socket> = None;
35
36pub trait AtkSocketExt: 'static {
37    fn embed(&self, plug_id: &str);
38
39    fn is_occupied(&self) -> bool;
40}
41
42impl<O: IsA<Socket>> AtkSocketExt for O {
43    fn embed(&self, plug_id: &str) {
44        unsafe {
45            atk_sys::atk_socket_embed(self.as_ref().to_glib_none().0, plug_id.to_glib_none().0);
46        }
47    }
48
49    fn is_occupied(&self) -> bool {
50        unsafe {
51            from_glib(atk_sys::atk_socket_is_occupied(
52                self.as_ref().to_glib_none().0,
53            ))
54        }
55    }
56}
57
58impl fmt::Display for Socket {
59    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
60        write!(f, "Socket")
61    }
62}