use crate::{ProxyResolver, SocketAddressEnumerator, SocketConnectable, ffi};
use glib::{
prelude::*,
signal::{SignalHandlerId, connect_raw},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
#[doc(alias = "GProxyAddressEnumerator")]
pub struct ProxyAddressEnumerator(Object<ffi::GProxyAddressEnumerator, ffi::GProxyAddressEnumeratorClass>) @extends SocketAddressEnumerator;
match fn {
type_ => || ffi::g_proxy_address_enumerator_get_type(),
}
}
impl ProxyAddressEnumerator {
pub const NONE: Option<&'static ProxyAddressEnumerator> = None;
}
pub trait ProxyAddressEnumeratorExt: IsA<ProxyAddressEnumerator> + 'static {
fn connectable(&self) -> Option<SocketConnectable> {
ObjectExt::property(self.as_ref(), "connectable")
}
#[doc(alias = "default-port")]
fn default_port(&self) -> u32 {
ObjectExt::property(self.as_ref(), "default-port")
}
#[doc(alias = "proxy-resolver")]
fn proxy_resolver(&self) -> Option<ProxyResolver> {
ObjectExt::property(self.as_ref(), "proxy-resolver")
}
#[doc(alias = "proxy-resolver")]
fn set_proxy_resolver<P: IsA<ProxyResolver>>(&self, proxy_resolver: Option<&P>) {
ObjectExt::set_property(self.as_ref(), "proxy-resolver", proxy_resolver)
}
fn uri(&self) -> Option<glib::GString> {
ObjectExt::property(self.as_ref(), "uri")
}
#[doc(alias = "proxy-resolver")]
fn connect_proxy_resolver_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_proxy_resolver_trampoline<
P: IsA<ProxyAddressEnumerator>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::GProxyAddressEnumerator,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
unsafe {
let f: &F = &*(f as *const F);
f(ProxyAddressEnumerator::from_glib_borrow(this).unsafe_cast_ref())
}
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::proxy-resolver".as_ptr(),
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_proxy_resolver_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<ProxyAddressEnumerator>> ProxyAddressEnumeratorExt for O {}