mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20: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);
|
this.set_response_enabled(response, false);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
callback(form.list.value())
|
callback(form.list.selected_item().value_enum())
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -93,9 +93,10 @@ impl Form {
|
|||||||
|
|
||||||
/// Validate `Self` components match current selection
|
/// Validate `Self` components match current selection
|
||||||
pub fn is_applicable(&self) -> bool {
|
pub fn is_applicable(&self) -> bool {
|
||||||
match self.list.value() {
|
match self.list.selected_item().value_enum() {
|
||||||
Value::GenerateNewAuth => self.name.is_valid(),
|
Value::GenerateNewAuth => self.name.is_valid(),
|
||||||
Value::ImportPem => self.file.is_valid(),
|
Value::ImportPem => self.file.is_valid(),
|
||||||
|
Value::ProfileIdentityGeminiId(_) => !self.list.selected_item().is_active(),
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,24 +120,22 @@ impl List {
|
|||||||
/// Run callback function on `connect_selected_notify` event
|
/// Run callback function on `connect_selected_notify` event
|
||||||
/// * return `Value` enum match selected item
|
/// * return `Value` enum match selected item
|
||||||
pub fn on_select(&self, callback: impl Fn(Value) + 'static) {
|
pub fn on_select(&self, callback: impl Fn(Value) + 'static) {
|
||||||
self.dropdown.connect_selected_notify(move |this| {
|
self.dropdown
|
||||||
callback(
|
.connect_selected_notify(move |this| callback(selected_item(this).value_enum()));
|
||||||
this.selected_item()
|
|
||||||
.and_downcast::<Item>()
|
|
||||||
.unwrap()
|
|
||||||
.value_enum(),
|
|
||||||
)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
|
|
||||||
/// Get formatted `value` match selected item
|
/// Get selected `Item` GObject
|
||||||
pub fn value(&self) -> Value {
|
pub fn selected_item(&self) -> Item {
|
||||||
self.dropdown
|
selected_item(&self.dropdown)
|
||||||
.selected_item()
|
|
||||||
.and_downcast::<Item>()
|
|
||||||
.unwrap()
|
|
||||||
.value_enum()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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