use crate::EntryBuffer;
use glib::{prelude::*, translate::*};
use std::fmt;
glib::wrapper! {
#[doc(alias = "GtkPasswordEntryBuffer")]
pub struct PasswordEntryBuffer(Object<ffi::GtkPasswordEntryBuffer, ffi::GtkPasswordEntryBufferClass>) @extends EntryBuffer;
match fn {
type_ => || ffi::gtk_password_entry_buffer_get_type(),
}
}
impl PasswordEntryBuffer {
#[doc(alias = "gtk_password_entry_buffer_new")]
pub fn new() -> PasswordEntryBuffer {
assert_initialized_main_thread!();
unsafe { EntryBuffer::from_glib_full(ffi::gtk_password_entry_buffer_new()).unsafe_cast() }
}
pub fn builder() -> PasswordEntryBufferBuilder {
PasswordEntryBufferBuilder::new()
}
}
impl Default for PasswordEntryBuffer {
fn default() -> Self {
Self::new()
}
}
#[must_use = "The builder must be built to be used"]
pub struct PasswordEntryBufferBuilder {
builder: glib::object::ObjectBuilder<'static, PasswordEntryBuffer>,
}
impl PasswordEntryBufferBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
pub fn max_length(self, max_length: i32) -> Self {
Self {
builder: self.builder.property("max-length", max_length),
}
}
pub fn text(self, text: impl Into<glib::GString>) -> Self {
Self {
builder: self.builder.property("text", text.into()),
}
}
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> PasswordEntryBuffer {
self.builder.build()
}
}
impl fmt::Display for PasswordEntryBuffer {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("PasswordEntryBuffer")
}
}