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, ffi};
8
9pub trait EntryExtManual: IsA<Entry> + 'static {
10 /// Retrieves the character displayed in place of the real characters
11 /// for entries with visibility set to false. See [`EntryExt::set_invisible_char()`][crate::prelude::EntryExt::set_invisible_char()].
12 ///
13 /// # Returns
14 ///
15 /// the current invisible char, or 0, if the entry does not
16 /// show invisible text at all.
17 #[doc(alias = "gtk_entry_get_invisible_char")]
18 #[doc(alias = "get_invisible_char")]
19 fn invisible_char(&self) -> Option<char> {
20 let ret = unsafe { ffi::gtk_entry_get_invisible_char(self.as_ref().to_glib_none().0) };
21
22 if ret == 0 {
23 return None;
24 }
25
26 Some(TryFrom::try_from(ret).expect("conversion from an invalid Unicode value attempted"))
27 }
28}
29
30impl<O: IsA<Entry>> EntryExtManual for O {}