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,Connection};
use glib::{object::ObjectType as _,prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
use std::{boxed::Box as Box_};

glib::wrapper! {
    ///
    ///
    /// ## Signals
    ///
    ///
    /// #### `changed`
    ///
    ///
    /// # Implements
    ///
    /// [`VpnEditorExt`][trait@crate::prelude::VpnEditorExt]
    #[doc(alias = "NMVpnEditor")]
    pub struct VpnEditor(Interface<ffi::NMVpnEditor, ffi::NMVpnEditorInterface>);

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

impl VpnEditor {
        pub const NONE: Option<&'static VpnEditor> = None;
    
}

/// Trait containing all [`struct@VpnEditor`] methods.
///
/// # Implementors
///
/// [`VpnEditor`][struct@crate::VpnEditor]
pub trait VpnEditorExt: IsA<VpnEditor> + 'static {
    //#[doc(alias = "nm_vpn_editor_get_widget")]
    //#[doc(alias = "get_widget")]
    //fn widget(&self) -> /*Ignored*/glib::Object {
    //    unsafe { TODO: call ffi:nm_vpn_editor_get_widget() }
    //}

    #[doc(alias = "nm_vpn_editor_update_connection")]
    fn update_connection(&self, connection: &impl IsA<Connection>) -> Result<(), glib::Error> {
        unsafe {
            let mut error = std::ptr::null_mut();
            let is_ok = ffi::nm_vpn_editor_update_connection(self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, &mut error);
            debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
            if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
        }
    }

    #[doc(alias = "changed")]
    fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe extern "C" fn changed_trampoline<P: IsA<VpnEditor>, F: Fn(&P) + 'static>(this: *mut ffi::NMVpnEditor, f: glib::ffi::gpointer) {
            let f: &F = &*(f as *const F);
            f(VpnEditor::from_glib_borrow(this).unsafe_cast_ref())
        }
        unsafe {
            let f: Box_<F> = Box_::new(f);
            connect_raw(self.as_ptr() as *mut _, c"changed".as_ptr() as *const _,
                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(changed_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
        }
    }
}

impl<O: IsA<VpnEditor>> VpnEditorExt for O {}