fix: don't allow favoriting apps without an exec string

This commit is contained in:
Ryan Brue 2024-03-31 14:50:08 -05:00 • committed by Ashley Wulber
parent 0629b18e00
commit 91b4f80a9f

View file

@ -878,6 +878,7 @@ impl cosmic::Application for CosmicAppList {
}; };
dock_item.id = self.item_ctr; dock_item.id = self.item_ctr;
if dock_item.desktop_info.exec.is_some() {
self.favorite_list self.favorite_list
.insert(index.min(self.favorite_list.len()), dock_item); .insert(index.min(self.favorite_list.len()), dock_item);
self.config.update_favorites( self.config.update_favorites(
@ -888,6 +889,7 @@ impl cosmic::Application for CosmicAppList {
&Config::new(APP_ID, AppListConfig::VERSION).unwrap(), &Config::new(APP_ID, AppListConfig::VERSION).unwrap(),
); );
} }
}
return finish_dnd(); return finish_dnd();
} }
Message::Wayland(event) => { Message::Wayland(event) => {
@ -1361,13 +1363,17 @@ impl cosmic::Application for CosmicAppList {
content = content.push(list_col); content = content.push(list_col);
content = content.push(divider::horizontal::default()); content = content.push(divider::horizontal::default());
} }
content = content.push(if is_favorite { if is_favorite {
content = content.push(
menu_button(iced::widget::text(fl!("unfavorite"))) menu_button(iced::widget::text(fl!("unfavorite")))
.on_press(Message::UnFavorite(desktop_info.id.clone())) .on_press(Message::UnFavorite(desktop_info.id.clone())),
} else { )
} else if let Some(_) = desktop_info.exec.clone() {
content = content.push(
menu_button(iced::widget::text(fl!("favorite"))) menu_button(iced::widget::text(fl!("favorite")))
.on_press(Message::Favorite(desktop_info.id.clone())) .on_press(Message::Favorite(desktop_info.id.clone())),
}); )
}
content = match toplevels.len() { content = match toplevels.len() {
0 => content, 0 => content,