// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(any(feature = "v1_2", feature = "dox"))]
use glib::object::ObjectType as ObjectType_;
#[cfg(any(feature = "v1_2", feature = "dox"))]
use glib::signal::connect_raw;
#[cfg(any(feature = "v1_2", feature = "dox"))]
use glib::signal::SignalHandlerId;
use glib::translate::*;
#[cfg(any(feature = "v1_2", feature = "dox"))]
use glib::GString;
#[cfg(any(feature = "v1_2", feature = "dox"))]
use glib_sys;
use nm_sys;
#[cfg(any(feature = "v1_2", feature = "dox"))]
use std::boxed::Box as Box_;
use std::fmt;
#[cfg(any(feature = "v1_2", feature = "dox"))]
use std::mem::transmute;
use Device;
use Object;

glib_wrapper! {
    pub struct DeviceMacvlan(Object<nm_sys::NMDeviceMacvlan, nm_sys::NMDeviceMacvlanClass, DeviceMacvlanClass>) @extends Device, Object;

    match fn {
        get_type => || nm_sys::nm_device_macvlan_get_type(),
    }
}

impl DeviceMacvlan {
    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn get_mode(&self) -> Option<GString> {
        unsafe { from_glib_none(nm_sys::nm_device_macvlan_get_mode(self.to_glib_none().0)) }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn get_no_promisc(&self) -> bool {
        unsafe {
            from_glib(nm_sys::nm_device_macvlan_get_no_promisc(
                self.to_glib_none().0,
            ))
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn get_parent(&self) -> Option<Device> {
        unsafe { from_glib_none(nm_sys::nm_device_macvlan_get_parent(self.to_glib_none().0)) }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn get_tap(&self) -> bool {
        unsafe { from_glib(nm_sys::nm_device_macvlan_get_tap(self.to_glib_none().0)) }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn connect_property_hw_address_notify<F: Fn(&DeviceMacvlan) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_hw_address_trampoline<F: Fn(&DeviceMacvlan) + 'static>(
            this: *mut nm_sys::NMDeviceMacvlan,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::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 _,
                b"notify::hw-address\0".as_ptr() as *const _,
                Some(transmute(notify_hw_address_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn connect_property_mode_notify<F: Fn(&DeviceMacvlan) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_mode_trampoline<F: Fn(&DeviceMacvlan) + 'static>(
            this: *mut nm_sys::NMDeviceMacvlan,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::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 _,
                b"notify::mode\0".as_ptr() as *const _,
                Some(transmute(notify_mode_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn connect_property_no_promisc_notify<F: Fn(&DeviceMacvlan) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_no_promisc_trampoline<F: Fn(&DeviceMacvlan) + 'static>(
            this: *mut nm_sys::NMDeviceMacvlan,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::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 _,
                b"notify::no-promisc\0".as_ptr() as *const _,
                Some(transmute(notify_no_promisc_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn connect_property_parent_notify<F: Fn(&DeviceMacvlan) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_parent_trampoline<F: Fn(&DeviceMacvlan) + 'static>(
            this: *mut nm_sys::NMDeviceMacvlan,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::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 _,
                b"notify::parent\0".as_ptr() as *const _,
                Some(transmute(notify_parent_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
        }
    }

    #[cfg(any(feature = "v1_2", feature = "dox"))]
    pub fn connect_property_tap_notify<F: Fn(&DeviceMacvlan) + 'static>(
        &self,
        f: F,
    ) -> SignalHandlerId {
        unsafe extern "C" fn notify_tap_trampoline<F: Fn(&DeviceMacvlan) + 'static>(
            this: *mut nm_sys::NMDeviceMacvlan,
            _param_spec: glib_sys::gpointer,
            f: glib_sys::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 _,
                b"notify::tap\0".as_ptr() as *const _,
                Some(transmute(notify_tap_trampoline::<F> as usize)),
                Box_::into_raw(f),
            )
        }
    }
}

impl fmt::Display for DeviceMacvlan {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "DeviceMacvlan")
    }
}
