mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
hide secondary icon on request entry is empty, implement shared method for trait
This commit is contained in:
parent
2e55fdfd3d
commit
5247cfee44
1 changed files with 15 additions and 11 deletions
|
|
@ -44,6 +44,8 @@ pub trait Request {
|
||||||
) -> Result<(), String>;
|
) -> Result<(), String>;
|
||||||
|
|
||||||
fn update_primary_icon(&self, profile: &Profile);
|
fn update_primary_icon(&self, profile: &Profile);
|
||||||
|
fn update_secondary_icon(&self);
|
||||||
|
|
||||||
fn show_identity_dialog(&self, profile: &Rc<Profile>);
|
fn show_identity_dialog(&self, profile: &Rc<Profile>);
|
||||||
fn show_search_dialog(&self, profile: &Rc<Profile>);
|
fn show_search_dialog(&self, profile: &Rc<Profile>);
|
||||||
|
|
||||||
|
|
@ -92,14 +94,7 @@ impl Request for Entry {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
entry.connect_has_focus_notify(|this| {
|
entry.connect_has_focus_notify(|this| this.update_secondary_icon());
|
||||||
if this.focus_child().is_some_and(|text| text.has_focus()) {
|
|
||||||
this.set_secondary_icon_name(Some("pan-end-symbolic"));
|
|
||||||
} else {
|
|
||||||
this.set_secondary_icon_name(None);
|
|
||||||
this.select_region(0, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
entry.connect_changed({
|
entry.connect_changed({
|
||||||
let profile = profile.clone();
|
let profile = profile.clone();
|
||||||
|
|
@ -109,8 +104,9 @@ impl Request for Entry {
|
||||||
item_action.reload.set_enabled(!this.text().is_empty());
|
item_action.reload.set_enabled(!this.text().is_empty());
|
||||||
item_action.home.set_enabled(this.home().is_some());
|
item_action.home.set_enabled(this.home().is_some());
|
||||||
|
|
||||||
// Update primary icon
|
// Update icons
|
||||||
this.update_primary_icon(&profile)
|
this.update_primary_icon(&profile);
|
||||||
|
this.update_secondary_icon();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -220,7 +216,6 @@ impl Request for Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_primary_icon(&self, profile: &Profile) {
|
fn update_primary_icon(&self, profile: &Profile) {
|
||||||
// Update primary icon
|
|
||||||
self.first_child().unwrap().remove_css_class("success"); // @TODO handle
|
self.first_child().unwrap().remove_css_class("success"); // @TODO handle
|
||||||
|
|
||||||
match primary_icon::from(&self.text()) {
|
match primary_icon::from(&self.text()) {
|
||||||
|
|
@ -256,6 +251,15 @@ impl Request for Entry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update_secondary_icon(&self) {
|
||||||
|
if !self.text().is_empty() && self.focus_child().is_some_and(|text| text.has_focus()) {
|
||||||
|
self.set_secondary_icon_name(Some("pan-end-symbolic"));
|
||||||
|
} else {
|
||||||
|
self.set_secondary_icon_name(None);
|
||||||
|
self.select_region(0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Present Identity [AlertDialog](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.AlertDialog.html) for `Self`
|
/// Present Identity [AlertDialog](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.AlertDialog.html) for `Self`
|
||||||
fn show_identity_dialog(&self, profile: &Rc<Profile>) {
|
fn show_identity_dialog(&self, profile: &Rc<Profile>) {
|
||||||
// connect identity traits
|
// connect identity traits
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue