Show toast on moving to trash
This commit is contained in:
parent
45711e1734
commit
5c82e72c80
4 changed files with 67 additions and 21 deletions
38
Cargo.lock
generated
38
Cargo.lock
generated
|
|
@ -1132,7 +1132,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"atomicwrites",
|
||||
"cosmic-config-derive",
|
||||
|
|
@ -1151,7 +1151,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-config-derive"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
|
|
@ -1240,7 +1240,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "cosmic-theme"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"almost",
|
||||
"cosmic-config",
|
||||
|
|
@ -2655,7 +2655,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -2674,7 +2674,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_accessibility"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"accesskit_unix",
|
||||
|
|
@ -2684,7 +2684,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_core"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"dnd",
|
||||
|
|
@ -2706,7 +2706,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_futures"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"iced_core",
|
||||
|
|
@ -2719,7 +2719,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_graphics"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"bytemuck",
|
||||
|
|
@ -2743,7 +2743,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_renderer"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"iced_graphics",
|
||||
"iced_tiny_skia",
|
||||
|
|
@ -2755,7 +2755,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_runtime"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -2769,7 +2769,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_sctk"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"enum-repr",
|
||||
"float-cmp",
|
||||
|
|
@ -2796,7 +2796,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_style"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"iced_core",
|
||||
"once_cell",
|
||||
|
|
@ -2806,7 +2806,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_tiny_skia"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"cosmic-text",
|
||||
|
|
@ -2823,7 +2823,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_wgpu"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"bytemuck",
|
||||
|
|
@ -2849,7 +2849,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_widget"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -2867,7 +2867,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "iced_winit"
|
||||
version = "0.12.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"dnd",
|
||||
"iced_accessibility",
|
||||
|
|
@ -3615,7 +3615,7 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
|||
[[package]]
|
||||
name = "libcosmic"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#c9a2265ab192af4d1270e96b0d73cb06163ece96"
|
||||
source = "git+https://github.com/pop-os/libcosmic.git#1e566c13aaa86a48695876a8badda38c8b828596"
|
||||
dependencies = [
|
||||
"apply",
|
||||
"ashpd",
|
||||
|
|
@ -4328,9 +4328,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
|||
|
||||
[[package]]
|
||||
name = "open"
|
||||
version = "5.2.0"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d2c909a3fce3bd80efef4cd1c6c056bd9376a8fe06fcfdbebaf32cb485a7e37"
|
||||
checksum = "61a877bf6abd716642a53ef1b89fb498923a4afca5c754f9050b4d081c05c4b3"
|
||||
dependencies = [
|
||||
"is-wsl",
|
||||
"libc",
|
||||
|
|
|
|||
|
|
@ -65,6 +65,12 @@ pending = Pending
|
|||
failed = Failed
|
||||
complete = Complete
|
||||
copy_noun = Copy
|
||||
moved-to-trash =
|
||||
{$items ->
|
||||
[one] 1 item has been moved to {trash}.
|
||||
*[other] {$items} items have been moved to {trash}.
|
||||
}
|
||||
undo = Undo
|
||||
|
||||
## Open with
|
||||
open-with = Open with
|
||||
|
|
|
|||
36
src/app.rs
36
src/app.rs
|
|
@ -249,7 +249,9 @@ pub enum Message {
|
|||
TabMessage(Option<Entity>, tab::Message),
|
||||
TabNew,
|
||||
TabRescan(Entity, Location, Vec<tab::Item>),
|
||||
Toast(widget::toaster::ToastMessage),
|
||||
ToggleContextPage(ContextPage),
|
||||
Undo(u64),
|
||||
WindowClose,
|
||||
WindowNew,
|
||||
DndHoverLocTimeout(Location),
|
||||
|
|
@ -262,6 +264,12 @@ pub enum Message {
|
|||
DndDropNav(Entity, Option<ClipboardPaste>, DndAction),
|
||||
}
|
||||
|
||||
impl From<widget::toaster::ToastMessage> for Message {
|
||||
fn from(toast_message: widget::toaster::ToastMessage) -> Self {
|
||||
Self::Toast(toast_message)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum ContextPage {
|
||||
About,
|
||||
|
|
@ -359,6 +367,7 @@ pub struct App {
|
|||
search_active: bool,
|
||||
search_id: widget::Id,
|
||||
search_input: String,
|
||||
toasts: widget::toaster::Toasts<Message>,
|
||||
watcher_opt: Option<(Debouncer<RecommendedWatcher, FileIdMap>, HashSet<PathBuf>)>,
|
||||
nav_dnd_hover: Option<(Location, Instant)>,
|
||||
tab_dnd_hover: Option<(Entity, Instant)>,
|
||||
|
|
@ -980,6 +989,7 @@ impl Application for App {
|
|||
search_active: false,
|
||||
search_id: widget::Id::unique(),
|
||||
search_input: String::new(),
|
||||
toasts: widget::toaster::Toasts::default(),
|
||||
watcher_opt: None,
|
||||
nav_dnd_hover: None,
|
||||
tab_dnd_hover: None,
|
||||
|
|
@ -1530,11 +1540,27 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
Message::PendingComplete(id) => {
|
||||
let mut commands = Vec::with_capacity(2);
|
||||
if let Some((op, _)) = self.pending_operations.remove(&id) {
|
||||
if let Some(description) = op.toast() {
|
||||
commands.push(
|
||||
self.toasts.push(
|
||||
widget::toaster::Toast::new(description)
|
||||
/*TODO
|
||||
.action(widget::toaster::ToastAction {
|
||||
description: fl!("undo"),
|
||||
message: Message::Undo(id),
|
||||
})
|
||||
*/
|
||||
.duration(widget::toaster::ToastDuration::Long),
|
||||
),
|
||||
);
|
||||
}
|
||||
self.complete_operations.insert(id, op);
|
||||
}
|
||||
// Manually rescan any trash tabs after any operation is completed
|
||||
return self.rescan_trash();
|
||||
commands.push(self.rescan_trash());
|
||||
return Command::batch(commands);
|
||||
}
|
||||
Message::PendingError(id, err) => {
|
||||
if let Some((op, _)) = self.pending_operations.remove(&id) {
|
||||
|
|
@ -1869,6 +1895,9 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
//TODO: TABRELOAD
|
||||
Message::Toast(toast_message) => {
|
||||
self.toasts.handle_message(&toast_message);
|
||||
}
|
||||
Message::ToggleContextPage(context_page) => {
|
||||
//TODO: ensure context menus are closed
|
||||
if self.context_page == context_page {
|
||||
|
|
@ -1879,6 +1908,9 @@ impl Application for App {
|
|||
}
|
||||
self.set_context_title(context_page.title());
|
||||
}
|
||||
Message::Undo(id) => {
|
||||
log::error!("TODO: Undo {id}");
|
||||
}
|
||||
Message::WindowClose => {
|
||||
return window::close(window::Id::MAIN);
|
||||
}
|
||||
|
|
@ -2376,7 +2408,7 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
|
||||
let content: Element<_> = tab_column.into();
|
||||
let content: Element<_> = widget::toaster::toaster(&self.toasts, tab_column).into();
|
||||
|
||||
// Uncomment to debug layout:
|
||||
//content.explain(cosmic::iced::Color::WHITE)
|
||||
|
|
|
|||
|
|
@ -198,6 +198,14 @@ fn copy_unique_path(from: &Path, to: &Path) -> PathBuf {
|
|||
}
|
||||
|
||||
impl Operation {
|
||||
pub fn toast(&self) -> Option<String> {
|
||||
match self {
|
||||
Self::Delete { paths } => Some(fl!("moved-to-trash", items = paths.len())),
|
||||
//TODO: more toasts
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Perform the operation
|
||||
pub async fn perform(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue