diff --git a/i18n/en/cosmic_files.ftl b/i18n/en/cosmic_files.ftl index 8ec0aa8..5fdda14 100644 --- a/i18n/en/cosmic_files.ftl +++ b/i18n/en/cosmic_files.ftl @@ -51,6 +51,10 @@ pending = Pending failed = Failed complete = Complete +## Open with +open-with = Open with +default-app = {$name} (default) + ## Properties properties = Properties @@ -71,7 +75,6 @@ light = Light # Context menu new-file = New file new-folder = New folder -open-with = Open with open-in-terminal = Open in terminal move-to-trash = Move to trash restore-from-trash = Restore from trash diff --git a/src/mime_app.rs b/src/mime_app.rs index d69807c..57104d6 100644 --- a/src/mime_app.rs +++ b/src/mime_app.rs @@ -6,7 +6,9 @@ use cosmic::desktop; use cosmic::widget; pub use mime_guess::Mime; use once_cell::sync::Lazy; -use std::{collections::HashMap, path::PathBuf, process, sync::Mutex, time::Instant}; +use std::{ + cmp::Ordering, collections::HashMap, path::PathBuf, process, sync::Mutex, time::Instant, +}; #[derive(Clone, Debug)] pub struct MimeApp { @@ -218,7 +220,11 @@ impl MimeAppCache { // Sort apps by name for apps in self.cache.values_mut() { - apps.sort_by(|a, b| lexical_sort::natural_lexical_cmp(&a.name, &b.name)); + apps.sort_by(|a, b| match (a.is_default, b.is_default) { + (true, false) => Ordering::Less, + (false, true) => Ordering::Greater, + _ => lexical_sort::natural_lexical_cmp(&a.name, &b.name), + }); } let elapsed = start.elapsed(); diff --git a/src/tab.rs b/src/tab.rs index e3dcc6a..c167a5b 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -525,7 +525,11 @@ impl Item { widget::button( widget::row::with_children(vec![ widget::icon(app.icon.clone()).into(), - widget::text(&app.name).into(), + if app.is_default { + widget::text(fl!("default-app", name = app.name.as_str())).into() + } else { + widget::text(&app.name).into() + }, ]) .spacing(space_xs), )