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);
match primary_icon::from(&self.entry.text()) {
PrimaryIcon::Download {
icon_name,
tooltip_text,
} => {
self.entry.set_primary_icon_name(Some(icon_name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip_text));
PrimaryIcon::Download { name, tooltip } => {
self.entry.set_primary_icon_name(Some(name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip));
}
PrimaryIcon::Gemini {
icon_name,
tooltip_text,
} => {
PrimaryIcon::Gemini { name, tooltip } => {
self.entry.set_primary_icon_activatable(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 {
self.entry.first_child().unwrap().add_css_class("success"); // @TODO handle
self.entry
.set_primary_icon_tooltip_text(Some(tooltip_text.1));
self.entry.set_primary_icon_tooltip_text(Some(tooltip.1));
} else {
self.entry
.set_primary_icon_tooltip_text(Some(tooltip_text.0));
self.entry.set_primary_icon_tooltip_text(Some(tooltip.0));
}
}
PrimaryIcon::Search {
icon_name,
tooltip_text,
} => {
self.entry.set_primary_icon_name(Some(icon_name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip_text));
PrimaryIcon::Search { name, tooltip } => {
self.entry.set_primary_icon_name(Some(name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip));
}
PrimaryIcon::Source {
icon_name,
tooltip_text,
} => {
self.entry.set_primary_icon_name(Some(icon_name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip_text));
PrimaryIcon::Source { name, tooltip } => {
self.entry.set_primary_icon_name(Some(name));
self.entry.set_primary_icon_tooltip_text(Some(tooltip));
}
}

View File

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