From 056724268ea88b9ecc688b29996f6976a25fba3c Mon Sep 17 00:00:00 2001 From: Francesco Pio Gaglione Date: Fri, 16 Aug 2024 14:42:09 +0200 Subject: [PATCH 01/13] recent section --- Cargo.lock | 34 ++++++++++ Cargo.toml | 1 + i18n/en/cosmic_files.ftl | 1 + src/app.rs | 13 ++++ src/menu.rs | 2 +- src/tab.rs | 132 ++++++++++++++++++++++++++++++++++----- 6 files changed, 167 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c0f753..4aeb5ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1166,6 +1166,7 @@ dependencies = [ "open", "paste", "rayon", + "recently-used-xbel", "regex", "rust-embed", "serde", @@ -1446,6 +1447,15 @@ dependencies = [ "dirs-sys 0.3.7", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys 0.3.7", +] + [[package]] name = "dirs" version = "5.0.1" @@ -4598,6 +4608,18 @@ dependencies = [ "font-types", ] +[[package]] +name = "recently-used-xbel" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9533c371523034735c8c68da31004561dd011df9d45d0e5886c141858a7d17" +dependencies = [ + "dirs 4.0.0", + "serde", + "serde-xml-rs", + "thiserror", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -4948,6 +4970,18 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-xml-rs" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65162e9059be2f6a3421ebbb4fef3e74b7d9e7c60c50a0e292c6239f19f1edfa" +dependencies = [ + "log", + "serde", + "thiserror", + "xml-rs", +] + [[package]] name = "serde_derive" version = "1.0.204" diff --git a/Cargo.toml b/Cargo.toml index f89032c..5f8b36f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,6 +46,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" [dependencies.libcosmic] git = "https://github.com/pop-os/libcosmic.git" diff --git a/i18n/en/cosmic_files.ftl b/i18n/en/cosmic_files.ftl index c67b844..1fbc056 100644 --- a/i18n/en/cosmic_files.ftl +++ b/i18n/en/cosmic_files.ftl @@ -6,6 +6,7 @@ filesystem = Filesystem home = Home notification-in-progress = File operations are in progress. trash = Trash +recents = Recents undo = Undo # List view diff --git a/src/app.rs b/src/app.rs index 59109c8..3e376b1 100644 --- a/src/app.rs +++ b/src/app.rs @@ -107,6 +107,7 @@ pub enum Action { ZoomDefault, ZoomIn, ZoomOut, + Recents } impl Action { @@ -164,6 +165,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 } } } @@ -267,6 +269,7 @@ pub enum Message { DndExitTab, DndDropTab(Entity, Option, DndAction), DndDropNav(Entity, Option, DndAction), + Recents } #[derive(Clone, Copy, Debug, Eq, PartialEq)] @@ -509,6 +512,13 @@ impl App { fn update_nav_model(&mut self) { let mut nav_model = segmented_button::ModelBuilder::default(); + + nav_model = nav_model.insert(|b| { + b.text(fl!("recents")) + .icon(widget::icon::from_name("user-bookmarks-symbolic")) //TODO change icon with a watch icon like gnome recents + .data(Location::Recents) + }); + for (favorite_i, favorite) in self.config.favorites.iter().enumerate() { if let Some(path) = favorite.path_opt() { let name = if matches!(favorite, Favorite::Home) { @@ -2233,6 +2243,9 @@ impl Application for App { self.dialog_pages.push_front(DialogPage::EmptyTrash); } }, + Message::Recents => { + return self.open_tab(Location::Recents); + } } Command::none() diff --git a/src/menu.rs b/src/menu.rs index b0aa3fc..dbeac7e 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -92,7 +92,7 @@ pub fn context_menu<'a>( let mut children: Vec> = Vec::new(); match tab.location { - Location::Path(_) | Location::Search(_, _) => { + Location::Path(_) | Location::Search(_, _) | Location::Recents => { if selected > 0 { if selected_dir == 1 && selected == 1 || selected_dir == 0 { children.push(menu_item(fl!("open"), Action::Open).into()); diff --git a/src/tab.rs b/src/tab.rs index 9ac25e4..59f6bb9 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -33,21 +33,6 @@ use cosmic::{ Element, }; -use mime_guess::{mime, Mime}; -use once_cell::sync::Lazy; -use serde::{Deserialize, Serialize}; -use std::{ - cell::{Cell, RefCell}, - cmp::Ordering, - collections::HashMap, - fmt, - fs::{self, Metadata}, - num::NonZeroU16, - path::PathBuf, - sync::{Arc, Mutex}, - time::{Duration, Instant}, -}; - use crate::{ app::{self, Action}, clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste}, @@ -60,6 +45,24 @@ use crate::{ mime_icon::{mime_for_path, mime_icon}, mouse_area, }; +use chrono::{DateTime, ParseError, Utc}; +use mime_guess::{mime, Mime}; +use once_cell::sync::Lazy; +use recently_used_xbel::{Error, RecentlyUsed}; +use serde::{Deserialize, Serialize}; +use std::cmp::Reverse; +use std::iter::from_fn; +use std::{ + cell::{Cell, RefCell}, + cmp::Ordering, + collections::HashMap, + fmt, + fs::{self, Metadata}, + num::NonZeroU16, + path::PathBuf, + sync::{Arc, Mutex}, + time::{Duration, Instant}, +}; pub const DOUBLE_CLICK_DURATION: Duration = Duration::from_millis(500); pub const HOVER_DURATION: Duration = Duration::from_millis(1600); @@ -543,11 +546,85 @@ pub fn scan_trash(sizes: IconSizes) -> Vec { items } +fn uri_to_path(uri: String) -> Option { + //TODO support for external drive or cloud? + if uri.starts_with("file://") { + let path_str = &uri[7..]; + Some(PathBuf::from(path_str)) + } else { + None + } +} + +pub fn scan_recents(sizes: IconSizes) -> Vec { + let mut recent_files = recently_used_xbel::parse_file(); + + let mut recents = Vec::new(); + + match recent_files { + Ok(recent_files) => { + for bookmark in recent_files.bookmarks { + let uri = bookmark.href; + let path = match uri_to_path(uri) { + None => continue, + Some(path) => path, + }; + let last_edit = match bookmark.modified.parse::>() { + Ok(last_edit) => last_edit, + Err(_) => continue, + }; + let last_visit = match bookmark.visited.parse::>() { + Ok(last_visit) => last_visit, + Err(_) => continue, + }; + let path_buf = PathBuf::from(path); + let path_exist = path_buf.exists(); + + if path_exist { + let file_name = path_buf.file_name(); + + if let Some(name) = file_name { + let name = name.to_string_lossy().to_string(); + + let metadata = match path_buf.metadata() { + Ok(ok) => ok, + Err(err) => { + log::warn!( + "failed to read metadata for entry at {:?}: {}", + path_buf.clone(), + err + ); + continue; + } + }; + let item = item_from_entry(path_buf, name, metadata, sizes); + recents.push((item, if last_edit.le(&last_visit) { last_edit } else { last_visit })) + } + } else { + log::warn!("recent file path not exist: {:?}", path_buf); + } + } + } + Err(err) => { + log::warn!("Error reading recent files: {:?}", err); + } + } + + recents.sort_by(|a, b| b.1.cmp(&a.1)); + + let recent_items: Vec = recents.into_iter().take(50).map(|(item, _)| item).collect(); + + log::info!("items: {}", recent_items.len()); + + recent_items +} + #[derive(Clone, Debug, Eq, PartialEq)] pub enum Location { Path(PathBuf), Search(PathBuf, String), Trash, + Recents, } impl std::fmt::Display for Location { @@ -556,6 +633,7 @@ impl std::fmt::Display for Location { Self::Path(path) => write!(f, "{}", path.display()), Self::Search(path, term) => write!(f, "search {} for {}", path.display(), term), Self::Trash => write!(f, "trash"), + Self::Recents => write!(f, "recents"), } } } @@ -566,6 +644,7 @@ impl Location { Self::Path(path) => scan_path(path, sizes), Self::Search(path, term) => scan_search(path, term, sizes), Self::Trash => scan_trash(sizes), + Self::Recents => scan_recents(sizes), } } } @@ -979,6 +1058,9 @@ impl Tab { Location::Trash => { fl!("trash") } + Location::Recents => { + fl!("recents") + } } } @@ -1648,6 +1730,7 @@ impl Tab { Location::Trash => { cd = Some(location); } + Location::Recents => cd = Some(location), } } Message::LocationUp => { @@ -1789,6 +1872,9 @@ impl Tab { Location::Trash => { log::warn!("Copy to trash is not supported."); } + Location::Recents => { + log::warn!("Copy to recents is not supported."); + } }; } Message::Drop(None) => { @@ -1861,6 +1947,7 @@ impl Tab { Location::Path(path) => path.is_dir(), Location::Search(path, _term) => path.is_dir(), Location::Trash => true, + Location::Recents => true, } { self.change_location(&location, history_i_opt); commands.push(Command::ChangeLocation(self.title(), location)); @@ -2254,6 +2341,21 @@ impl Tab { .into(), ); } + Location::Recents => { + let mut row = widget::row::with_capacity(2) + .align_items(Alignment::Center) + .spacing(space_xxxs); + row = row.push(widget::icon::from_name("user-bookmarks-symbolic").size(16)); //TODO change with recent icon + row = row.push(widget::text::heading(fl!("recents"))); + + children.push( + widget::button(row) + .padding(space_xxxs) + .on_press(Message::Location(Location::Recents)) + .style(theme::Button::Text) + .into(), + ); + } } for child in children { From c087e85e121bcdccd93d47c9fdde877f11447828 Mon Sep 17 00:00:00 2001 From: Francesco Pio Gaglione Date: Fri, 16 Aug 2024 14:48:51 +0200 Subject: [PATCH 02/13] fix icons --- src/app.rs | 2 +- src/tab.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 3e376b1..ecb65bf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -515,7 +515,7 @@ impl App { nav_model = nav_model.insert(|b| { b.text(fl!("recents")) - .icon(widget::icon::from_name("user-bookmarks-symbolic")) //TODO change icon with a watch icon like gnome recents + .icon(widget::icon::from_name("accessories-clock-symbolic")) .data(Location::Recents) }); diff --git a/src/tab.rs b/src/tab.rs index 59f6bb9..a227053 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -2345,7 +2345,7 @@ impl Tab { let mut row = widget::row::with_capacity(2) .align_items(Alignment::Center) .spacing(space_xxxs); - row = row.push(widget::icon::from_name("user-bookmarks-symbolic").size(16)); //TODO change with recent icon + row = row.push(widget::icon::from_name("accessories-clock-symbolic").size(16)); row = row.push(widget::text::heading(fl!("recents"))); children.push( From 0c299950c9321830dac2bc643c1ddb88b945df5a Mon Sep 17 00:00:00 2001 From: Francesco Pio Gaglione Date: Tue, 20 Aug 2024 09:43:25 +0200 Subject: [PATCH 03/13] recents in dialog mode --- Cargo.toml | 6 ++++++ src/dialog.rs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 839d611..00cff78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,12 @@ edition = "2021" license = "GPL-3.0-only" rust-version = "1.71" +[[example]] +name = "dialog" # examples/dialog.rs + +[[example]] +name = "gvfs" # examples/gvfs.rs + [build-dependencies] vergen = { version = "8", features = ["git", "gitcl"] } diff --git a/src/dialog.rs b/src/dialog.rs index c713ac9..8f93fde 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -440,6 +440,13 @@ impl Application for App { let accept_label = flags.kind.accept_label(); let mut nav_model = segmented_button::ModelBuilder::default(); + + nav_model = nav_model.insert(move |b| { + b.text(fl!("recents")) + .icon(widget::icon::from_name("accessories-clock-symbolic").size(16)) + .data(Location::Recents) + }); + if let Some(dir) = dirs::home_dir() { nav_model = nav_model.insert(move |b| { b.text(fl!("home")) From bb2833e65ed7d04d1538cbed9dd6886cfefd888a Mon Sep 17 00:00:00 2001 From: Francesco Pio Gaglione Date: Tue, 20 Aug 2024 21:11:49 +0200 Subject: [PATCH 04/13] removed examples from cargo.toml --- Cargo.toml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 00cff78..839d611 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,6 @@ edition = "2021" license = "GPL-3.0-only" rust-version = "1.71" -[[example]] -name = "dialog" # examples/dialog.rs - -[[example]] -name = "gvfs" # examples/gvfs.rs - [build-dependencies] vergen = { version = "8", features = ["git", "gitcl"] } From 75d30ce216740e5f4600d075ea34fc6a89e479e3 Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Tue, 27 Aug 2024 08:59:32 +0200 Subject: [PATCH 05/13] merge --- Cargo.lock | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80d10c8..bedd384 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -929,6 +929,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cfb" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" +dependencies = [ + "byteorder", + "fnv", + "uuid", +] + [[package]] name = "cfg-expr" version = "0.15.8" @@ -1256,6 +1267,7 @@ dependencies = [ "open", "paste", "rayon", + "recently-used-xbel", "regex", "rust-embed", "serde", @@ -3222,6 +3234,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "infer" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc150e5ce2330295b8616ce0e3f53250e53af31759a9dbedad1621ba29151847" +dependencies = [ + "cfb", +] + [[package]] name = "inotify" version = "0.9.6" @@ -3543,7 +3564,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -4677,6 +4698,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.37" @@ -4770,6 +4801,22 @@ dependencies = [ "font-types", ] +[[package]] +name = "recently-used-xbel" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "079a81183e41e5cf17fd9ec55db30d6be6cddfad7fd619862efac27f1be28c9b" +dependencies = [ + "chrono", + "dirs 5.0.1", + "infer", + "mime_guess", + "quick-xml 0.36.1", + "serde", + "thiserror", + "url", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -6222,6 +6269,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" + [[package]] name = "valuable" version = "0.1.0" @@ -6662,7 +6715,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] From 0d9780ae1336e703f1dfc52c4ab298923d4edc99 Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Tue, 27 Aug 2024 09:04:52 +0200 Subject: [PATCH 06/13] merge --- src/tab.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/tab.rs b/src/tab.rs index c82b4eb..cb7a7f5 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -33,25 +33,11 @@ use cosmic::{ Element, }; -use crate::{ - app::{self, Action}, - clipboard::{ClipboardCopy, ClipboardKind, ClipboardPaste}, - config::{IconSizes, TabConfig, ICON_SCALE_MAX, ICON_SIZE_GRID}, - dialog::DialogKind, - fl, - localize::{LANGUAGE_CHRONO, LANGUAGE_SORTER}, - menu, - mime_app::{mime_apps, MimeApp}, - mime_icon::{mime_for_path, mime_icon}, - mouse_area, -}; -use chrono::{DateTime, ParseError, Utc}; +use chrono::{DateTime, Utc}; use mime_guess::{mime, Mime}; use once_cell::sync::Lazy; use recently_used_xbel::{Error, RecentlyUsed}; use serde::{Deserialize, Serialize}; -use std::cmp::Reverse; -use std::iter::from_fn; use std::{ cell::{Cell, RefCell}, cmp::Ordering, @@ -657,7 +643,14 @@ pub fn scan_recents(sizes: IconSizes) -> Vec { } }; let item = item_from_entry(path_buf, name, metadata, sizes); - recents.push((item, if last_edit.le(&last_visit) { last_edit } else { last_visit })) + recents.push(( + item, + if last_edit.le(&last_visit) { + last_edit + } else { + last_visit + }, + )) } } else { log::warn!("recent file path not exist: {:?}", path_buf); From 65aea7671ffa2fdb28a22d6eeab90fa4e5d8ae88 Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Tue, 27 Aug 2024 09:25:30 +0200 Subject: [PATCH 07/13] 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); } From 626a85868d8192133d73ce990b8c5094d5b47c49 Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Tue, 27 Aug 2024 19:01:36 +0200 Subject: [PATCH 08/13] removed logs --- src/tab.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/tab.rs b/src/tab.rs index cb7a7f5..f31e900 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -664,11 +664,7 @@ pub fn scan_recents(sizes: IconSizes) -> Vec { recents.sort_by(|a, b| b.1.cmp(&a.1)); - let recent_items: Vec = recents.into_iter().take(50).map(|(item, _)| item).collect(); - - log::info!("items: {}", recent_items.len()); - - recent_items + recents.into_iter().take(50).map(|(item, _)| item).collect() } #[derive(Clone, Debug, Eq, PartialEq)] From f8113947f5f0be58f7cc52588a71a67011e8512f Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Wed, 28 Aug 2024 08:54:44 +0200 Subject: [PATCH 09/13] merge --- Cargo.lock | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 90e3aa3..85c9ebf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -929,6 +929,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cfb" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f" +dependencies = [ + "byteorder", + "fnv", + "uuid", +] + [[package]] name = "cfg-expr" version = "0.15.8" @@ -1256,6 +1267,7 @@ dependencies = [ "open", "paste", "rayon", + "recently-used-xbel", "regex", "rust-embed", "serde", @@ -3221,6 +3233,15 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "infer" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc150e5ce2330295b8616ce0e3f53250e53af31759a9dbedad1621ba29151847" +dependencies = [ + "cfb", +] + [[package]] name = "inotify" version = "0.9.6" @@ -4677,6 +4698,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" version = "1.0.37" @@ -4770,6 +4801,22 @@ dependencies = [ "font-types", ] +[[package]] +name = "recently-used-xbel" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "079a81183e41e5cf17fd9ec55db30d6be6cddfad7fd619862efac27f1be28c9b" +dependencies = [ + "chrono", + "dirs 5.0.1", + "infer", + "mime_guess", + "quick-xml 0.36.1", + "serde", + "thiserror", + "url", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -6201,6 +6248,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "uuid" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" + [[package]] name = "uzers" version = "0.12.1" From bcfdc1138b4bbb2a8fd675537a8cadb2218ea0c4 Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Wed, 28 Aug 2024 08:58:44 +0200 Subject: [PATCH 10/13] fix app name --- src/app.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 2a8b5cb..12d4774 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1595,7 +1595,7 @@ impl Application for App { Ok(()) => { let _ = recently_used_xbel::update_recently_used( &path, - "org.cosmic.cosmic-files".to_string(), + "com.system76.cosmic-files".to_string(), "cosmic-files".to_string(), None, ); @@ -1988,7 +1988,7 @@ impl Application for App { Ok(()) => { let _ = recently_used_xbel::update_recently_used( &item_path, - "org.cosmic.cosmic-files".to_string(), + "com.system76.cosmic-files".to_string(), "cosmic-files".to_string(), None, ); From dc5842e5d58f1d3c71abbeb2ccf9111cbbced50c Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Mon, 2 Sep 2024 23:39:56 +0200 Subject: [PATCH 11/13] fix app id --- src/app.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 12d4774..d1f5d9b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1595,7 +1595,7 @@ impl Application for App { Ok(()) => { let _ = recently_used_xbel::update_recently_used( &path, - "com.system76.cosmic-files".to_string(), + App::APP_ID.to_string(), "cosmic-files".to_string(), None, ); @@ -1988,7 +1988,7 @@ impl Application for App { Ok(()) => { let _ = recently_used_xbel::update_recently_used( &item_path, - "com.system76.cosmic-files".to_string(), + App::APP_ID.to_string(), "cosmic-files".to_string(), None, ); From da52e8aa6e76d8e7cefe89dfddfe70f6753b0d0a Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Tue, 3 Sep 2024 00:09:49 +0200 Subject: [PATCH 12/13] update recently used on dialog open --- src/dialog.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dialog.rs b/src/dialog.rs index 8f93fde..47ec081 100644 --- a/src/dialog.rs +++ b/src/dialog.rs @@ -25,6 +25,7 @@ use notify_debouncer_full::{ notify::{self, RecommendedWatcher, Watcher}, DebouncedEvent, Debouncer, FileIdMap, }; +use recently_used_xbel::update_recently_used; use std::{ any::TypeId, collections::{HashMap, HashSet}, @@ -440,7 +441,7 @@ impl Application for App { let accept_label = flags.kind.accept_label(); let mut nav_model = segmented_button::ModelBuilder::default(); - + nav_model = nav_model.insert(move |b| { b.text(fl!("recents")) .icon(widget::icon::from_name("accessories-clock-symbolic").size(16)) @@ -673,6 +674,12 @@ impl Application for App { if item.selected { if let Some(path) = &item.path_opt { paths.push(path.clone()); + let _ = update_recently_used( + &path.clone(), + App::APP_ID.to_string(), + "cosmic-files".to_string(), + None, + ); } } } From 08324834fa85f2455901f5a8eb53a9fb9cb37290 Mon Sep 17 00:00:00 2001 From: Francesco-gaglione Date: Tue, 3 Sep 2024 00:21:53 +0200 Subject: [PATCH 13/13] some lang update --- i18n/ar/cosmic_files.ftl | 1 + i18n/cs/cosmic_files.ftl | 1 + i18n/de/cosmic_files.ftl | 1 + i18n/es/cosmic_files.ftl | 1 + i18n/fr/cosmic_files.ftl | 1 + i18n/it/cosmic_files.ftl | 1 + i18n/uk/cosmic_files.ftl | 1 + 7 files changed, 7 insertions(+) diff --git a/i18n/ar/cosmic_files.ftl b/i18n/ar/cosmic_files.ftl index acd208a..920647c 100644 --- a/i18n/ar/cosmic_files.ftl +++ b/i18n/ar/cosmic_files.ftl @@ -4,6 +4,7 @@ empty-folder-hidden = مجلّد فارغ (يحتوي على ملفّات أو filesystem = نظام ملفات home = منزل trash = مُهملات +recents = حديثاً # List view name = اسم diff --git a/i18n/cs/cosmic_files.ftl b/i18n/cs/cosmic_files.ftl index 395e234..02a9563 100644 --- a/i18n/cs/cosmic_files.ftl +++ b/i18n/cs/cosmic_files.ftl @@ -3,6 +3,7 @@ empty-folder = Složka je prázdná empty-folder-hidden = Složka je prázdná (obsahuje skryté položky) filesystem = Souborový systém home = Domů +recents = Nedávné trash = Koš # List view diff --git a/i18n/de/cosmic_files.ftl b/i18n/de/cosmic_files.ftl index 7abaca1..d5da3c2 100644 --- a/i18n/de/cosmic_files.ftl +++ b/i18n/de/cosmic_files.ftl @@ -4,6 +4,7 @@ empty-folder-hidden = Leerer Ordner (hat versteckte Elemente) filesystem = Dateisystem home = Benutzerordner trash = Papierkorb +recents = Aktuelle undo = Rückgängig # Listenansicht diff --git a/i18n/es/cosmic_files.ftl b/i18n/es/cosmic_files.ftl index 0f63d36..4cc352b 100644 --- a/i18n/es/cosmic_files.ftl +++ b/i18n/es/cosmic_files.ftl @@ -3,6 +3,7 @@ empty-folder = Carpeta vacía empty-folder-hidden = Carpeta vacía (tiene elementos escondidos) filesystem = Sistema de archivos home = Inicio +recents = Reciente trash = Papelera # List view diff --git a/i18n/fr/cosmic_files.ftl b/i18n/fr/cosmic_files.ftl index 4a980ea..abfe553 100644 --- a/i18n/fr/cosmic_files.ftl +++ b/i18n/fr/cosmic_files.ftl @@ -5,6 +5,7 @@ filesystem = Système de fichiers home = Dossier personnel notification-in-progress = Les opérations sur les fichiers sont en cours. trash = Corbeille +recents = Récente undo = Annuler # List view diff --git a/i18n/it/cosmic_files.ftl b/i18n/it/cosmic_files.ftl index ddd8a3e..a1bfc59 100644 --- a/i18n/it/cosmic_files.ftl +++ b/i18n/it/cosmic_files.ftl @@ -6,6 +6,7 @@ filesystem = Filesystem home = Home notification-in-progress = Operazioni sui file in corso ... trash = Cestino +recents = Recenti undo = Annulla ultima operazione # List view diff --git a/i18n/uk/cosmic_files.ftl b/i18n/uk/cosmic_files.ftl index c025a4b..1f93011 100644 --- a/i18n/uk/cosmic_files.ftl +++ b/i18n/uk/cosmic_files.ftl @@ -4,6 +4,7 @@ empty-folder-hidden = Тека порожня (але містить прихо filesystem = Файлова система home = Домівка trash = Смітник +recents = недавній undo = Скасувати # List view