From 34c5cb8c83b6ad9111c2d7649dc040a96aac2f44 Mon Sep 17 00:00:00 2001 From: stippi Date: Tue, 23 Mar 2010 15:37:01 +0000 Subject: [PATCH] Following another suggestion by Axel: Check if a download file is being moved into the trash. If it's still in progress, cancel it. Dim the icon in any case. Undim the icon if a download is moved back out of the trash (restarting still has to happen manually). git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@348 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/DownloadWindow.cpp | 31 ++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/apps/webpositive/DownloadWindow.cpp b/src/apps/webpositive/DownloadWindow.cpp index c22a8602cc..ad0b6d90a5 100644 --- a/src/apps/webpositive/DownloadWindow.cpp +++ b/src/apps/webpositive/DownloadWindow.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -381,12 +382,36 @@ public: || strlen(name) == 0) { break; } + // Construct the BEntry and update fPath entry_ref ref(device, directory, name); BEntry entry(&ref); - if (entry.GetPath(&fPath) == B_OK) { - fStatusBar->SetText(name); - Window()->PostMessage(SAVE_SETTINGS); + if (entry.GetPath(&fPath) != B_OK) + break; + // Find out if the directory is the Trash for this + // volume + char trashPath[B_PATH_NAME_LENGTH]; + if (find_directory(B_TRASH_DIRECTORY, device, false, + trashPath, B_PATH_NAME_LENGTH) == B_OK) { + BPath trashDirectory(trashPath); + BPath parentDirectory; + fPath.GetParent(&parentDirectory); + if (parentDirectory == trashDirectory) { + // The entry was moved into the Trash. + // If the download is still in progress, + // cancel it. + if (fDownload) + fDownload->Cancel(); + fIconView->SetIconDimmed(true); + DownloadCanceled(); + break; + } else if (fIconView->IsIconDimmed()) { + // Maybe it was moved out of the trash. + fIconView->SetIconDimmed(false); + } } + + fStatusBar->SetText(name); + Window()->PostMessage(SAVE_SETTINGS); break; } case B_ATTR_CHANGED: