parent
bd8dbbf4c5
commit
55b0b19135
2 changed files with 5 additions and 4 deletions
|
|
@ -562,15 +562,16 @@ impl<'a> TryFrom<Cow<'a, Path>> for Applet<'static> {
|
||||||
|
|
||||||
fn try_from(path: Cow<'a, Path>) -> Result<Self, Self::Error> {
|
fn try_from(path: Cow<'a, Path>) -> Result<Self, Self::Error> {
|
||||||
let content = std::fs::read_to_string(path.as_ref())?;
|
let content = std::fs::read_to_string(path.as_ref())?;
|
||||||
let entry = DesktopEntry::from_str(path.as_ref(), &content, None::<&[&str]>)?;
|
let languages = freedesktop_desktop_entry::get_languages_from_env();
|
||||||
|
let entry = DesktopEntry::from_str(path.as_ref(), &content, Some(&languages))?;
|
||||||
if entry.desktop_entry("X-CosmicApplet").is_none() {
|
if entry.desktop_entry("X-CosmicApplet").is_none() {
|
||||||
anyhow::bail!("Not an applet");
|
anyhow::bail!("Not an applet");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
id: Cow::from(entry.id().to_string()),
|
id: Cow::from(entry.id().to_string()),
|
||||||
name: Cow::from(entry.name::<&str>(&[]).unwrap_or_default().to_string()),
|
name: Cow::from(entry.name(&languages).unwrap_or_default().to_string()),
|
||||||
description: Cow::from(entry.comment::<&str>(&[]).unwrap_or_default().to_string()),
|
description: Cow::from(entry.comment(&languages).unwrap_or_default().to_string()),
|
||||||
icon: Cow::from(entry.icon().unwrap_or_default().to_string()),
|
icon: Cow::from(entry.icon().unwrap_or_default().to_string()),
|
||||||
path: Cow::from(path.into_owned()),
|
path: Cow::from(path.into_owned()),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue