sort startup applications and all apps by name for improved organization
This commit is contained in:
parent
6db1e6a17b
commit
d6bf77bf3a
1 changed files with 37 additions and 1 deletions
|
|
@ -142,8 +142,21 @@ impl page::Page<crate::pages::Message> for Page {
|
||||||
let user_entries =
|
let user_entries =
|
||||||
freedesktop_desktop_entry::Iter::new(user_dirs.into_iter()).entries(Some(&locales));
|
freedesktop_desktop_entry::Iter::new(user_dirs.into_iter()).entries(Some(&locales));
|
||||||
|
|
||||||
|
let mut user_entries_vec = user_entries.collect_vec();
|
||||||
|
user_entries_vec.sort_by(|a, b| {
|
||||||
|
let name_a = a
|
||||||
|
.name(&locales)
|
||||||
|
.map(|n| n.to_lowercase())
|
||||||
|
.unwrap_or_else(|| a.appid.to_lowercase());
|
||||||
|
let name_b = b
|
||||||
|
.name(&locales)
|
||||||
|
.map(|n| n.to_lowercase())
|
||||||
|
.unwrap_or_else(|| b.appid.to_lowercase());
|
||||||
|
name_a.cmp(&name_b)
|
||||||
|
});
|
||||||
|
|
||||||
let mut apps_hash = HashMap::with_capacity(1);
|
let mut apps_hash = HashMap::with_capacity(1);
|
||||||
apps_hash.insert(DirectoryType::User, user_entries.collect_vec());
|
apps_hash.insert(DirectoryType::User, user_entries_vec);
|
||||||
|
|
||||||
Message::UpdateStartupApplications(CachedApps {
|
Message::UpdateStartupApplications(CachedApps {
|
||||||
apps: apps_hash,
|
apps: apps_hash,
|
||||||
|
|
@ -246,6 +259,17 @@ impl Page {
|
||||||
if let Some(target_apps) = target_apps {
|
if let Some(target_apps) = target_apps {
|
||||||
let mut new_apps = target_apps.clone();
|
let mut new_apps = target_apps.clone();
|
||||||
new_apps.push(app.clone());
|
new_apps.push(app.clone());
|
||||||
|
new_apps.sort_by(|a, b| {
|
||||||
|
let name_a = a
|
||||||
|
.name(&cached_startup_apps.locales)
|
||||||
|
.map(|n| n.to_lowercase())
|
||||||
|
.unwrap_or_else(|| a.appid.to_lowercase());
|
||||||
|
let name_b = b
|
||||||
|
.name(&cached_startup_apps.locales)
|
||||||
|
.map(|n| n.to_lowercase())
|
||||||
|
.unwrap_or_else(|| b.appid.to_lowercase());
|
||||||
|
name_a.cmp(&name_b)
|
||||||
|
});
|
||||||
|
|
||||||
cached_startup_apps
|
cached_startup_apps
|
||||||
.apps
|
.apps
|
||||||
|
|
@ -473,5 +497,17 @@ fn get_all_apps(locales: Vec<String>) -> Vec<DesktopEntry> {
|
||||||
dedupe.insert(app_id.to_owned());
|
dedupe.insert(app_id.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result.sort_by(|a, b| {
|
||||||
|
let name_a = a
|
||||||
|
.name(&locales)
|
||||||
|
.map(|n| n.to_lowercase())
|
||||||
|
.unwrap_or_else(|| a.appid.to_lowercase());
|
||||||
|
let name_b = b
|
||||||
|
.name(&locales)
|
||||||
|
.map(|n| n.to_lowercase())
|
||||||
|
.unwrap_or_else(|| b.appid.to_lowercase());
|
||||||
|
name_a.cmp(&name_b)
|
||||||
|
});
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue