gtk4/auto/
password_entry_buffer.rs1use crate::{ffi, EntryBuffer};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 #[doc(alias = "GtkPasswordEntryBuffer")]
10 pub struct PasswordEntryBuffer(Object<ffi::GtkPasswordEntryBuffer, ffi::GtkPasswordEntryBufferClass>) @extends EntryBuffer;
11
12 match fn {
13 type_ => || ffi::gtk_password_entry_buffer_get_type(),
14 }
15}
16
17impl PasswordEntryBuffer {
18 #[doc(alias = "gtk_password_entry_buffer_new")]
19 pub fn new() -> PasswordEntryBuffer {
20 assert_initialized_main_thread!();
21 unsafe { EntryBuffer::from_glib_full(ffi::gtk_password_entry_buffer_new()).unsafe_cast() }
22 }
23
24 pub fn builder() -> PasswordEntryBufferBuilder {
29 PasswordEntryBufferBuilder::new()
30 }
31}
32
33impl Default for PasswordEntryBuffer {
34 fn default() -> Self {
35 Self::new()
36 }
37}
38
39#[must_use = "The builder must be built to be used"]
44pub struct PasswordEntryBufferBuilder {
45 builder: glib::object::ObjectBuilder<'static, PasswordEntryBuffer>,
46}
47
48impl PasswordEntryBufferBuilder {
49 fn new() -> Self {
50 Self {
51 builder: glib::object::Object::builder(),
52 }
53 }
54
55 pub fn max_length(self, max_length: i32) -> Self {
56 Self {
57 builder: self.builder.property("max-length", max_length),
58 }
59 }
60
61 pub fn text(self, text: impl Into<glib::GString>) -> Self {
62 Self {
63 builder: self.builder.property("text", text.into()),
64 }
65 }
66
67 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
70 pub fn build(self) -> PasswordEntryBuffer {
71 assert_initialized_main_thread!();
72 self.builder.build()
73 }
74}