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