gio/auto/
tls_password.rs
1use crate::{ffi, TlsPasswordFlags};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GTlsPassword")]
41 pub struct TlsPassword(Object<ffi::GTlsPassword, ffi::GTlsPasswordClass>);
42
43 match fn {
44 type_ => || ffi::g_tls_password_get_type(),
45 }
46}
47
48impl TlsPassword {
49 pub const NONE: Option<&'static TlsPassword> = None;
50
51 #[doc(alias = "g_tls_password_new")]
61 pub fn new(flags: TlsPasswordFlags, description: &str) -> TlsPassword {
62 unsafe {
63 from_glib_full(ffi::g_tls_password_new(
64 flags.into_glib(),
65 description.to_glib_none().0,
66 ))
67 }
68 }
69}
70
71pub trait TlsPasswordExt: IsA<TlsPassword> + 'static {
77 #[doc(alias = "g_tls_password_get_description")]
83 #[doc(alias = "get_description")]
84 fn description(&self) -> glib::GString {
85 unsafe {
86 from_glib_none(ffi::g_tls_password_get_description(
87 self.as_ref().to_glib_none().0,
88 ))
89 }
90 }
91
92 #[doc(alias = "g_tls_password_get_flags")]
98 #[doc(alias = "get_flags")]
99 fn flags(&self) -> TlsPasswordFlags {
100 unsafe {
101 from_glib(ffi::g_tls_password_get_flags(
102 self.as_ref().to_glib_none().0,
103 ))
104 }
105 }
106
107 #[doc(alias = "g_tls_password_get_warning")]
115 #[doc(alias = "get_warning")]
116 fn warning(&self) -> glib::GString {
117 unsafe {
118 from_glib_none(ffi::g_tls_password_get_warning(
119 self.as_ref().to_glib_none().0,
120 ))
121 }
122 }
123
124 #[doc(alias = "g_tls_password_set_description")]
128 #[doc(alias = "description")]
129 fn set_description(&self, description: &str) {
130 unsafe {
131 ffi::g_tls_password_set_description(
132 self.as_ref().to_glib_none().0,
133 description.to_glib_none().0,
134 );
135 }
136 }
137
138 #[doc(alias = "g_tls_password_set_flags")]
142 #[doc(alias = "flags")]
143 fn set_flags(&self, flags: TlsPasswordFlags) {
144 unsafe {
145 ffi::g_tls_password_set_flags(self.as_ref().to_glib_none().0, flags.into_glib());
146 }
147 }
148
149 #[doc(alias = "g_tls_password_set_warning")]
160 #[doc(alias = "warning")]
161 fn set_warning(&self, warning: &str) {
162 unsafe {
163 ffi::g_tls_password_set_warning(
164 self.as_ref().to_glib_none().0,
165 warning.to_glib_none().0,
166 );
167 }
168 }
169
170 #[doc(alias = "description")]
171 fn connect_description_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
172 unsafe extern "C" fn notify_description_trampoline<
173 P: IsA<TlsPassword>,
174 F: Fn(&P) + 'static,
175 >(
176 this: *mut ffi::GTlsPassword,
177 _param_spec: glib::ffi::gpointer,
178 f: glib::ffi::gpointer,
179 ) {
180 let f: &F = &*(f as *const F);
181 f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
182 }
183 unsafe {
184 let f: Box_<F> = Box_::new(f);
185 connect_raw(
186 self.as_ptr() as *mut _,
187 c"notify::description".as_ptr() as *const _,
188 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
189 notify_description_trampoline::<Self, F> as *const (),
190 )),
191 Box_::into_raw(f),
192 )
193 }
194 }
195
196 #[doc(alias = "flags")]
197 fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
198 unsafe extern "C" fn notify_flags_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
199 this: *mut ffi::GTlsPassword,
200 _param_spec: glib::ffi::gpointer,
201 f: glib::ffi::gpointer,
202 ) {
203 let f: &F = &*(f as *const F);
204 f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
205 }
206 unsafe {
207 let f: Box_<F> = Box_::new(f);
208 connect_raw(
209 self.as_ptr() as *mut _,
210 c"notify::flags".as_ptr() as *const _,
211 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
212 notify_flags_trampoline::<Self, F> as *const (),
213 )),
214 Box_::into_raw(f),
215 )
216 }
217 }
218
219 #[doc(alias = "warning")]
220 fn connect_warning_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
221 unsafe extern "C" fn notify_warning_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
222 this: *mut ffi::GTlsPassword,
223 _param_spec: glib::ffi::gpointer,
224 f: glib::ffi::gpointer,
225 ) {
226 let f: &F = &*(f as *const F);
227 f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
228 }
229 unsafe {
230 let f: Box_<F> = Box_::new(f);
231 connect_raw(
232 self.as_ptr() as *mut _,
233 c"notify::warning".as_ptr() as *const _,
234 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
235 notify_warning_trampoline::<Self, F> as *const (),
236 )),
237 Box_::into_raw(f),
238 )
239 }
240 }
241}
242
243impl<O: IsA<TlsPassword>> TlsPasswordExt for O {}