deactivate exit action if not active, update method names

This commit is contained in:
yggverse 2024-12-08 04:21:10 +02:00
parent d70c4fa963
commit 2d5a84c39c
6 changed files with 33 additions and 17 deletions

View File

@ -28,6 +28,8 @@ pub struct Form {
pub name: Rc<Name>,
pub save: Rc<Save>,
pub g_box: Box,
auth_uri: Uri,
profile: Rc<Profile>,
}
impl Form {
@ -76,6 +78,8 @@ impl Form {
name,
save,
g_box,
auth_uri,
profile,
}
}
@ -92,23 +96,34 @@ impl Form {
}
pub fn update(&self) {
// Get selected item value
// Get shared selected item value
let value = self.list.selected().value_enum();
// Toggle visibility for children components
self.name.set_visible(matches!(value, Value::GeneratePem));
self.file.set_visible(matches!(value, Value::ImportPem));
// Begin children components update
self.name.update(matches!(value, Value::GeneratePem));
self.file.update(matches!(value, Value::ImportPem));
match value {
Value::ProfileIdentityGeminiId(_) => {
self.drop.set_visible(true);
self.exit.set_visible(true);
self.save.set_visible(true);
Value::ProfileIdentityGeminiId(profile_identity_gemini_id) => {
self.drop.update(true);
self.exit.update(
true,
self.profile
.identity
.gemini
.auth
.memory
.match_scope(&self.auth_uri.to_string())
.is_some_and(|auth| {
auth.profile_identity_gemini_id == profile_identity_gemini_id
}),
);
self.save.update(true);
}
_ => {
self.drop.set_visible(false);
self.exit.set_visible(false);
self.save.set_visible(false);
self.drop.update(false);
self.exit.update(false, false);
self.save.update(false);
}
}
}

View File

@ -107,7 +107,7 @@ impl Drop {
// Actions
pub fn set_visible(&self, is_visible: bool) {
pub fn update(&self, is_visible: bool) {
self.button.set_visible(is_visible)
}
}

View File

@ -125,7 +125,8 @@ impl Exit {
// Actions
pub fn set_visible(&self, is_visible: bool) {
self.button.set_visible(is_visible)
pub fn update(&self, is_visible: bool, is_sensitive: bool) {
self.button.set_visible(is_visible);
self.button.set_sensitive(is_sensitive);
}
}

View File

@ -102,7 +102,7 @@ impl File {
// Actions
/// Change visibility status
pub fn set_visible(&self, is_visible: bool) {
pub fn update(&self, is_visible: bool) {
self.button.set_visible(is_visible);
}

View File

@ -39,7 +39,7 @@ impl Name {
/// Change visibility status
/// * grab focus on `is_visible` is `true`
pub fn set_visible(&self, is_visible: bool) {
pub fn update(&self, is_visible: bool) {
self.entry.set_visible(is_visible);
if is_visible && self.entry.focus_child().is_none() {
self.entry.grab_focus();

View File

@ -128,7 +128,7 @@ impl Save {
// Actions
pub fn set_visible(&self, is_visible: bool) {
pub fn update(&self, is_visible: bool) {
self.button.set_visible(is_visible)
}
}