Skip to main content

gio/auto/
tls_password.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{TlsPasswordFlags, ffi};
6use glib::{
7    prelude::*,
8    signal::{SignalHandlerId, connect_raw},
9    translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14    #[doc(alias = "GTlsPassword")]
15    pub struct TlsPassword(Object<ffi::GTlsPassword, ffi::GTlsPasswordClass>);
16
17    match fn {
18        type_ => || ffi::g_tls_password_get_type(),
19    }
20}
21
22impl TlsPassword {
23    pub const NONE: Option<&'static TlsPassword> = None;
24
25    #[doc(alias = "g_tls_password_new")]
26    pub fn new(flags: TlsPasswordFlags, description: &str) -> TlsPassword {
27        unsafe {
28            from_glib_full(ffi::g_tls_password_new(
29                flags.into_glib(),
30                description.to_glib_none().0,
31            ))
32        }
33    }
34}
35
36pub trait TlsPasswordExt: IsA<TlsPassword> + 'static {
37    #[doc(alias = "g_tls_password_get_description")]
38    #[doc(alias = "get_description")]
39    fn description(&self) -> glib::GString {
40        unsafe {
41            from_glib_none(ffi::g_tls_password_get_description(
42                self.as_ref().to_glib_none().0,
43            ))
44        }
45    }
46
47    #[doc(alias = "g_tls_password_get_flags")]
48    #[doc(alias = "get_flags")]
49    fn flags(&self) -> TlsPasswordFlags {
50        unsafe {
51            from_glib(ffi::g_tls_password_get_flags(
52                self.as_ref().to_glib_none().0,
53            ))
54        }
55    }
56
57    #[doc(alias = "g_tls_password_get_warning")]
58    #[doc(alias = "get_warning")]
59    fn warning(&self) -> glib::GString {
60        unsafe {
61            from_glib_none(ffi::g_tls_password_get_warning(
62                self.as_ref().to_glib_none().0,
63            ))
64        }
65    }
66
67    #[doc(alias = "g_tls_password_set_description")]
68    #[doc(alias = "description")]
69    fn set_description(&self, description: &str) {
70        unsafe {
71            ffi::g_tls_password_set_description(
72                self.as_ref().to_glib_none().0,
73                description.to_glib_none().0,
74            );
75        }
76    }
77
78    #[doc(alias = "g_tls_password_set_flags")]
79    #[doc(alias = "flags")]
80    fn set_flags(&self, flags: TlsPasswordFlags) {
81        unsafe {
82            ffi::g_tls_password_set_flags(self.as_ref().to_glib_none().0, flags.into_glib());
83        }
84    }
85
86    //#[doc(alias = "g_tls_password_set_value_full")]
87    //fn set_value_full(&self, value: &[u8]) {
88    //    unsafe { TODO: call ffi:g_tls_password_set_value_full() }
89    //}
90
91    #[doc(alias = "g_tls_password_set_warning")]
92    #[doc(alias = "warning")]
93    fn set_warning(&self, warning: &str) {
94        unsafe {
95            ffi::g_tls_password_set_warning(
96                self.as_ref().to_glib_none().0,
97                warning.to_glib_none().0,
98            );
99        }
100    }
101
102    #[doc(alias = "description")]
103    fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
104        unsafe extern "C" fn notify_description_trampoline<
105            P: IsA<TlsPassword>,
106            F: Fn(&P) + 'static,
107        >(
108            this: *mut ffi::GTlsPassword,
109            _param_spec: glib::ffi::gpointer,
110            f: glib::ffi::gpointer,
111        ) {
112            unsafe {
113                let f: &F = &*(f as *const F);
114                f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
115            }
116        }
117        unsafe {
118            let f: Box_<F> = Box_::new(f);
119            connect_raw(
120                self.as_ptr() as *mut _,
121                c"notify::description".as_ptr(),
122                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
123                    notify_description_trampoline::<Self, F> as *const (),
124                )),
125                Box_::into_raw(f),
126            )
127        }
128    }
129
130    #[doc(alias = "flags")]
131    fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
132        unsafe extern "C" fn notify_flags_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
133            this: *mut ffi::GTlsPassword,
134            _param_spec: glib::ffi::gpointer,
135            f: glib::ffi::gpointer,
136        ) {
137            unsafe {
138                let f: &F = &*(f as *const F);
139                f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
140            }
141        }
142        unsafe {
143            let f: Box_<F> = Box_::new(f);
144            connect_raw(
145                self.as_ptr() as *mut _,
146                c"notify::flags".as_ptr(),
147                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
148                    notify_flags_trampoline::<Self, F> as *const (),
149                )),
150                Box_::into_raw(f),
151            )
152        }
153    }
154
155    #[doc(alias = "warning")]
156    fn connect_warning_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
157        unsafe extern "C" fn notify_warning_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
158            this: *mut ffi::GTlsPassword,
159            _param_spec: glib::ffi::gpointer,
160            f: glib::ffi::gpointer,
161        ) {
162            unsafe {
163                let f: &F = &*(f as *const F);
164                f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
165            }
166        }
167        unsafe {
168            let f: Box_<F> = Box_::new(f);
169            connect_raw(
170                self.as_ptr() as *mut _,
171                c"notify::warning".as_ptr(),
172                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
173                    notify_warning_trampoline::<Self, F> as *const (),
174                )),
175                Box_::into_raw(f),
176            )
177        }
178    }
179}
180
181impl<O: IsA<TlsPassword>> TlsPasswordExt for O {}