gio/auto/
simple_proxy_resolver.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::{ffi, ProxyResolver};
6use glib::{
7    prelude::*,
8    signal::{connect_raw, SignalHandlerId},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GSimpleProxyResolver")]
15    pub struct SimpleProxyResolver(Object<ffi::GSimpleProxyResolver, ffi::GSimpleProxyResolverClass>) @implements ProxyResolver;
16
17    match fn {
18        type_ => || ffi::g_simple_proxy_resolver_get_type(),
19    }
20}
21
22impl SimpleProxyResolver {
23    pub const NONE: Option<&'static SimpleProxyResolver> = None;
24}
25
26pub trait SimpleProxyResolverExt: IsA<SimpleProxyResolver> + 'static {
27    #[doc(alias = "g_simple_proxy_resolver_set_default_proxy")]
28    #[doc(alias = "default-proxy")]
29    fn set_default_proxy(&self, default_proxy: Option<&str>) {
30        unsafe {
31            ffi::g_simple_proxy_resolver_set_default_proxy(
32                self.as_ref().to_glib_none().0,
33                default_proxy.to_glib_none().0,
34            );
35        }
36    }
37
38    #[doc(alias = "g_simple_proxy_resolver_set_uri_proxy")]
39    fn set_uri_proxy(&self, uri_scheme: &str, proxy: &str) {
40        unsafe {
41            ffi::g_simple_proxy_resolver_set_uri_proxy(
42                self.as_ref().to_glib_none().0,
43                uri_scheme.to_glib_none().0,
44                proxy.to_glib_none().0,
45            );
46        }
47    }
48
49    #[doc(alias = "default-proxy")]
50    fn default_proxy(&self) -> Option<glib::GString> {
51        ObjectExt::property(self.as_ref(), "default-proxy")
52    }
53
54    #[doc(alias = "ignore-hosts")]
55    fn ignore_hosts(&self) -> Vec<glib::GString> {
56        ObjectExt::property(self.as_ref(), "ignore-hosts")
57    }
58
59    #[doc(alias = "default-proxy")]
60    fn connect_default_proxy_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
61        unsafe extern "C" fn notify_default_proxy_trampoline<
62            P: IsA<SimpleProxyResolver>,
63            F: Fn(&P) + 'static,
64        >(
65            this: *mut ffi::GSimpleProxyResolver,
66            _param_spec: glib::ffi::gpointer,
67            f: glib::ffi::gpointer,
68        ) {
69            let f: &F = &*(f as *const F);
70            f(SimpleProxyResolver::from_glib_borrow(this).unsafe_cast_ref())
71        }
72        unsafe {
73            let f: Box_<F> = Box_::new(f);
74            connect_raw(
75                self.as_ptr() as *mut _,
76                c"notify::default-proxy".as_ptr() as *const _,
77                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
78                    notify_default_proxy_trampoline::<Self, F> as *const (),
79                )),
80                Box_::into_raw(f),
81            )
82        }
83    }
84
85    #[doc(alias = "ignore-hosts")]
86    fn connect_ignore_hosts_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
87        unsafe extern "C" fn notify_ignore_hosts_trampoline<
88            P: IsA<SimpleProxyResolver>,
89            F: Fn(&P) + 'static,
90        >(
91            this: *mut ffi::GSimpleProxyResolver,
92            _param_spec: glib::ffi::gpointer,
93            f: glib::ffi::gpointer,
94        ) {
95            let f: &F = &*(f as *const F);
96            f(SimpleProxyResolver::from_glib_borrow(this).unsafe_cast_ref())
97        }
98        unsafe {
99            let f: Box_<F> = Box_::new(f);
100            connect_raw(
101                self.as_ptr() as *mut _,
102                c"notify::ignore-hosts".as_ptr() as *const _,
103                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
104                    notify_ignore_hosts_trampoline::<Self, F> as *const (),
105                )),
106                Box_::into_raw(f),
107            )
108        }
109    }
110}
111
112impl<O: IsA<SimpleProxyResolver>> SimpleProxyResolverExt for O {}