use crate::{Object};
use glib::{prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};
glib::wrapper! {
#[doc(alias = "WpProxy")]
pub struct Proxy(Object<ffi::WpProxy, ffi::WpProxyClass>) @extends Object;
match fn {
type_ => || ffi::wp_proxy_get_type(),
}
}
impl Proxy {
pub const NONE: Option<&'static Proxy> = None;
}
mod sealed {
pub trait Sealed {}
impl<T: super::IsA<super::Proxy>> Sealed for T {}
}
pub trait ProxyExt: IsA<Proxy> + sealed::Sealed + 'static {
#[doc(alias = "wp_proxy_get_bound_id")]
#[doc(alias = "get_bound_id")]
fn bound_id(&self) -> u32 {
unsafe {
ffi::wp_proxy_get_bound_id(self.as_ref().to_glib_none().0)
}
}
#[doc(alias = "wp_proxy_get_interface_type")]
#[doc(alias = "get_interface_type")]
fn interface_type(&self) -> (glib::GString, u32) {
unsafe {
let mut version = std::mem::MaybeUninit::uninit();
let ret = from_glib_none(ffi::wp_proxy_get_interface_type(self.as_ref().to_glib_none().0, version.as_mut_ptr()));
(ret, version.assume_init())
}
}
#[doc(alias = "bound")]
fn connect_bound<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn bound_trampoline<P: IsA<Proxy>, F: Fn(&P, u32) + 'static>(this: *mut ffi::WpProxy, object: libc::c_uint, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Proxy::from_glib_borrow(this).unsafe_cast_ref(), object)
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"bound\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(bound_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "error")]
fn connect_error<F: Fn(&Self, i32, i32, &str) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn error_trampoline<P: IsA<Proxy>, F: Fn(&P, i32, i32, &str) + 'static>(this: *mut ffi::WpProxy, object: libc::c_int, p0: libc::c_int, p1: *mut libc::c_char, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Proxy::from_glib_borrow(this).unsafe_cast_ref(), object, p0, &glib::GString::from_glib_borrow(p1))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"error\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(error_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "pw-proxy-destroyed")]
fn connect_pw_proxy_destroyed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn pw_proxy_destroyed_trampoline<P: IsA<Proxy>, F: Fn(&P) + 'static>(this: *mut ffi::WpProxy, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Proxy::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"pw-proxy-destroyed\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(pw_proxy_destroyed_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "bound-id")]
fn connect_bound_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bound_id_trampoline<P: IsA<Proxy>, F: Fn(&P) + 'static>(this: *mut ffi::WpProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Proxy::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::bound-id\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_bound_id_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
#[doc(alias = "pw-proxy")]
fn connect_pw_proxy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_pw_proxy_trampoline<P: IsA<Proxy>, F: Fn(&P) + 'static>(this: *mut ffi::WpProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
let f: &F = &*(f as *const F);
f(Proxy::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::pw-proxy\0".as_ptr() as *const _,
Some(std::mem::transmute::<_, unsafe extern "C" fn()>(notify_pw_proxy_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
impl<O: IsA<Proxy>> ProxyExt for O {}