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! {
#[doc(alias = "NMSettingProxy")]
pub struct SettingProxy(Object<ffi::NMSettingProxy, ffi::NMSettingProxyClass>) @extends Setting;
match fn {
type_ => || ffi::nm_setting_proxy_get_type(),
}
}
impl SettingProxy {
#[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()
}
}
pub fn builder() -> SettingProxyBuilder {
SettingProxyBuilder::new()
}
#[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))
}
}
#[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))
}
}
#[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))
}
}
#[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))
}
}
#[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)
}
#[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)
}
#[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)
}
#[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()
}
}
#[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() }
}
#[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), }
}
#[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), }
}
#[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()), }
}
#[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()), }
}
#[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() }
}