nm-rs 0.1.3

Rust bindings for the libnm library.
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir
// from gtk-girs (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::{ffi,Setting};
#[cfg(feature = "v1_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
use crate::{SettingProxyMethod};
use glib::{prelude::*};
#[cfg(feature = "v1_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
use glib::{signal::{connect_raw, SignalHandlerId},translate::*};
#[cfg(feature = "v1_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
use std::{boxed::Box as Box_};

glib::wrapper! {
    /// WWW Proxy Settings
    ///
    /// ## Properties
    ///
    ///
    /// #### `browser-only`
    ///  Whether the proxy configuration is for browser only.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `method`
    ///  Method for proxy configuration, Default is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None]
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `pac-script`
    ///  PAC script for the connection. This is an UTF-8 encoded javascript code
    /// that defines a FindProxyForURL() function.
    ///
    /// Readable | Writeable
    ///
    ///
    /// #### `pac-url`
    ///  PAC URL for obtaining PAC file.
    ///
    /// Readable | Writeable
    /// <details><summary><h4>Setting</h4></summary>
    ///
    ///
    /// #### `name`
    ///  The setting's name, which uniquely identifies the setting within the
    /// connection.  Each setting type has a name unique to that type, for
    /// example "ppp" or "802-11-wireless" or "802-3-ethernet".
    ///
    /// Readable
    /// </details>
    ///
    /// # Implements
    ///
    /// [`SettingExt`][trait@crate::prelude::SettingExt]
    #[doc(alias = "NMSettingProxy")]
    pub struct SettingProxy(Object<ffi::NMSettingProxy, ffi::NMSettingProxyClass>) @extends Setting;

    match fn {
        type_ => || ffi::nm_setting_proxy_get_type(),
    }
}

impl SettingProxy {
    /// Creates a new #NMSettingProxy object.
    ///
    /// # Returns
    ///
    /// the new empty #NMSettingProxy object
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "nm_setting_proxy_new")]
    pub fn new() -> SettingProxy {
        assert_initialized_main_thread!();
        unsafe {
            Setting::from_glib_full(ffi::nm_setting_proxy_new()).unsafe_cast()
        }
    }

            // rustdoc-stripper-ignore-next
            /// Creates a new builder-pattern struct instance to construct [`SettingProxy`] objects.
            ///
            /// This method returns an instance of [`SettingProxyBuilder`](crate::builders::SettingProxyBuilder) which can be used to create [`SettingProxy`] objects.
            pub fn builder() -> SettingProxyBuilder {
                SettingProxyBuilder::new()
            }
        

    ///
    /// # Returns
    ///
    /// [`true`] if this proxy configuration is only for browser
    /// clients/schemes, [`false`] otherwise.
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "nm_setting_proxy_get_browser_only")]
    #[doc(alias = "get_browser_only")]
    #[doc(alias = "browser-only")]
    pub fn is_browser_only(&self) -> bool {
        unsafe {
            from_glib(ffi::nm_setting_proxy_get_browser_only(self.to_glib_none().0))
        }
    }

    /// Returns the proxy configuration method. By default the value is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None].
    /// [`SettingProxyMethod::None`][crate::SettingProxyMethod::None] should be selected for a connection intended for direct network
    /// access.
    ///
    /// # Returns
    ///
    /// the proxy configuration method
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "nm_setting_proxy_get_method")]
    #[doc(alias = "get_method")]
    pub fn method(&self) -> SettingProxyMethod {
        unsafe {
            from_glib(ffi::nm_setting_proxy_get_method(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the PAC script.
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "nm_setting_proxy_get_pac_script")]
    #[doc(alias = "get_pac_script")]
    #[doc(alias = "pac-script")]
    pub fn pac_script(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_proxy_get_pac_script(self.to_glib_none().0))
        }
    }

    ///
    /// # Returns
    ///
    /// the PAC URL for obtaining PAC file
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "nm_setting_proxy_get_pac_url")]
    #[doc(alias = "get_pac_url")]
    #[doc(alias = "pac-url")]
    pub fn pac_url(&self) -> glib::GString {
        unsafe {
            from_glib_none(ffi::nm_setting_proxy_get_pac_url(self.to_glib_none().0))
        }
    }

    /// Whether the proxy configuration is for browser only.
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "browser-only")]
    pub fn set_browser_only(&self, browser_only: bool) {
        ObjectExt::set_property(self,"browser-only", browser_only)
    }

    /// Method for proxy configuration, Default is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None]
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    pub fn set_method(&self, method: i32) {
        ObjectExt::set_property(self,"method", method)
    }

    /// PAC script for the connection. This is an UTF-8 encoded javascript code
    /// that defines a FindProxyForURL() function.
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "pac-script")]
    pub fn set_pac_script(&self, pac_script: Option<&str>) {
        ObjectExt::set_property(self,"pac-script", pac_script)
    }

    /// PAC URL for obtaining PAC file.
    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "pac-url")]
    pub fn set_pac_url(&self, pac_url: Option<&str>) {
        ObjectExt::set_property(self,"pac-url", pac_url)
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "browser-only")]
    pub fn connect_browser_only_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        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) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::browser-only".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_browser_only_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "method")]
    pub fn connect_method_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn notify_method_trampoline<F: Fn(&SettingProxy) + 'static>(this: *mut ffi::NMSettingProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::method".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_method_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "pac-script")]
    pub fn connect_pac_script_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        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) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::pac-script".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pac_script_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }

    #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    #[doc(alias = "pac-url")]
    pub fn connect_pac_url_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        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) {
            let f: &F = &*(f as *const F);
            f(&from_glib_borrow(this))
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"notify::pac-url".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(notify_pac_url_trampoline::<F> as *const ())), Box_::into_raw(f))
        }
    }
}

#[cfg(feature = "v1_6")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
impl Default for SettingProxy {
                     fn default() -> Self {
                         Self::new()
                     }
                 }

// rustdoc-stripper-ignore-next
        /// A [builder-pattern] type to construct [`SettingProxy`] objects.
        ///
        /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct SettingProxyBuilder {
            builder: glib::object::ObjectBuilder<'static, SettingProxy>,
        }

        impl SettingProxyBuilder {
        fn new() -> Self {
            Self { builder: glib::object::Object::builder() }
        }

                            /// Whether the proxy configuration is for browser only.
                            #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    pub fn browser_only(self, browser_only: bool) -> Self {
                            Self { builder: self.builder.property("browser-only", browser_only), }
                        }

                            /// Method for proxy configuration, Default is [`SettingProxyMethod::None`][crate::SettingProxyMethod::None]
                            #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    pub fn method(self, method: i32) -> Self {
                            Self { builder: self.builder.property("method", method), }
                        }

                            /// PAC script for the connection. This is an UTF-8 encoded javascript code
                            /// that defines a FindProxyForURL() function.
                            #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    pub fn pac_script(self, pac_script: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("pac-script", pac_script.into()), }
                        }

                            /// PAC URL for obtaining PAC file.
                            #[cfg(feature = "v1_6")]
    #[cfg_attr(docsrs, doc(cfg(feature = "v1_6")))]
    pub fn pac_url(self, pac_url: impl Into<glib::GString>) -> Self {
                            Self { builder: self.builder.property("pac-url", pac_url.into()), }
                        }

    // rustdoc-stripper-ignore-next
    /// Build the [`SettingProxy`].
    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
    pub fn build(self) -> SettingProxy {
assert_initialized_main_thread!();
    self.builder.build() }
}