fix(app-list): load apps so that they match the config order
This commit is contained in:
parent
d292246032
commit
bb788b45a4
1 changed files with 20 additions and 3 deletions
|
|
@ -68,6 +68,23 @@ pub fn run() -> cosmic::iced::Result {
|
||||||
cosmic::applet::run::<CosmicAppList>(true, ())
|
cosmic::applet::run::<CosmicAppList>(true, ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn load_applications_for_app_ids_sorted<'a, 'b>(
|
||||||
|
locale: impl Into<Option<&'a str>>,
|
||||||
|
app_ids: impl Iterator<Item = &'b str> + Clone,
|
||||||
|
fill_missing_ones: bool,
|
||||||
|
) -> Vec<DesktopEntryData> {
|
||||||
|
let mut ret = load_applications_for_app_ids(locale, app_ids.clone(), fill_missing_ones);
|
||||||
|
ret.sort_by(|a, b| {
|
||||||
|
app_ids
|
||||||
|
.clone()
|
||||||
|
.position(|id| id == a.id)
|
||||||
|
.unwrap()
|
||||||
|
.cmp(&app_ids.clone().position(|id| id == b.id).unwrap())
|
||||||
|
});
|
||||||
|
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
struct DockItem {
|
struct DockItem {
|
||||||
id: u32,
|
id: u32,
|
||||||
|
|
@ -354,7 +371,7 @@ impl cosmic::Application for CosmicAppList {
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let mut self_ = Self {
|
let mut self_ = Self {
|
||||||
core,
|
core,
|
||||||
favorite_list: load_applications_for_app_ids(
|
favorite_list: load_applications_for_app_ids_sorted(
|
||||||
None,
|
None,
|
||||||
config.favorites.iter().map(|s| &**s),
|
config.favorites.iter().map(|s| &**s),
|
||||||
true,
|
true,
|
||||||
|
|
@ -710,7 +727,7 @@ impl cosmic::Application for CosmicAppList {
|
||||||
info.app_id = format!("Unknown Application {}", self.item_ctr);
|
info.app_id = format!("Unknown Application {}", self.item_ctr);
|
||||||
}
|
}
|
||||||
self.item_ctr += 1;
|
self.item_ctr += 1;
|
||||||
let desktop_info = load_applications_for_app_ids(
|
let desktop_info = load_applications_for_app_ids_sorted(
|
||||||
None,
|
None,
|
||||||
std::iter::once(&*info.app_id),
|
std::iter::once(&*info.app_id),
|
||||||
true,
|
true,
|
||||||
|
|
@ -824,7 +841,7 @@ impl cosmic::Application for CosmicAppList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// pull back configured items into the favorites list
|
// pull back configured items into the favorites list
|
||||||
self.favorite_list = load_applications_for_app_ids(
|
self.favorite_list = load_applications_for_app_ids_sorted(
|
||||||
None,
|
None,
|
||||||
self.config.favorites.iter().map(|s| &**s),
|
self.config.favorites.iter().map(|s| &**s),
|
||||||
true,
|
true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue