fix pr feedback
This commit is contained in:
parent
5f1d923f8e
commit
723f73c276
2 changed files with 24 additions and 30 deletions
|
|
@ -223,11 +223,3 @@ dirs = "6.0.0"
|
||||||
tempfile = "3.13.0"
|
tempfile = "3.13.0"
|
||||||
|
|
||||||
|
|
||||||
[patch."https://github.com/pop-os/libcosmic"]
|
|
||||||
libcosmic = { path = "./" }
|
|
||||||
|
|
||||||
# FIXME update winit deps where necessary to use this
|
|
||||||
# [patch.crates-io]
|
|
||||||
# [patch."https://github.com/pop-os/winit.git"]
|
|
||||||
# winit = { git = "https://github.com/pop-os/winit.git//", branch = "xdg-toplevel" }
|
|
||||||
# winit = { path = "../winit" }
|
|
||||||
|
|
|
||||||
|
|
@ -14,21 +14,13 @@ pub trait IconSourceExt {
|
||||||
impl IconSourceExt for fde::IconSource {
|
impl IconSourceExt for fde::IconSource {
|
||||||
fn as_cosmic_icon(&self) -> crate::widget::icon::Icon {
|
fn as_cosmic_icon(&self) -> crate::widget::icon::Icon {
|
||||||
match self {
|
match self {
|
||||||
fde::IconSource::Name(name) => {
|
fde::IconSource::Name(name) => crate::widget::icon::from_name(name.as_str())
|
||||||
// Prefer SVG only for symbolic icons; otherwise allow themed resolver
|
.size(128)
|
||||||
// to select optimal raster assets to avoid small-size SVG rendering issues.
|
|
||||||
let named = if name.ends_with("-symbolic") {
|
|
||||||
crate::widget::icon::from_name(name.as_str()).prefer_svg(true)
|
|
||||||
} else {
|
|
||||||
crate::widget::icon::from_name(name.as_str())
|
|
||||||
}
|
|
||||||
.fallback(Some(crate::widget::icon::IconFallback::Names(vec![
|
.fallback(Some(crate::widget::icon::IconFallback::Names(vec![
|
||||||
"application-default".into(),
|
"application-default".into(),
|
||||||
"application-x-executable".into(),
|
"application-x-executable".into(),
|
||||||
])));
|
])))
|
||||||
|
.into(),
|
||||||
named.into()
|
|
||||||
}
|
|
||||||
fde::IconSource::Path(path) => {
|
fde::IconSource::Path(path) => {
|
||||||
crate::widget::icon(crate::widget::icon::from_path(path.clone()))
|
crate::widget::icon(crate::widget::icon::from_path(path.clone()))
|
||||||
}
|
}
|
||||||
|
|
@ -347,7 +339,10 @@ pub fn extract_crx_id(value: &str) -> Option<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
fn match_crx_id(entries: &[fde::DesktopEntry], context: &DesktopLookupContext<'_>) -> Option<fde::DesktopEntry> {
|
fn match_crx_id(
|
||||||
|
entries: &[fde::DesktopEntry],
|
||||||
|
context: &DesktopLookupContext<'_>,
|
||||||
|
) -> Option<fde::DesktopEntry> {
|
||||||
let crx = extract_crx_id(context.app_id.as_ref())
|
let crx = extract_crx_id(context.app_id.as_ref())
|
||||||
.or_else(|| context.identifier.as_deref().and_then(extract_crx_id))?;
|
.or_else(|| context.identifier.as_deref().and_then(extract_crx_id))?;
|
||||||
|
|
||||||
|
|
@ -879,7 +874,7 @@ mod tests {
|
||||||
impl EnvVarGuard {
|
impl EnvVarGuard {
|
||||||
fn set(key: &'static str, value: &Path) -> Self {
|
fn set(key: &'static str, value: &Path) -> Self {
|
||||||
let original = env::var(key).ok();
|
let original = env::var(key).ok();
|
||||||
env::set_var(key, value);
|
std::env::set_var(key, value);
|
||||||
Self { key, original }
|
Self { key, original }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -887,9 +882,9 @@ mod tests {
|
||||||
impl Drop for EnvVarGuard {
|
impl Drop for EnvVarGuard {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
if let Some(ref original) = self.original {
|
if let Some(ref original) = self.original {
|
||||||
env::set_var(self.key, original);
|
std::env::set_var(self.key, original);
|
||||||
} else {
|
} else {
|
||||||
env::remove_var(self.key);
|
std::env::remove_var(self.key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -946,7 +941,7 @@ StartupWMClass=crx_jnpecgipniidlgicjocehkhajgdnjekh
|
||||||
let mut cache = DesktopEntryCache::new(locales.clone());
|
let mut cache = DesktopEntryCache::new(locales.clone());
|
||||||
cache.refresh();
|
cache.refresh();
|
||||||
|
|
||||||
let ctx = DesktopLookupContext::new("crx_jnpecgipniidlgicjocehkhajgdnjekh".into());
|
let ctx = DesktopLookupContext::new("crx_jnpecgipniidlgicjocehkhajgdnjekh");
|
||||||
let resolved = resolve_desktop_entry(&mut cache, &ctx, &DesktopResolveOptions::default());
|
let resolved = resolve_desktop_entry(&mut cache, &ctx, &DesktopResolveOptions::default());
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -978,8 +973,7 @@ Icon=vmware-workstation\n\
|
||||||
let mut cache = DesktopEntryCache::new(locales.clone());
|
let mut cache = DesktopEntryCache::new(locales.clone());
|
||||||
cache.refresh();
|
cache.refresh();
|
||||||
|
|
||||||
let ctx = DesktopLookupContext::new("vmware".into())
|
let ctx = DesktopLookupContext::new("vmware").with_title("Library — VMware Workstation");
|
||||||
.with_title("Library — VMware Workstation".into());
|
|
||||||
|
|
||||||
let resolved = resolve_desktop_entry(&mut cache, &ctx, &DesktopResolveOptions::default());
|
let resolved = resolve_desktop_entry(&mut cache, &ctx, &DesktopResolveOptions::default());
|
||||||
|
|
||||||
|
|
@ -1067,8 +1061,14 @@ Icon=vmware-workstation\n\
|
||||||
#[test]
|
#[test]
|
||||||
fn crx_id_extraction_variants() {
|
fn crx_id_extraction_variants() {
|
||||||
let id = "cadlkienfkclaiaibeoongdcgmdikeeg"; // 32 chars a..p
|
let id = "cadlkienfkclaiaibeoongdcgmdikeeg"; // 32 chars a..p
|
||||||
assert_eq!(super::extract_crx_id(&format!("chrome-{}-Default", id)), Some(id.to_string()));
|
assert_eq!(
|
||||||
assert_eq!(super::extract_crx_id(&format!("crx_{}", id)), Some(id.to_string()));
|
super::extract_crx_id(&format!("chrome-{}-Default", id)),
|
||||||
|
Some(id.to_string())
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
super::extract_crx_id(&format!("crx_{}", id)),
|
||||||
|
Some(id.to_string())
|
||||||
|
);
|
||||||
assert_eq!(super::extract_crx_id(id), Some(id.to_string()));
|
assert_eq!(super::extract_crx_id(id), Some(id.to_string()));
|
||||||
// Embedded
|
// Embedded
|
||||||
let embedded = format!("org.chromium.Chromium.flextop.chrome-{}-Default", id);
|
let embedded = format!("org.chromium.Chromium.flextop.chrome-{}-Default", id);
|
||||||
|
|
@ -1086,7 +1086,9 @@ Icon=vmware-workstation\n\
|
||||||
"[Desktop Entry]\nType=Application\nName=ChatGPT\nExec=chromium --app-id={} --profile-directory=Default\nStartupWMClass=crx_{}\nIcon=chrome-{}-Default\n",
|
"[Desktop Entry]\nType=Application\nName=ChatGPT\nExec=chromium --app-id={} --profile-directory=Default\nStartupWMClass=crx_{}\nIcon=chrome-{}-Default\n",
|
||||||
id, id, id
|
id, id, id
|
||||||
);
|
);
|
||||||
let desktop_path = apps_dir.join("org.chromium.Chromium.flextop.chrome-cadlkienfkclaiaibeoongdcgmdikeeg-Default.desktop");
|
let desktop_path = apps_dir.join(
|
||||||
|
"org.chromium.Chromium.flextop.chrome-cadlkienfkclaiaibeoongdcgmdikeeg-Default.desktop",
|
||||||
|
);
|
||||||
fs::write(&desktop_path, desktop_contents).expect("write desktop file");
|
fs::write(&desktop_path, desktop_contents).expect("write desktop file");
|
||||||
|
|
||||||
let _guard = EnvVarGuard::set("XDG_DATA_HOME", temp.path());
|
let _guard = EnvVarGuard::set("XDG_DATA_HOME", temp.path());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue