Revision: 7264
http://skim-app.svn.sourceforge.net/skim-app/?rev=7264&view=rev
Author: hofman
Date: 2011-06-08 11:08:34 +0000 (Wed, 08 Jun 2011)
Log Message:
-----------
implement moveToTrash in download class
Modified Paths:
--------------
trunk/SKDownload.h
trunk/SKDownload.m
trunk/SKDownloadController.m
Modified: trunk/SKDownload.h
===================================================================
--- trunk/SKDownload.h 2011-06-08 10:15:41 UTC (rev 7263)
+++ trunk/SKDownload.h 2011-06-08 11:08:34 UTC (rev 7264)
@@ -90,6 +90,7 @@
- (void)cancel;
- (void)resume;
- (void)cleanup;
+- (void)moveToTrash;
- (void)removeProgressIndicatorFromSuperview;
Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m 2011-06-08 10:15:41 UTC (rev 7263)
+++ trunk/SKDownload.m 2011-06-08 11:08:34 UTC (rev 7264)
@@ -281,6 +281,16 @@
[[NSFileManager defaultManager] removeItemAtPath:[filePath
stringByDeletingLastPathComponent] error:NULL];
}
+- (void)moveToTrash {
+ if ([self canRemove] && filePath) {
+ NSString *folderPath = [filePath stringByDeletingLastPathComponent];
+ NSString *fileName = [filePath lastPathComponent];
+ NSInteger tag = 0;
+
+ [[NSWorkspace sharedWorkspace]
performFileOperation:NSWorkspaceRecycleOperation source:folderPath
destination:nil files:[NSArray arrayWithObjects:fileName, nil] tag:&tag];
+ }
+}
+
- (BOOL)canCancel {
return [self status] == SKDownloadStatusStarting || [self status] ==
SKDownloadStatusDownloading;
}
Modified: trunk/SKDownloadController.m
===================================================================
--- trunk/SKDownloadController.m 2011-06-08 10:15:41 UTC (rev 7263)
+++ trunk/SKDownloadController.m 2011-06-08 11:08:34 UTC (rev 7264)
@@ -235,14 +235,8 @@
if (row != -1)
download = [self objectInDownloadsAtIndex:row];
if ([download canRemove]) {
- if ([download status] == SKDownloadStatusFinished) {
- NSString *filePath = [download filePath];
- NSString *folderPath = [filePath
stringByDeletingLastPathComponent];
- NSString *fileName = [filePath lastPathComponent];
- NSInteger tag = 0;
-
- [[NSWorkspace sharedWorkspace]
performFileOperation:NSWorkspaceRecycleOperation source:folderPath
destination:nil files:[NSArray arrayWithObjects:fileName, nil] tag:&tag];
- }
+ if ([download status] == SKDownloadStatusFinished)
+ [download moveToTrash];
[[self mutableArrayValueForKey:DOWNLOADS_KEY] removeObject:download];
} else {
NSBeep();
@@ -280,14 +274,8 @@
NSInteger row = [tableView clickedRow];
if (row != -1) {
download = [self objectInDownloadsAtIndex:row];
- if ([NSEvent standardModifierFlags] & NSAlternateKeyMask) {
- NSString *filePath = [download filePath];
- NSString *folderPath = [filePath
stringByDeletingLastPathComponent];
- NSString *fileName = [filePath lastPathComponent];
- NSInteger tag = 0;
-
- [[NSWorkspace sharedWorkspace]
performFileOperation:NSWorkspaceRecycleOperation source:folderPath
destination:nil files:[NSArray arrayWithObjects:fileName, nil] tag:&tag];
- }
+ if ([NSEvent standardModifierFlags] & NSAlternateKeyMask)
+ [download moveToTrash];
}
}
@@ -321,16 +309,10 @@
- (void)trashDownloadedFile:(id)sender {
SKDownload *download = [sender representedObject];
- if (download && [download status] != SKDownloadStatusFinished) {
+ if (download && [download status] != SKDownloadStatusFinished)
NSBeep();
- } else {
- NSString *filePath = [download filePath];
- NSString *folderPath = [filePath stringByDeletingLastPathComponent];
- NSString *fileName = [filePath lastPathComponent];
- NSInteger tag = 0;
-
- [[NSWorkspace sharedWorkspace]
performFileOperation:NSWorkspaceRecycleOperation source:folderPath
destination:nil files:[NSArray arrayWithObjects:fileName, nil] tag:&tag];
- }
+ else
+ [download moveToTrash];
}
#pragma mark Menu validation
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit