Revision: 2652
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2652&view=rev
Author:   hofman
Date:     2007-08-14 02:21:28 -0700 (Tue, 14 Aug 2007)

Log Message:
-----------
Add resume button to downloads window. Remove successfully finished downloads.

Modified Paths:
--------------
    trunk/Dutch.lproj/DownloadsWindow.nib/info.nib
    trunk/Dutch.lproj/DownloadsWindow.nib/keyedobjects.nib
    trunk/English.lproj/DownloadsWindow.nib/info.nib
    trunk/English.lproj/DownloadsWindow.nib/keyedobjects.nib
    trunk/French.lproj/DownloadsWindow.nib/info.nib
    trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib
    trunk/Italian.lproj/DownloadsWindow.nib/info.nib
    trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib
    trunk/SKDownload.h
    trunk/SKDownload.m
    trunk/SKDownloadController.m
    trunk/Skim.xcodeproj/project.pbxproj

Added Paths:
-----------
    trunk/Images/Resume.tiff

Modified: trunk/Dutch.lproj/DownloadsWindow.nib/info.nib
===================================================================
--- trunk/Dutch.lproj/DownloadsWindow.nib/info.nib      2007-08-14 01:12:06 UTC 
(rev 2651)
+++ trunk/Dutch.lproj/DownloadsWindow.nib/info.nib      2007-08-14 09:21:28 UTC 
(rev 2652)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>115 82 356 240 0 0 1600 1178 </string>
+       <string>100 77 356 240 0 0 1440 938 </string>
        <key>IBFramework Version</key>
        <string>446.1</string>
        <key>IBOpenObjects</key>

Modified: trunk/Dutch.lproj/DownloadsWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: trunk/English.lproj/DownloadsWindow.nib/info.nib
===================================================================
--- trunk/English.lproj/DownloadsWindow.nib/info.nib    2007-08-14 01:12:06 UTC 
(rev 2651)
+++ trunk/English.lproj/DownloadsWindow.nib/info.nib    2007-08-14 09:21:28 UTC 
(rev 2652)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>115 103 356 240 0 0 1600 1178 </string>
+       <string>100 77 356 240 0 0 1440 938 </string>
        <key>IBFramework Version</key>
        <string>446.1</string>
        <key>IBOpenObjects</key>

Modified: trunk/English.lproj/DownloadsWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: trunk/French.lproj/DownloadsWindow.nib/info.nib
===================================================================
--- trunk/French.lproj/DownloadsWindow.nib/info.nib     2007-08-14 01:12:06 UTC 
(rev 2651)
+++ trunk/French.lproj/DownloadsWindow.nib/info.nib     2007-08-14 09:21:28 UTC 
(rev 2652)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>115 103 356 240 0 0 1600 1178 </string>
+       <string>100 77 356 240 0 0 1440 938 </string>
        <key>IBFramework Version</key>
        <string>446.1</string>
        <key>IBOpenObjects</key>

Modified: trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Added: trunk/Images/Resume.tiff
===================================================================
(Binary files differ)


Property changes on: trunk/Images/Resume.tiff
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/Italian.lproj/DownloadsWindow.nib/info.nib
===================================================================
--- trunk/Italian.lproj/DownloadsWindow.nib/info.nib    2007-08-14 01:12:06 UTC 
(rev 2651)
+++ trunk/Italian.lproj/DownloadsWindow.nib/info.nib    2007-08-14 09:21:28 UTC 
(rev 2652)
@@ -3,7 +3,7 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>115 103 356 240 0 0 1600 1178 </string>
+       <string>100 77 356 240 0 0 1440 938 </string>
        <key>IBFramework Version</key>
        <string>446.1</string>
        <key>IBOpenObjects</key>

Modified: trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib
===================================================================
(Binary files differ)

Modified: trunk/SKDownload.h
===================================================================
--- trunk/SKDownload.h  2007-08-14 01:12:06 UTC (rev 2651)
+++ trunk/SKDownload.h  2007-08-14 09:21:28 UTC (rev 2652)
@@ -85,9 +85,11 @@
 
 - (void)startDownload;
 - (void)cancelDownload;
+- (void)resumeDownload;
 - (void)cleanupDownload;
 
 - (BOOL)canCancel;
+- (BOOL)canResume;
 
 @end
 

Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m  2007-08-14 01:12:06 UTC (rev 2651)
+++ trunk/SKDownload.m  2007-08-14 09:21:28 UTC (rev 2652)
@@ -63,7 +63,7 @@
 }
 
 - (void)dealloc {
-    [self cancelDownload];
+    [self cleanupDownload];
     [URL release];
     [URLDownload release];
     [filePath release];
@@ -198,10 +198,10 @@
         return;
     }
     
-    [self setStatus:SKDownloadStatusDownloading];
     [self setExpectedContentLength:-1];
     [self setReceivedContentLength:0];
     URLDownload = [[NSURLDownload alloc] initWithRequest:[NSURLRequest 
requestWithURL:URL] delegate:self];
+    [URLDownload setDeletesFileUponFailure:NO];
     [self setStatus:SKDownloadStatusStarting];
     if ([delegate respondsToSelector:@selector(downloadDidUpdate:)])
         [delegate downloadDidUpdate:self];
@@ -209,25 +209,43 @@
 
 - (void)cancelDownload {
     if ([self canCancel]) {
+        
+        [URLDownload cancel];
         [self setStatus:SKDownloadStatusCanceled];
-        [URLDownload cancel];
         if ([delegate respondsToSelector:@selector(downloadDidEnd:)])
             [delegate downloadDidEnd:self];
     }
 }
 
+- (void)resumeDownload {
+    if ([self canResume]) {
+        
+        NSData *resumeData = [[[URLDownload resumeData] retain] autorelease];
+        if (resumeData) {
+            [URLDownload release];
+            URLDownload = [[NSURLDownload alloc] initWithResumeData:resumeData 
delegate:self path:[self filePath]];
+            [URLDownload setDeletesFileUponFailure:NO];
+            [self setStatus:SKDownloadStatusDownloading];
+            if ([delegate respondsToSelector:@selector(downloadDidUpdate:)])
+                [delegate downloadDidUpdate:self];
+        }
+    }
+}
+
 - (void)cleanupDownload {
     [self cancelDownload];
     if (filePath)
         [[NSFileManager defaultManager] removeFileAtPath:[filePath 
stringByDeletingLastPathComponent] handler:nil];
-    [URLDownload release];
-    URLDownload = nil;
 }
 
 - (BOOL)canCancel {
     return [self status] == SKDownloadStatusStarting || [self status] == 
SKDownloadStatusDownloading;
 }
 
+- (BOOL)canResume {
+    return [self status] == SKDownloadStatusCanceled;
+}
+
 #pragma mark NSURLDownloadDelegate protocol
 
 - (void)downloadDidBegin:(NSURLDownload *)download{

Modified: trunk/SKDownloadController.m
===================================================================
--- trunk/SKDownloadController.m        2007-08-14 01:12:06 UTC (rev 2651)
+++ trunk/SKDownloadController.m        2007-08-14 09:21:28 UTC (rev 2652)
@@ -53,7 +53,9 @@
 
 - (id)init {
     if (self = [super init]) {
-         downloads = [[NSMutableArray alloc] init];
+        downloads = [[NSMutableArray alloc] init];
+        [[NSNotificationCenter defaultCenter] addObserver:self 
selector:@selector(handleApplicationWillTerminateNotification:) 
+                                                     
name:NSApplicationWillTerminateNotification object:NSApp];
     }
     return self;
 }
@@ -65,6 +67,10 @@
 
 - (NSString *)windowNibName { return @"DownloadsWindow"; }
 
+- (void)handleApplicationWillTerminateNotification:(NSNotification 
*)notification {
+    [downloads makeObjectsPerformSelector:@selector(cleanupDownload)];
+}
+
 - (void)reloadTableView {
     NSView *view;
     while (view = [[tableView subviews] lastObject])
@@ -127,13 +133,25 @@
     }
 }
 
+- (IBAction)resumeDownload:(id)sender {
+       int row = [tableView clickedRow];
+    
+    if (row != -1) {
+        SKDownload *download = [downloads objectAtIndex:row];
+        if ([download status] == SKDownloadStatusCanceled) {
+            [download resumeDownload];
+            [self reloadTableView];
+            [self updateButtons];
+        }
+    }
+}
+
 - (IBAction)removeDownload:(id)sender {
        int row = [tableView clickedRow];
     
     if (row != -1) {
         SKDownload *download = [downloads objectAtIndex:row];
-        if ([download status] == SKDownloadStatusDownloading)
-            [download cancelDownload];
+        [download cleanupDownload];
         [downloads removeObjectAtIndex:row];
         [self reloadTableView];
         [self updateButtons];
@@ -163,9 +181,6 @@
 }
 
 - (void)downloadDidEnd:(SKDownload *)download {
-    [self reloadTableView];
-    [self updateButtons];
-    
     if ([download status] == SKDownloadStatusFinished) {
         NSURL *URL = [NSURL fileURLWithPath:[download filePath]];
         NSError *error = nil;
@@ -174,9 +189,13 @@
             [document setFileName:[[URL path] lastPathComponent]];
         else
             [NSApp presentError:error];
+        
+        [download cleanupDownload];
+        [downloads removeObject:download];
     }
     
-    [download cleanupDownload];
+    [self reloadTableView];
+    [self updateButtons];
 }
 
 #pragma mark NSTableViewDataSource
@@ -243,6 +262,16 @@
             [cell setAction:@selector(removeDownload:)];
             [cell setTarget:self];
         }
+    } else if ([identifier isEqualToString:@"resume"]) {
+        if ([download canResume]) {
+            [cell setImage:[NSImage imageNamed:@"Resume"]];
+            [cell setAction:@selector(resumeDownload:)];
+            [cell setTarget:self];
+        } else {
+            [cell setImage:nil];
+            [cell setAction:NULL];
+            [cell setTarget:nil];
+        }
     }
 }
 
@@ -253,6 +282,9 @@
             toolTip = NSLocalizedString(@"Cancel download", @"");
         else
             toolTip = NSLocalizedString(@"Remove download", @"");
+    } else if ([[tableColumn identifier] isEqualToString:@"resume"]) {
+        if ([[downloads objectAtIndex:row] canResume])
+            toolTip = NSLocalizedString(@"Resume download", @"");
     }
     return toolTip;
 }

Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj        2007-08-14 01:12:06 UTC (rev 
2651)
+++ trunk/Skim.xcodeproj/project.pbxproj        2007-08-14 09:21:28 UTC (rev 
2652)
@@ -163,6 +163,7 @@
                CEAA56D50C6DEE83006BD633 /* Delete.tiff in Resources */ = {isa 
= PBXBuildFile; fileRef = CEAA56D30C6DEE83006BD633 /* Delete.tiff */; };
                CEAA67250C70A882006BD633 /* NSURL_SKExtensions.h in CopyFiles 
*/ = {isa = PBXBuildFile; fileRef = CEAA67230C70A882006BD633 /* 
NSURL_SKExtensions.h */; };
                CEAA67260C70A882006BD633 /* NSURL_SKExtensions.m in Sources */ 
= {isa = PBXBuildFile; fileRef = CEAA67240C70A882006BD633 /* 
NSURL_SKExtensions.m */; };
+               CEAA68EB0C71242F006BD633 /* Resume.tiff in Resources */ = {isa 
= PBXBuildFile; fileRef = CEAA68EA0C71242F006BD633 /* Resume.tiff */; };
                CEAF079D0C4139EB00C3ECBB /* SKStatusBar.m in Sources */ = {isa 
= PBXBuildFile; fileRef = CEAF079B0C4139EB00C3ECBB /* SKStatusBar.m */; };
                CEAF2E5A0C45414100C3ECBB /* SKLine.m in Sources */ = {isa = 
PBXBuildFile; fileRef = CEAF2E580C45414100C3ECBB /* SKLine.m */; };
                CEAFFD7C0C40ED5400C3ECBB /* ToolbarColors.tiff in Resources */ 
= {isa = PBXBuildFile; fileRef = CEAFFD7A0C40ED5400C3ECBB /* ToolbarColors.tiff 
*/; };
@@ -542,6 +543,7 @@
                CEAA56D30C6DEE83006BD633 /* Delete.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; name = Delete.tiff; path = 
Images/Delete.tiff; sourceTree = "<group>"; };
                CEAA67230C70A882006BD633 /* NSURL_SKExtensions.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
NSURL_SKExtensions.h; sourceTree = "<group>"; };
                CEAA67240C70A882006BD633 /* NSURL_SKExtensions.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= NSURL_SKExtensions.m; sourceTree = "<group>"; };
+               CEAA68EA0C71242F006BD633 /* Resume.tiff */ = {isa = 
PBXFileReference; lastKnownFileType = image.tiff; name = Resume.tiff; path = 
Images/Resume.tiff; sourceTree = "<group>"; };
                CEAF079A0C4139EB00C3ECBB /* SKStatusBar.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKStatusBar.h; sourceTree = "<group>"; };
                CEAF079B0C4139EB00C3ECBB /* SKStatusBar.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= SKStatusBar.m; sourceTree = "<group>"; };
                CEAF2E570C45414100C3ECBB /* SKLine.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
SKLine.h; sourceTree = "<group>"; };
@@ -1008,6 +1010,7 @@
                                CE4D88D70C3AE52F002C20CB /* DVIDocument.icns */,
                                CEAA56D20C6DEE83006BD633 /* Cancel.tiff */,
                                CEAA56D30C6DEE83006BD633 /* Delete.tiff */,
+                               CEAA68EA0C71242F006BD633 /* Resume.tiff */,
                                CE0715890B8A3D6300733CC8 /* NoteDocument.icns 
*/,
                                CE7C5D180BD8086C0011315D /* 
ToolbarLineNote.tiff */,
                                CE4190C20B94963A00ECF819 /* 
ToolbarCircleNote.tiff */,
@@ -1259,6 +1262,7 @@
                                CEAA55F10C6DE5AE006BD633 /* DownloadsWindow.nib 
in Resources */,
                                CEAA56D40C6DEE83006BD633 /* Cancel.tiff in 
Resources */,
                                CEAA56D50C6DEE83006BD633 /* Delete.tiff in 
Resources */,
+                               CEAA68EB0C71242F006BD633 /* Resume.tiff in 
Resources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to