enshort member names

This commit is contained in:
yggverse 2024-12-11 07:33:06 +02:00
parent d661bb8253
commit 315174befb
2 changed files with 29 additions and 43 deletions

View File

@ -184,42 +184,28 @@ impl Widget {
self.entry.set_primary_icon_sensitive(false); self.entry.set_primary_icon_sensitive(false);
match primary_icon::from(&self.entry.text()) { match primary_icon::from(&self.entry.text()) {
PrimaryIcon::Download { PrimaryIcon::Download { name, tooltip } => {
icon_name, self.entry.set_primary_icon_name(Some(name));
tooltip_text, self.entry.set_primary_icon_tooltip_text(Some(tooltip));
} => {
self.entry.set_primary_icon_name(Some(icon_name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip_text));
} }
PrimaryIcon::Gemini { PrimaryIcon::Gemini { name, tooltip } => {
icon_name,
tooltip_text,
} => {
self.entry.set_primary_icon_activatable(true); self.entry.set_primary_icon_activatable(true);
self.entry.set_primary_icon_sensitive(true); self.entry.set_primary_icon_sensitive(true);
self.entry.set_primary_icon_name(Some(icon_name)); self.entry.set_primary_icon_name(Some(name));
if is_identity_active { if is_identity_active {
self.entry.first_child().unwrap().add_css_class("success"); // @TODO handle self.entry.first_child().unwrap().add_css_class("success"); // @TODO handle
self.entry self.entry.set_primary_icon_tooltip_text(Some(tooltip.1));
.set_primary_icon_tooltip_text(Some(tooltip_text.1));
} else { } else {
self.entry self.entry.set_primary_icon_tooltip_text(Some(tooltip.0));
.set_primary_icon_tooltip_text(Some(tooltip_text.0));
} }
} }
PrimaryIcon::Search { PrimaryIcon::Search { name, tooltip } => {
icon_name, self.entry.set_primary_icon_name(Some(name));
tooltip_text, self.entry.set_primary_icon_tooltip_text(Some(tooltip));
} => {
self.entry.set_primary_icon_name(Some(icon_name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip_text));
} }
PrimaryIcon::Source { PrimaryIcon::Source { name, tooltip } => {
icon_name, self.entry.set_primary_icon_name(Some(name));
tooltip_text, self.entry.set_primary_icon_tooltip_text(Some(tooltip));
} => {
self.entry.set_primary_icon_name(Some(icon_name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip_text));
} }
} }

View File

@ -1,46 +1,46 @@
pub enum PrimaryIcon<'a> { pub enum PrimaryIcon<'a> {
Download { Download {
icon_name: &'a str, name: &'a str,
tooltip_text: &'a str, tooltip: &'a str,
}, },
Gemini { Gemini {
icon_name: &'a str, name: &'a str,
tooltip_text: (&'a str, &'a str), tooltip: (&'a str, &'a str),
}, },
Search { Search {
icon_name: &'a str, name: &'a str,
tooltip_text: &'a str, tooltip: &'a str,
}, },
Source { Source {
icon_name: &'a str, name: &'a str,
tooltip_text: &'a str, tooltip: &'a str,
}, },
} }
pub fn from(request: &str) -> PrimaryIcon { pub fn from(request: &str) -> PrimaryIcon {
if request.starts_with("download:") { if request.starts_with("download:") {
return PrimaryIcon::Download { return PrimaryIcon::Download {
icon_name: "document-save-symbolic", name: "document-save-symbolic",
tooltip_text: "Download", tooltip: "Download",
}; };
} }
if request.starts_with("source:") { if request.starts_with("source:") {
return PrimaryIcon::Source { return PrimaryIcon::Source {
icon_name: "applications-system-symbolic", name: "applications-system-symbolic",
tooltip_text: "Source view", tooltip: "Source view",
}; };
} }
if request.starts_with("gemini:") { if request.starts_with("gemini:") {
return PrimaryIcon::Gemini { return PrimaryIcon::Gemini {
icon_name: "channel-secure-symbolic", name: "channel-secure-symbolic",
tooltip_text: ("Guest session", "User session"), tooltip: ("Guest session", "User session"),
}; };
} }
PrimaryIcon::Search { PrimaryIcon::Search {
icon_name: "system-search-symbolic", name: "system-search-symbolic",
tooltip_text: "Search", tooltip: "Search",
} }
} }