Put default app first in open with list
This commit is contained in:
parent
3e1e6b090e
commit
a4efff3873
3 changed files with 17 additions and 4 deletions
|
|
@ -51,6 +51,10 @@ pending = Pending
|
||||||
failed = Failed
|
failed = Failed
|
||||||
complete = Complete
|
complete = Complete
|
||||||
|
|
||||||
|
## Open with
|
||||||
|
open-with = Open with
|
||||||
|
default-app = {$name} (default)
|
||||||
|
|
||||||
## Properties
|
## Properties
|
||||||
properties = Properties
|
properties = Properties
|
||||||
|
|
||||||
|
|
@ -71,7 +75,6 @@ light = Light
|
||||||
# Context menu
|
# Context menu
|
||||||
new-file = New file
|
new-file = New file
|
||||||
new-folder = New folder
|
new-folder = New folder
|
||||||
open-with = Open with
|
|
||||||
open-in-terminal = Open in terminal
|
open-in-terminal = Open in terminal
|
||||||
move-to-trash = Move to trash
|
move-to-trash = Move to trash
|
||||||
restore-from-trash = Restore from trash
|
restore-from-trash = Restore from trash
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ use cosmic::desktop;
|
||||||
use cosmic::widget;
|
use cosmic::widget;
|
||||||
pub use mime_guess::Mime;
|
pub use mime_guess::Mime;
|
||||||
use once_cell::sync::Lazy;
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct MimeApp {
|
pub struct MimeApp {
|
||||||
|
|
@ -218,7 +220,11 @@ impl MimeAppCache {
|
||||||
|
|
||||||
// Sort apps by name
|
// Sort apps by name
|
||||||
for apps in self.cache.values_mut() {
|
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();
|
let elapsed = start.elapsed();
|
||||||
|
|
|
||||||
|
|
@ -525,7 +525,11 @@ impl Item {
|
||||||
widget::button(
|
widget::button(
|
||||||
widget::row::with_children(vec![
|
widget::row::with_children(vec![
|
||||||
widget::icon(app.icon.clone()).into(),
|
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),
|
.spacing(space_xs),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue