spice_client_glib/auto/
port_channel.rs1use crate::{ffi, Channel};
7use glib::{
8 object::ObjectType as _,
9 prelude::*,
10 signal::{connect_raw, SignalHandlerId},
11 translate::*,
12};
13use std::boxed::Box as Box_;
14
15glib::wrapper! {
16 #[doc(alias = "SpicePortChannel")]
17 pub struct PortChannel(Object<ffi::SpicePortChannel, ffi::SpicePortChannelClass>) @extends Channel;
18
19 match fn {
20 type_ => || ffi::spice_port_channel_get_type(),
21 }
22}
23
24impl PortChannel {
25 pub const NONE: Option<&'static PortChannel> = None;
26}
27
28pub trait PortChannelExt: IsA<PortChannel> + 'static {
29 #[doc(alias = "spice_port_channel_event")]
30 fn event(&self, event: u8) {
31 unsafe {
32 ffi::spice_port_channel_event(self.as_ref().to_glib_none().0, event);
33 }
34 }
35
36 #[doc(alias = "port-name")]
37 fn port_name(&self) -> Option<glib::GString> {
38 ObjectExt::property(self.as_ref(), "port-name")
39 }
40
41 #[doc(alias = "port-opened")]
42 fn is_port_opened(&self) -> bool {
43 ObjectExt::property(self.as_ref(), "port-opened")
44 }
45
46 #[doc(alias = "port-event")]
52 fn connect_port_event<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
53 unsafe extern "C" fn port_event_trampoline<
54 P: IsA<PortChannel>,
55 F: Fn(&P, i32) + 'static,
56 >(
57 this: *mut ffi::SpicePortChannel,
58 event: std::ffi::c_int,
59 f: glib::ffi::gpointer,
60 ) {
61 unsafe {
62 let f: &F = &*(f as *const F);
63 f(PortChannel::from_glib_borrow(this).unsafe_cast_ref(), event)
64 }
65 }
66 unsafe {
67 let f: Box_<F> = Box_::new(f);
68 connect_raw(
69 self.as_ptr() as *mut _,
70 c"port-event".as_ptr(),
71 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
72 port_event_trampoline::<Self, F> as *const (),
73 )),
74 Box_::into_raw(f),
75 )
76 }
77 }
78
79 #[doc(alias = "port-name")]
80 fn connect_port_name_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
81 unsafe extern "C" fn notify_port_name_trampoline<
82 P: IsA<PortChannel>,
83 F: Fn(&P) + 'static,
84 >(
85 this: *mut ffi::SpicePortChannel,
86 _param_spec: glib::ffi::gpointer,
87 f: glib::ffi::gpointer,
88 ) {
89 unsafe {
90 let f: &F = &*(f as *const F);
91 f(PortChannel::from_glib_borrow(this).unsafe_cast_ref())
92 }
93 }
94 unsafe {
95 let f: Box_<F> = Box_::new(f);
96 connect_raw(
97 self.as_ptr() as *mut _,
98 c"notify::port-name".as_ptr(),
99 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
100 notify_port_name_trampoline::<Self, F> as *const (),
101 )),
102 Box_::into_raw(f),
103 )
104 }
105 }
106
107 #[doc(alias = "port-opened")]
108 fn connect_port_opened_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
109 unsafe extern "C" fn notify_port_opened_trampoline<
110 P: IsA<PortChannel>,
111 F: Fn(&P) + 'static,
112 >(
113 this: *mut ffi::SpicePortChannel,
114 _param_spec: glib::ffi::gpointer,
115 f: glib::ffi::gpointer,
116 ) {
117 unsafe {
118 let f: &F = &*(f as *const F);
119 f(PortChannel::from_glib_borrow(this).unsafe_cast_ref())
120 }
121 }
122 unsafe {
123 let f: Box_<F> = Box_::new(f);
124 connect_raw(
125 self.as_ptr() as *mut _,
126 c"notify::port-opened".as_ptr(),
127 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
128 notify_port_opened_trampoline::<Self, F> as *const (),
129 )),
130 Box_::into_raw(f),
131 )
132 }
133 }
134}
135
136impl<O: IsA<PortChannel>> PortChannelExt for O {}