nm_rs/auto/
setting_proxy.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir
3// from gtk-girs (https://github.com/gtk-rs/gir-files)
4// DO NOT EDIT
5
6use crate::{ffi,Setting};
7#[cfg(feature = "v1_6")]
8#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
9use crate::{SettingProxyMethod};
10use glib::{prelude::*};
11#[cfg(feature = "v1_6")]
12#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
13use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
14#[cfg(feature = "v1_6")]
15#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
16use std::{boxed::Box as Box_};
17
18glib::wrapper! {
19    /// WWW Proxy Settings
20    ///
21    /// ## Properties
22    ///
23    ///
24    /// #### `browser-only`
25    ///  Whether the proxy configuration is for browser only.
26    ///
27    /// Readable | Writeable
28    ///
29    ///
30    /// #### `method`
31    ///  Method for proxy configuration, Default is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None]
32    ///
33    /// Readable | Writeable
34    ///
35    ///
36    /// #### `pac-script`
37    ///  PAC script for the connection. This is an UTF-8 encoded javascript code
38    /// that defines a FindProxyForURL() function.
39    ///
40    /// Readable | Writeable
41    ///
42    ///
43    /// #### `pac-url`
44    ///  PAC URL for obtaining PAC file.
45    ///
46    /// Readable | Writeable
47    /// <details><summary><h4>Setting</h4></summary>
48    ///
49    ///
50    /// #### `name`
51    ///  The setting's name, which uniquely identifies the setting within the
52    /// connection.  Each setting type has a name unique to that type, for
53    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
54    ///
55    /// Readable
56    /// </details>
57    ///
58    /// # Implements
59    ///
60    /// [`SettingExt`][trait@crate::prelude::SettingExt]
61    #[doc(alias = "NMSettingProxy")]
62    pub struct SettingProxy(Object<ffi::NMSettingProxy, ffi::NMSettingProxyClass>) @extends Setting;
63
64    match fn {
65        type_ => || ffi::nm_setting_proxy_get_type(),
66    }
67}
68
69impl SettingProxy {
70    /// Creates a new #NMSettingProxy object.
71    ///
72    /// # Returns
73    ///
74    /// the new empty #NMSettingProxy object
75    #[cfg(feature = "v1_6")]
76    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
77    #[doc(alias = "nm_setting_proxy_new")]
78    pub fn new() -> SettingProxy {
79        assert_initialized_main_thread!();
80        unsafe {
81            Setting::from_glib_full(ffi::nm_setting_proxy_new()).unsafe_cast()
82        }
83    }
84
85            // rustdoc-stripper-ignore-next
86            /// Creates a new builder-pattern struct instance to construct [`SettingProxy`] objects.
87            ///
88            /// This method returns an instance of [`SettingProxyBuilder`](crate::builders::SettingProxyBuilder) which can be used to create [`SettingProxy`] objects.
89            pub fn builder() -> SettingProxyBuilder {
90                SettingProxyBuilder::new()
91            }
92        
93
94    ///
95    /// # Returns
96    ///
97    /// [`true`] if this proxy configuration is only for browser
98    /// clients/schemes, [`false`] otherwise.
99    #[cfg(feature = "v1_6")]
100    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
101    #[doc(alias = "nm_setting_proxy_get_browser_only")]
102    #[doc(alias = "get_browser_only")]
103    #[doc(alias = "browser-only")]
104    pub fn is_browser_only(&self) -> bool {
105        unsafe {
106            from_glib(ffi::nm_setting_proxy_get_browser_only(self.to_glib_none().0))
107        }
108    }
109
110    /// Returns the proxy configuration method. By default the value is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None].
111    /// [`SettingProxyMethod::None`][crate::SettingProxyMethod::None] should be selected for a connection intended for direct network
112    /// access.
113    ///
114    /// # Returns
115    ///
116    /// the proxy configuration method
117    #[cfg(feature = "v1_6")]
118    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
119    #[doc(alias = "nm_setting_proxy_get_method")]
120    #[doc(alias = "get_method")]
121    pub fn method(&self) -> SettingProxyMethod {
122        unsafe {
123            from_glib(ffi::nm_setting_proxy_get_method(self.to_glib_none().0))
124        }
125    }
126
127    ///
128    /// # Returns
129    ///
130    /// the PAC script.
131    #[cfg(feature = "v1_6")]
132    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
133    #[doc(alias = "nm_setting_proxy_get_pac_script")]
134    #[doc(alias = "get_pac_script")]
135    #[doc(alias = "pac-script")]
136    pub fn pac_script(&self) -> glib::GString {
137        unsafe {
138            from_glib_none(ffi::nm_setting_proxy_get_pac_script(self.to_glib_none().0))
139        }
140    }
141
142    ///
143    /// # Returns
144    ///
145    /// the PAC URL for obtaining PAC file
146    #[cfg(feature = "v1_6")]
147    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
148    #[doc(alias = "nm_setting_proxy_get_pac_url")]
149    #[doc(alias = "get_pac_url")]
150    #[doc(alias = "pac-url")]
151    pub fn pac_url(&self) -> glib::GString {
152        unsafe {
153            from_glib_none(ffi::nm_setting_proxy_get_pac_url(self.to_glib_none().0))
154        }
155    }
156
157    /// Whether the proxy configuration is for browser only.
158    #[cfg(feature = "v1_6")]
159    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
160    #[doc(alias = "browser-only")]
161    pub fn set_browser_only(&self, browser_only: bool) {
162        ObjectExt::set_property(self,"browser-only", browser_only)
163    }
164
165    /// Method for proxy configuration, Default is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None]
166    #[cfg(feature = "v1_6")]
167    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
168    pub fn set_method(&self, method: i32) {
169        ObjectExt::set_property(self,"method", method)
170    }
171
172    /// PAC script for the connection. This is an UTF-8 encoded javascript code
173    /// that defines a FindProxyForURL() function.
174    #[cfg(feature = "v1_6")]
175    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
176    #[doc(alias = "pac-script")]
177    pub fn set_pac_script(&self, pac_script: Option<&str>) {
178        ObjectExt::set_property(self,"pac-script", pac_script)
179    }
180
181    /// PAC URL for obtaining PAC file.
182    #[cfg(feature = "v1_6")]
183    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
184    #[doc(alias = "pac-url")]
185    pub fn set_pac_url(&self, pac_url: Option<&str>) {
186        ObjectExt::set_property(self,"pac-url", pac_url)
187    }
188
189    #[cfg(feature = "v1_6")]
190    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
191    #[doc(alias = "browser-only")]
192    pub fn connect_browser_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
193        unsafe extern "C" fn notify_browser_only_trampoline<F: Fn(&SettingProxy) + 'static>(this: *mut ffi::NMSettingProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
194            let f: &F = &*(f as *const F);
195            f(&from_glib_borrow(this))
196        }
197        unsafe {
198            let f: Box_<F> = Box_::new(f);
199            connect_raw(self.as_ptr() as *mut _, c"notify::browser-only".as_ptr() as *const _,
200                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_browser_only_trampoline::<F> as *const ())), Box_::into_raw(f))
201        }
202    }
203
204    #[cfg(feature = "v1_6")]
205    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
206    #[doc(alias = "method")]
207    pub fn connect_method_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
208        unsafe extern "C" fn notify_method_trampoline<F: Fn(&SettingProxy) + 'static>(this: *mut ffi::NMSettingProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
209            let f: &F = &*(f as *const F);
210            f(&from_glib_borrow(this))
211        }
212        unsafe {
213            let f: Box_<F> = Box_::new(f);
214            connect_raw(self.as_ptr() as *mut _, c"notify::method".as_ptr() as *const _,
215                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_method_trampoline::<F> as *const ())), Box_::into_raw(f))
216        }
217    }
218
219    #[cfg(feature = "v1_6")]
220    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
221    #[doc(alias = "pac-script")]
222    pub fn connect_pac_script_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
223        unsafe extern "C" fn notify_pac_script_trampoline<F: Fn(&SettingProxy) + 'static>(this: *mut ffi::NMSettingProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
224            let f: &F = &*(f as *const F);
225            f(&from_glib_borrow(this))
226        }
227        unsafe {
228            let f: Box_<F> = Box_::new(f);
229            connect_raw(self.as_ptr() as *mut _, c"notify::pac-script".as_ptr() as *const _,
230                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pac_script_trampoline::<F> as *const ())), Box_::into_raw(f))
231        }
232    }
233
234    #[cfg(feature = "v1_6")]
235    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
236    #[doc(alias = "pac-url")]
237    pub fn connect_pac_url_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
238        unsafe extern "C" fn notify_pac_url_trampoline<F: Fn(&SettingProxy) + 'static>(this: *mut ffi::NMSettingProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
239            let f: &F = &*(f as *const F);
240            f(&from_glib_borrow(this))
241        }
242        unsafe {
243            let f: Box_<F> = Box_::new(f);
244            connect_raw(self.as_ptr() as *mut _, c"notify::pac-url".as_ptr() as *const _,
245                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pac_url_trampoline::<F> as *const ())), Box_::into_raw(f))
246        }
247    }
248}
249
250#[cfg(feature = "v1_6")]
251#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
252impl Default for SettingProxy {
253                     fn default() -> Self {
254                         Self::new()
255                     }
256                 }
257
258// rustdoc-stripper-ignore-next
259        /// A [builder-pattern] type to construct [`SettingProxy`] objects.
260        ///
261        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
262#[must_use = "The builder must be built to be used"]
263pub struct SettingProxyBuilder {
264            builder: glib::object::ObjectBuilder<'static, SettingProxy>,
265        }
266
267        impl SettingProxyBuilder {
268        fn new() -> Self {
269            Self { builder: glib::object::Object::builder() }
270        }
271
272                            /// Whether the proxy configuration is for browser only.
273                            #[cfg(feature = "v1_6")]
274    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
275    pub fn browser_only(self, browser_only: bool) -> Self {
276                            Self { builder: self.builder.property("browser-only", browser_only), }
277                        }
278
279                            /// Method for proxy configuration, Default is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None]
280                            #[cfg(feature = "v1_6")]
281    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
282    pub fn method(self, method: i32) -> Self {
283                            Self { builder: self.builder.property("method", method), }
284                        }
285
286                            /// PAC script for the connection. This is an UTF-8 encoded javascript code
287                            /// that defines a FindProxyForURL() function.
288                            #[cfg(feature = "v1_6")]
289    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
290    pub fn pac_script(self, pac_script: impl Into<glib::GString>) -> Self {
291                            Self { builder: self.builder.property("pac-script", pac_script.into()), }
292                        }
293
294                            /// PAC URL for obtaining PAC file.
295                            #[cfg(feature = "v1_6")]
296    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
297    pub fn pac_url(self, pac_url: impl Into<glib::GString>) -> Self {
298                            Self { builder: self.builder.property("pac-url", pac_url.into()), }
299                        }
300
301    // rustdoc-stripper-ignore-next
302    /// Build the [`SettingProxy`].
303    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
304    pub fn build(self) -> SettingProxy {
305assert_initialized_main_thread!();
306    self.builder.build() }
307}