update recently used on file open

This commit is contained in:
Francesco-gaglione 2024-08-27 09:25:30 +02:00
parent 0d9780ae13
commit 65aea7671f
2 changed files with 20 additions and 6 deletions

View file

@ -47,7 +47,7 @@ i18n-embed = { version = "0.14", features = [
i18n-embed-fl = "0.7" i18n-embed-fl = "0.7"
rust-embed = "8" rust-embed = "8"
slotmap = "1.0.7" slotmap = "1.0.7"
recently-used-xbel = "1.0.0" recently-used-xbel = "1.1.0"
zip = "2.1.6" zip = "2.1.6"
unix_permissions_ext = "0.1.2" unix_permissions_ext = "0.1.2"
users = "0.11.0" users = "0.11.0"

View file

@ -109,7 +109,7 @@ pub enum Action {
ZoomDefault, ZoomDefault,
ZoomIn, ZoomIn,
ZoomOut, ZoomOut,
Recents Recents,
} }
impl Action { impl Action {
@ -169,7 +169,7 @@ impl Action {
Action::ZoomDefault => Message::TabMessage(entity_opt, tab::Message::ZoomDefault), Action::ZoomDefault => Message::TabMessage(entity_opt, tab::Message::ZoomDefault),
Action::ZoomIn => Message::TabMessage(entity_opt, tab::Message::ZoomIn), Action::ZoomIn => Message::TabMessage(entity_opt, tab::Message::ZoomIn),
Action::ZoomOut => Message::TabMessage(entity_opt, tab::Message::ZoomOut), Action::ZoomOut => Message::TabMessage(entity_opt, tab::Message::ZoomOut),
Action::Recents => Message::Recents Action::Recents => Message::Recents,
} }
} }
} }
@ -276,7 +276,7 @@ pub enum Message {
DndExitTab, DndExitTab,
DndDropTab(Entity, Option<ClipboardPaste>, DndAction), DndDropTab(Entity, Option<ClipboardPaste>, DndAction),
DndDropNav(Entity, Option<ClipboardPaste>, DndAction), DndDropNav(Entity, Option<ClipboardPaste>, DndAction),
Recents Recents,
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
@ -1592,7 +1592,14 @@ impl Application for App {
Message::OpenWith(path, app) => { Message::OpenWith(path, app) => {
if let Some(mut command) = app.command(Some(path.clone())) { if let Some(mut command) = app.command(Some(path.clone())) {
match spawn_detached(&mut command) { match spawn_detached(&mut command) {
Ok(()) => {} Ok(()) => {
let _ = recently_used_xbel::update_recently_used(
&path,
"org.cosmic.cosmic-files".to_string(),
"cosmic-files".to_string(),
None,
);
}
Err(err) => { Err(err) => {
log::warn!("failed to open {:?} with {:?}: {}", path, app.id, err) log::warn!("failed to open {:?} with {:?}: {}", path, app.id, err)
} }
@ -1978,7 +1985,14 @@ impl Application for App {
} }
tab::Command::OpenFile(item_path) => { tab::Command::OpenFile(item_path) => {
match open::that_detached(&item_path) { match open::that_detached(&item_path) {
Ok(()) => (), Ok(()) => {
let _ = recently_used_xbel::update_recently_used(
&item_path,
"org.cosmic.cosmic-files".to_string(),
"cosmic-files".to_string(),
None,
);
}
Err(err) => { Err(err) => {
log::warn!("failed to open {:?}: {}", item_path, err); log::warn!("failed to open {:?}: {}", item_path, err);
} }