use 'map' rather than 'and_then'
This commit is contained in:
parent
9dcc3fcc35
commit
068560e921
1 changed files with 15 additions and 17 deletions
|
|
@ -628,23 +628,21 @@ impl cosmic::Application for CosmicAppList {
|
||||||
Message::DndData(file_path) => {
|
Message::DndData(file_path) => {
|
||||||
if let Some(DndOffer { dock_item, .. }) = self.dnd_offer.as_mut() {
|
if let Some(DndOffer { dock_item, .. }) = self.dnd_offer.as_mut() {
|
||||||
if let Some(di) = std::fs::read_to_string(&file_path).ok().and_then(|input| {
|
if let Some(di) = std::fs::read_to_string(&file_path).ok().and_then(|input| {
|
||||||
DesktopEntry::decode(&file_path, &input)
|
DesktopEntry::decode(&file_path, &input).ok().map(|de| {
|
||||||
.ok()
|
let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid))
|
||||||
.and_then(|de| {
|
.with_size(128)
|
||||||
let icon = freedesktop_icons::lookup(de.icon().unwrap_or(de.appid))
|
.with_cache()
|
||||||
.with_size(128)
|
.find()
|
||||||
.with_cache()
|
.unwrap_or_else(default_app_icon);
|
||||||
.find()
|
DesktopInfo {
|
||||||
.unwrap_or_else(default_app_icon);
|
id: de.id().to_string(),
|
||||||
Some(DesktopInfo {
|
wm_class: de.startup_wm_class().map(ToString::to_string),
|
||||||
id: de.id().to_string(),
|
icon,
|
||||||
wm_class: de.startup_wm_class().map(ToString::to_string),
|
exec: de.exec().unwrap_or_default().to_string(),
|
||||||
icon,
|
name: de.name(None).unwrap_or_default().to_string(),
|
||||||
exec: de.exec().unwrap_or_default().to_string(),
|
path: file_path.clone(),
|
||||||
name: de.name(None).unwrap_or_default().to_string(),
|
}
|
||||||
path: file_path.clone(),
|
})
|
||||||
})
|
|
||||||
})
|
|
||||||
}) {
|
}) {
|
||||||
self.item_ctr += 1;
|
self.item_ctr += 1;
|
||||||
*dock_item = Some(DockItem::new(self.item_ctr, Vec::new(), di));
|
*dock_item = Some(DockItem::new(self.item_ctr, Vec::new(), di));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue