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")]
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_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 let f: &F = &*(f as *const F);
113 f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
114 }
115 unsafe {
116 let f: Box_<F> = Box_::new(f);
117 connect_raw(
118 self.as_ptr() as *mut _,
119 c"notify::description".as_ptr() as *const _,
120 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
121 notify_description_trampoline::<Self, F> as *const (),
122 )),
123 Box_::into_raw(f),
124 )
125 }
126 }
127
128 #[doc(alias = "flags")]
129 fn connect_flags_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
130 unsafe extern "C" fn notify_flags_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
131 this: *mut ffi::GTlsPassword,
132 _param_spec: glib::ffi::gpointer,
133 f: glib::ffi::gpointer,
134 ) {
135 let f: &F = &*(f as *const F);
136 f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
137 }
138 unsafe {
139 let f: Box_<F> = Box_::new(f);
140 connect_raw(
141 self.as_ptr() as *mut _,
142 c"notify::flags".as_ptr() as *const _,
143 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
144 notify_flags_trampoline::<Self, F> as *const (),
145 )),
146 Box_::into_raw(f),
147 )
148 }
149 }
150
151 #[doc(alias = "warning")]
152 fn connect_warning_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
153 unsafe extern "C" fn notify_warning_trampoline<P: IsA<TlsPassword>, F: Fn(&P) + 'static>(
154 this: *mut ffi::GTlsPassword,
155 _param_spec: glib::ffi::gpointer,
156 f: glib::ffi::gpointer,
157 ) {
158 let f: &F = &*(f as *const F);
159 f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref())
160 }
161 unsafe {
162 let f: Box_<F> = Box_::new(f);
163 connect_raw(
164 self.as_ptr() as *mut _,
165 c"notify::warning".as_ptr() as *const _,
166 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
167 notify_warning_trampoline::<Self, F> as *const (),
168 )),
169 Box_::into_raw(f),
170 )
171 }
172 }
173}
174
175impl<O: IsA<TlsPassword>> TlsPasswordExt for O {}