1use crate::{ffi,Connection};
7use glib::{object::ObjectType as _,prelude::*,signal::{connect_raw, SignalHandlerId},translate::*};
8use std::{boxed::Box as Box_};
9
10glib::wrapper! {
11 #[doc(alias = "NMVpnEditor")]
23 pub struct VpnEditor(Interface<ffi::NMVpnEditor, ffi::NMVpnEditorInterface>);
24
25 match fn {
26 type_ => || ffi::nm_vpn_editor_get_type(),
27 }
28}
29
30impl VpnEditor {
31 pub const NONE: Option<&'static VpnEditor> = None;
32
33}
34
35pub trait VpnEditorExt: IsA<VpnEditor> + 'static {
41 #[doc(alias = "nm_vpn_editor_update_connection")]
48 fn update_connection(&self, connection: &impl IsA<Connection>) -> Result<(), glib::Error> {
49 unsafe {
50 let mut error = std::ptr::null_mut();
51 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);
52 debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
53 if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
54 }
55 }
56
57 #[doc(alias = "changed")]
58 fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
59 unsafe extern "C" fn changed_trampoline<P: IsA<VpnEditor>, F: Fn(&P) + 'static>(this: *mut ffi::NMVpnEditor, f: glib::ffi::gpointer) {
60 let f: &F = &*(f as *const F);
61 f(VpnEditor::from_glib_borrow(this).unsafe_cast_ref())
62 }
63 unsafe {
64 let f: Box_<F> = Box_::new(f);
65 connect_raw(self.as_ptr() as *mut _, c"changed".as_ptr() as *const _,
66 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(changed_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
67 }
68 }
69}
70
71impl<O: IsA<VpnEditor>> VpnEditorExt for O {}