Merge pull request #1777 from norepro/add-clear-recents-button

feat(files): Add button to clear recents
This commit is contained in:
Jeremy Soller 2026-05-11 15:04:34 -06:00 committed by GitHub
commit 3548615d40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 0 deletions

View file

@ -4576,6 +4576,14 @@ impl Application for App {
tab::Command::DropFiles(to, from) => {
commands.push(self.update(Message::PasteContents(to, from)));
}
tab::Command::ClearRecents => {
match recently_used_xbel::clear_recently_used() {
Ok(()) => {}
Err(err) => {
log::warn!("failed to clear recents history: {}", err);
}
}
}
tab::Command::EmptyTrash => {
return self.push_dialog(
DialogPage::EmptyTrash,

View file

@ -1663,6 +1663,7 @@ pub enum Command {
ContextMenu(Option<Point>, Option<window::Id>),
Delete(Vec<PathBuf>),
DropFiles(PathBuf, ClipboardPaste),
ClearRecents,
EmptyTrash,
#[cfg(feature = "desktop")]
ExecEntryAction(cosmic::desktop::DesktopEntryData, usize),
@ -1702,6 +1703,7 @@ pub enum Message {
EditLocationSubmit,
EditLocationTab,
OpenInNewTab(PathBuf),
ClearRecents,
EmptyTrash,
#[cfg(feature = "desktop")]
ExecEntryAction(Option<PathBuf>, usize),
@ -3677,6 +3679,9 @@ impl Tab {
Message::OpenInNewTab(path) => {
commands.push(Command::OpenInNewTab(path));
}
Message::ClearRecents => {
commands.push(Command::ClearRecents);
}
Message::EmptyTrash => {
commands.push(Command::EmptyTrash);
}
@ -6192,6 +6197,24 @@ impl Tab {
);
}
}
Location::Recents | Location::Search(SearchLocation::Recents, ..) => {
if let Some(items) = self.items_opt()
&& !items.is_empty()
{
tab_column = tab_column.push(
widget::layer_container(widget::row::with_children([
widget::space::horizontal().into(),
widget::button::standard(fl!("clear-recents-history"))
.on_press(Message::ClearRecents)
.into(),
]))
.padding([space_xxs, space_xs])
.layer(cosmic_theme::Layer::Primary)
.apply(widget::container)
.padding([0, 0, 7, 0]),
);
}
}
Location::Network(uri, _display_name, _path) if uri == "network:///" => {
tab_column = tab_column.push(
widget::layer_container(widget::row::with_children([