From 65aea7671ffa2fdb28a22d6eeab90fa4e5d8ae88 Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Tue, 27 Aug 2024 09:25:30 +0200 Subject: [PATCH] update recently used on file open --- Cargo.toml | 2 +- src/app.rs | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 578ce5a..76af17d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ i18n-embed = { version = "0.14", features = [ i18n-embed-fl = "0.7" rust-embed = "8" slotmap = "1.0.7" -recently-used-xbel = "1.0.0" +recently-used-xbel = "1.1.0" zip = "2.1.6" unix_permissions_ext = "0.1.2" users = "0.11.0" diff --git a/src/app.rs b/src/app.rs index 91e5cd0..2a8b5cb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -109,7 +109,7 @@ pub enum Action { ZoomDefault, ZoomIn, ZoomOut, - Recents + Recents, } impl Action { @@ -169,7 +169,7 @@ impl Action { Action::ZoomDefault => Message::TabMessage(entity_opt, tab::Message::ZoomDefault), Action::ZoomIn => Message::TabMessage(entity_opt, tab::Message::ZoomIn), 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, DndDropTab(Entity, Option, DndAction), DndDropNav(Entity, Option, DndAction), - Recents + Recents, } #[derive(Clone, Copy, Debug, Eq, PartialEq)] @@ -1592,7 +1592,14 @@ impl Application for App { Message::OpenWith(path, app) => { if let Some(mut command) = app.command(Some(path.clone())) { 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) => { log::warn!("failed to open {:?} with {:?}: {}", path, app.id, err) } @@ -1978,7 +1985,14 @@ impl Application for App { } tab::Command::OpenFile(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) => { log::warn!("failed to open {:?}: {}", item_path, err); }