Merge pull request #400 from francesco-gaglione/recent_section
Recents section
This commit is contained in:
commit
c4c92be708
14 changed files with 210 additions and 3 deletions
53
Cargo.lock
generated
53
Cargo.lock
generated
|
|
@ -929,6 +929,17 @@ version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
|
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]]
|
[[package]]
|
||||||
name = "cfg-expr"
|
name = "cfg-expr"
|
||||||
version = "0.15.8"
|
version = "0.15.8"
|
||||||
|
|
@ -1256,6 +1267,7 @@ dependencies = [
|
||||||
"open",
|
"open",
|
||||||
"paste",
|
"paste",
|
||||||
"rayon",
|
"rayon",
|
||||||
|
"recently-used-xbel",
|
||||||
"regex",
|
"regex",
|
||||||
"rust-embed",
|
"rust-embed",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
@ -3223,6 +3235,15 @@ dependencies = [
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "infer"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc150e5ce2330295b8616ce0e3f53250e53af31759a9dbedad1621ba29151847"
|
||||||
|
dependencies = [
|
||||||
|
"cfb",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "inotify"
|
name = "inotify"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
|
|
@ -4679,6 +4700,16 @@ dependencies = [
|
||||||
"memchr",
|
"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]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.37"
|
version = "1.0.37"
|
||||||
|
|
@ -4772,6 +4803,22 @@ dependencies = [
|
||||||
"font-types",
|
"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]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
|
@ -6203,6 +6250,12 @@ version = "0.2.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uzers"
|
name = "uzers"
|
||||||
version = "0.12.1"
|
version = "0.12.1"
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,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.1.0"
|
||||||
zip = "2.1.6"
|
zip = "2.1.6"
|
||||||
unix_permissions_ext = "0.1.2"
|
unix_permissions_ext = "0.1.2"
|
||||||
uzers = "0.12.0"
|
uzers = "0.12.0"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ empty-folder-hidden = مجلّد فارغ (يحتوي على ملفّات أو
|
||||||
filesystem = نظام ملفات
|
filesystem = نظام ملفات
|
||||||
home = منزل
|
home = منزل
|
||||||
trash = مُهملات
|
trash = مُهملات
|
||||||
|
recents = حديثاً
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
name = اسم
|
name = اسم
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ empty-folder = Složka je prázdná
|
||||||
empty-folder-hidden = Složka je prázdná (obsahuje skryté položky)
|
empty-folder-hidden = Složka je prázdná (obsahuje skryté položky)
|
||||||
filesystem = Souborový systém
|
filesystem = Souborový systém
|
||||||
home = Domů
|
home = Domů
|
||||||
|
recents = Nedávné
|
||||||
trash = Koš
|
trash = Koš
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ empty-folder-hidden = Leerer Ordner (hat versteckte Elemente)
|
||||||
filesystem = Dateisystem
|
filesystem = Dateisystem
|
||||||
home = Benutzerordner
|
home = Benutzerordner
|
||||||
trash = Papierkorb
|
trash = Papierkorb
|
||||||
|
recents = Aktuelle
|
||||||
undo = Rückgängig
|
undo = Rückgängig
|
||||||
|
|
||||||
# Listenansicht
|
# Listenansicht
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ filesystem = Filesystem
|
||||||
home = Home
|
home = Home
|
||||||
notification-in-progress = File operations are in progress.
|
notification-in-progress = File operations are in progress.
|
||||||
trash = Trash
|
trash = Trash
|
||||||
|
recents = Recents
|
||||||
undo = Undo
|
undo = Undo
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ empty-folder = Carpeta vacía
|
||||||
empty-folder-hidden = Carpeta vacía (tiene elementos escondidos)
|
empty-folder-hidden = Carpeta vacía (tiene elementos escondidos)
|
||||||
filesystem = Sistema de archivos
|
filesystem = Sistema de archivos
|
||||||
home = Inicio
|
home = Inicio
|
||||||
|
recents = Reciente
|
||||||
trash = Papelera
|
trash = Papelera
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ filesystem = Système de fichiers
|
||||||
home = Dossier personnel
|
home = Dossier personnel
|
||||||
notification-in-progress = Les opérations sur les fichiers sont en cours.
|
notification-in-progress = Les opérations sur les fichiers sont en cours.
|
||||||
trash = Corbeille
|
trash = Corbeille
|
||||||
|
recents = Récente
|
||||||
undo = Annuler
|
undo = Annuler
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ filesystem = Filesystem
|
||||||
home = Home
|
home = Home
|
||||||
notification-in-progress = Operazioni sui file in corso ...
|
notification-in-progress = Operazioni sui file in corso ...
|
||||||
trash = Cestino
|
trash = Cestino
|
||||||
|
recents = Recenti
|
||||||
undo = Annulla ultima operazione
|
undo = Annulla ultima operazione
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ empty-folder-hidden = Тека порожня (але містить прихо
|
||||||
filesystem = Файлова система
|
filesystem = Файлова система
|
||||||
home = Домівка
|
home = Домівка
|
||||||
trash = Смітник
|
trash = Смітник
|
||||||
|
recents = недавній
|
||||||
undo = Скасувати
|
undo = Скасувати
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
|
|
|
||||||
31
src/app.rs
31
src/app.rs
|
|
@ -110,6 +110,7 @@ pub enum Action {
|
||||||
ZoomDefault,
|
ZoomDefault,
|
||||||
ZoomIn,
|
ZoomIn,
|
||||||
ZoomOut,
|
ZoomOut,
|
||||||
|
Recents,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Action {
|
impl Action {
|
||||||
|
|
@ -170,6 +171,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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -277,6 +279,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,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
|
|
@ -549,6 +552,13 @@ impl App {
|
||||||
|
|
||||||
fn update_nav_model(&mut self) {
|
fn update_nav_model(&mut self) {
|
||||||
let mut nav_model = segmented_button::ModelBuilder::default();
|
let mut nav_model = segmented_button::ModelBuilder::default();
|
||||||
|
|
||||||
|
nav_model = nav_model.insert(|b| {
|
||||||
|
b.text(fl!("recents"))
|
||||||
|
.icon(widget::icon::from_name("accessories-clock-symbolic"))
|
||||||
|
.data(Location::Recents)
|
||||||
|
});
|
||||||
|
|
||||||
for (favorite_i, favorite) in self.config.favorites.iter().enumerate() {
|
for (favorite_i, favorite) in self.config.favorites.iter().enumerate() {
|
||||||
if let Some(path) = favorite.path_opt() {
|
if let Some(path) = favorite.path_opt() {
|
||||||
let name = if matches!(favorite, Favorite::Home) {
|
let name = if matches!(favorite, Favorite::Home) {
|
||||||
|
|
@ -1633,7 +1643,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,
|
||||||
|
App::APP_ID.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)
|
||||||
}
|
}
|
||||||
|
|
@ -2030,7 +2047,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,
|
||||||
|
App::APP_ID.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);
|
||||||
}
|
}
|
||||||
|
|
@ -2346,6 +2370,9 @@ impl Application for App {
|
||||||
self.dialog_pages.push_front(DialogPage::EmptyTrash);
|
self.dialog_pages.push_front(DialogPage::EmptyTrash);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Message::Recents => {
|
||||||
|
return self.open_tab(Location::Recents, false, None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::none()
|
Command::none()
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ use notify_debouncer_full::{
|
||||||
notify::{self, RecommendedWatcher, Watcher},
|
notify::{self, RecommendedWatcher, Watcher},
|
||||||
DebouncedEvent, Debouncer, FileIdMap,
|
DebouncedEvent, Debouncer, FileIdMap,
|
||||||
};
|
};
|
||||||
|
use recently_used_xbel::update_recently_used;
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
|
@ -440,6 +441,13 @@ impl Application for App {
|
||||||
let accept_label = flags.kind.accept_label();
|
let accept_label = flags.kind.accept_label();
|
||||||
|
|
||||||
let mut nav_model = segmented_button::ModelBuilder::default();
|
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() {
|
if let Some(dir) = dirs::home_dir() {
|
||||||
nav_model = nav_model.insert(move |b| {
|
nav_model = nav_model.insert(move |b| {
|
||||||
b.text(fl!("home"))
|
b.text(fl!("home"))
|
||||||
|
|
@ -666,6 +674,12 @@ impl Application for App {
|
||||||
if item.selected {
|
if item.selected {
|
||||||
if let Some(path) = &item.path_opt {
|
if let Some(path) = &item.path_opt {
|
||||||
paths.push(path.clone());
|
paths.push(path.clone());
|
||||||
|
let _ = update_recently_used(
|
||||||
|
&path.clone(),
|
||||||
|
App::APP_ID.to_string(),
|
||||||
|
"cosmic-files".to_string(),
|
||||||
|
None,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ pub fn context_menu<'a>(
|
||||||
|
|
||||||
let mut children: Vec<Element<_>> = Vec::new();
|
let mut children: Vec<Element<_>> = Vec::new();
|
||||||
match tab.location {
|
match tab.location {
|
||||||
Location::Path(_) | Location::Search(_, _) => {
|
Location::Path(_) | Location::Search(_, _) | Location::Recents => {
|
||||||
if selected > 0 {
|
if selected > 0 {
|
||||||
if selected_dir == 1 && selected == 1 || selected_dir == 0 {
|
if selected_dir == 1 && selected == 1 || selected_dir == 0 {
|
||||||
children.push(menu_item(fl!("open"), Action::Open).into());
|
children.push(menu_item(fl!("open"), Action::Open).into());
|
||||||
|
|
|
||||||
104
src/tab.rs
104
src/tab.rs
|
|
@ -33,8 +33,10 @@ use cosmic::{
|
||||||
Element,
|
Element,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use mime_guess::{mime, Mime};
|
use mime_guess::{mime, Mime};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
use recently_used_xbel::{Error, RecentlyUsed};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
|
|
@ -589,11 +591,88 @@ pub fn scan_trash(sizes: IconSizes) -> Vec<Item> {
|
||||||
items
|
items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn uri_to_path(uri: String) -> Option<PathBuf> {
|
||||||
|
//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<Item> {
|
||||||
|
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::<DateTime<Utc>>() {
|
||||||
|
Ok(last_edit) => last_edit,
|
||||||
|
Err(_) => continue,
|
||||||
|
};
|
||||||
|
let last_visit = match bookmark.visited.parse::<DateTime<Utc>>() {
|
||||||
|
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));
|
||||||
|
|
||||||
|
recents.into_iter().take(50).map(|(item, _)| item).collect()
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum Location {
|
pub enum Location {
|
||||||
Path(PathBuf),
|
Path(PathBuf),
|
||||||
Search(PathBuf, String),
|
Search(PathBuf, String),
|
||||||
Trash,
|
Trash,
|
||||||
|
Recents,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for Location {
|
impl std::fmt::Display for Location {
|
||||||
|
|
@ -602,6 +681,7 @@ impl std::fmt::Display for Location {
|
||||||
Self::Path(path) => write!(f, "{}", path.display()),
|
Self::Path(path) => write!(f, "{}", path.display()),
|
||||||
Self::Search(path, term) => write!(f, "search {} for {}", path.display(), term),
|
Self::Search(path, term) => write!(f, "search {} for {}", path.display(), term),
|
||||||
Self::Trash => write!(f, "trash"),
|
Self::Trash => write!(f, "trash"),
|
||||||
|
Self::Recents => write!(f, "recents"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -612,6 +692,7 @@ impl Location {
|
||||||
Self::Path(path) => scan_path(path, sizes),
|
Self::Path(path) => scan_path(path, sizes),
|
||||||
Self::Search(path, term) => scan_search(path, term, sizes),
|
Self::Search(path, term) => scan_search(path, term, sizes),
|
||||||
Self::Trash => scan_trash(sizes),
|
Self::Trash => scan_trash(sizes),
|
||||||
|
Self::Recents => scan_recents(sizes),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1088,6 +1169,9 @@ impl Tab {
|
||||||
Location::Trash => {
|
Location::Trash => {
|
||||||
fl!("trash")
|
fl!("trash")
|
||||||
}
|
}
|
||||||
|
Location::Recents => {
|
||||||
|
fl!("recents")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1765,6 +1849,7 @@ impl Tab {
|
||||||
Location::Trash => {
|
Location::Trash => {
|
||||||
cd = Some(location);
|
cd = Some(location);
|
||||||
}
|
}
|
||||||
|
Location::Recents => cd = Some(location),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::LocationUp => {
|
Message::LocationUp => {
|
||||||
|
|
@ -1906,6 +1991,9 @@ impl Tab {
|
||||||
Location::Trash => {
|
Location::Trash => {
|
||||||
log::warn!("Copy to trash is not supported.");
|
log::warn!("Copy to trash is not supported.");
|
||||||
}
|
}
|
||||||
|
Location::Recents => {
|
||||||
|
log::warn!("Copy to recents is not supported.");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Message::Drop(None) => {
|
Message::Drop(None) => {
|
||||||
|
|
@ -1978,6 +2066,7 @@ impl Tab {
|
||||||
Location::Path(path) => path.is_dir(),
|
Location::Path(path) => path.is_dir(),
|
||||||
Location::Search(path, _term) => path.is_dir(),
|
Location::Search(path, _term) => path.is_dir(),
|
||||||
Location::Trash => true,
|
Location::Trash => true,
|
||||||
|
Location::Recents => true,
|
||||||
} {
|
} {
|
||||||
let prev_path = if let Location::Path(path) = &self.location {
|
let prev_path = if let Location::Path(path) = &self.location {
|
||||||
Some(path.clone())
|
Some(path.clone())
|
||||||
|
|
@ -2341,6 +2430,21 @@ impl Tab {
|
||||||
.into(),
|
.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("accessories-clock-symbolic").size(16));
|
||||||
|
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 {
|
for child in children {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue