mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-03 01:55:27 +00:00
remove extra getters, give name to gobjects
This commit is contained in:
parent
36d4673d44
commit
2799ce37fe
16 changed files with 76 additions and 180 deletions
|
|
@ -2,12 +2,11 @@ mod widget;
|
|||
|
||||
use widget::Widget;
|
||||
|
||||
use adw::PasswordEntryRow;
|
||||
use gtk::{gio::SimpleAction, glib::GString};
|
||||
use gtk::gio::SimpleAction;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Form {
|
||||
widget: Rc<Widget>,
|
||||
pub widget: Rc<Widget>,
|
||||
}
|
||||
|
||||
impl Form {
|
||||
|
|
@ -19,18 +18,4 @@ impl Form {
|
|||
// Result
|
||||
Self { widget }
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn focus(&self) {
|
||||
self.widget.focus();
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn text(&self) -> GString {
|
||||
self.widget.text()
|
||||
}
|
||||
|
||||
pub fn gobject(&self) -> &PasswordEntryRow {
|
||||
self.widget.gobject()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,51 +2,33 @@ use adw::{
|
|||
prelude::{EntryRowExt, PreferencesRowExt},
|
||||
PasswordEntryRow,
|
||||
};
|
||||
use gtk::{
|
||||
gio::SimpleAction,
|
||||
glib::GString,
|
||||
prelude::{ActionExt, EditableExt, WidgetExt},
|
||||
};
|
||||
use gtk::{gio::SimpleAction, prelude::ActionExt};
|
||||
|
||||
pub struct Widget {
|
||||
gobject: PasswordEntryRow,
|
||||
pub password_entry_row: PasswordEntryRow,
|
||||
}
|
||||
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(action_send: SimpleAction, title: Option<&str>, _max_length: Option<i32>) -> Self {
|
||||
// Init gobject
|
||||
let gobject = PasswordEntryRow::builder().show_apply_button(true).build();
|
||||
// Init main widget
|
||||
let password_entry_row = PasswordEntryRow::builder().show_apply_button(true).build();
|
||||
|
||||
if let Some(value) = title {
|
||||
gobject.set_title(value);
|
||||
password_entry_row.set_title(value);
|
||||
}
|
||||
|
||||
/* @TODO adw 1.6 / ubuntu 24.10+
|
||||
if let Some(value) = max_length {
|
||||
gobject.set_max_length(value);
|
||||
password_entry_row.set_max_length(value);
|
||||
} */
|
||||
|
||||
// Init events
|
||||
gobject.connect_apply(move |_| {
|
||||
password_entry_row.connect_apply(move |_| {
|
||||
action_send.activate(None);
|
||||
});
|
||||
|
||||
// Return activated struct
|
||||
Self { gobject }
|
||||
}
|
||||
|
||||
// Actions
|
||||
pub fn focus(&self) {
|
||||
self.gobject.grab_focus();
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn text(&self) -> GString {
|
||||
self.gobject.text()
|
||||
}
|
||||
|
||||
pub fn gobject(&self) -> &PasswordEntryRow {
|
||||
&self.gobject
|
||||
Self { password_entry_row }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue