gtk/entry.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::object::IsA;
4use glib::translate::ToGlibPtr;
5use std::convert::TryFrom;
6
7use crate::Entry;
8
9mod sealed {
10 pub trait Sealed {}
11 impl<T: glib::IsA<crate::Entry>> Sealed for T {}
12}
13
14pub trait EntryExtManual: IsA<Entry> + sealed::Sealed + 'static {
15 /// Retrieves the character displayed in place of the real characters
16 /// for entries with visibility set to false. See [`EntryExt::set_invisible_char()`][crate::prelude::EntryExt::set_invisible_char()].
17 ///
18 /// # Returns
19 ///
20 /// the current invisible char, or 0, if the entry does not
21 /// show invisible text at all.
22 #[doc(alias = "gtk_entry_get_invisible_char")]
23 #[doc(alias = "get_invisible_char")]
24 fn invisible_char(&self) -> Option<char> {
25 let ret = unsafe { ffi::gtk_entry_get_invisible_char(self.as_ref().to_glib_none().0) };
26
27 if ret == 0 {
28 return None;
29 }
30
31 Some(TryFrom::try_from(ret).expect("conversion from an invalid Unicode value attempted"))
32 }
33}
34
35impl<O: IsA<Entry>> EntryExtManual for O {}