mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 09:10:08 +00:00
disable apply button on auth match previous or active selection (or contain parent relation), reorganize getters
This commit is contained in:
parent
10edad5cb2
commit
44d34c46bb
@ -93,7 +93,7 @@ impl Widget {
|
||||
this.set_response_enabled(response, false);
|
||||
|
||||
// Result
|
||||
callback(form.list.value())
|
||||
callback(form.list.selected_item().value_enum())
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -93,9 +93,10 @@ impl Form {
|
||||
|
||||
/// Validate `Self` components match current selection
|
||||
pub fn is_applicable(&self) -> bool {
|
||||
match self.list.value() {
|
||||
match self.list.selected_item().value_enum() {
|
||||
Value::GenerateNewAuth => self.name.is_valid(),
|
||||
Value::ImportPem => self.file.is_valid(),
|
||||
Value::ProfileIdentityGeminiId(_) => !self.list.selected_item().is_active(),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
@ -120,24 +120,22 @@ impl List {
|
||||
/// Run callback function on `connect_selected_notify` event
|
||||
/// * return `Value` enum match selected item
|
||||
pub fn on_select(&self, callback: impl Fn(Value) + 'static) {
|
||||
self.dropdown.connect_selected_notify(move |this| {
|
||||
callback(
|
||||
this.selected_item()
|
||||
.and_downcast::<Item>()
|
||||
.unwrap()
|
||||
.value_enum(),
|
||||
)
|
||||
});
|
||||
self.dropdown
|
||||
.connect_selected_notify(move |this| callback(selected_item(this).value_enum()));
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
||||
/// Get formatted `value` match selected item
|
||||
pub fn value(&self) -> Value {
|
||||
self.dropdown
|
||||
.selected_item()
|
||||
.and_downcast::<Item>()
|
||||
.unwrap()
|
||||
.value_enum()
|
||||
/// Get selected `Item` GObject
|
||||
pub fn selected_item(&self) -> Item {
|
||||
selected_item(&self.dropdown)
|
||||
}
|
||||
}
|
||||
|
||||
// Tools
|
||||
|
||||
/// Cast and return selected `Item` GObject for any internal
|
||||
/// [DropDown](https://docs.gtk.org/gtk4/class.DropDown.html) widget
|
||||
fn selected_item(dropdown: &DropDown) -> Item {
|
||||
dropdown.selected_item().and_downcast::<Item>().unwrap()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user