You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(23) |
Apr
(254) |
May
(252) |
Jun
(209) |
Jul
(198) |
Aug
(192) |
Sep
(207) |
Oct
(120) |
Nov
(179) |
Dec
(52) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(48) |
Feb
(69) |
Mar
(129) |
Apr
(250) |
May
(113) |
Jun
(177) |
Jul
(228) |
Aug
(155) |
Sep
(218) |
Oct
(185) |
Nov
(109) |
Dec
(88) |
2009 |
Jan
(83) |
Feb
(39) |
Mar
(70) |
Apr
(47) |
May
(48) |
Jun
(67) |
Jul
(61) |
Aug
(97) |
Sep
(221) |
Oct
(141) |
Nov
(70) |
Dec
(61) |
2010 |
Jan
(45) |
Feb
(76) |
Mar
(178) |
Apr
(106) |
May
(57) |
Jun
(32) |
Jul
(64) |
Aug
(98) |
Sep
(96) |
Oct
(19) |
Nov
(34) |
Dec
(117) |
2011 |
Jan
(55) |
Feb
(48) |
Mar
(64) |
Apr
(21) |
May
(39) |
Jun
(53) |
Jul
(99) |
Aug
(56) |
Sep
(39) |
Oct
(26) |
Nov
(19) |
Dec
(69) |
2012 |
Jan
(17) |
Feb
(40) |
Mar
(17) |
Apr
|
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
(10) |
Sep
(10) |
Oct
(38) |
Nov
(48) |
Dec
(70) |
2013 |
Jan
(43) |
Feb
(47) |
Mar
(39) |
Apr
(37) |
May
(25) |
Jun
(6) |
Jul
(20) |
Aug
(49) |
Sep
(33) |
Oct
(34) |
Nov
(75) |
Dec
(6) |
2014 |
Jan
(32) |
Feb
(10) |
Mar
(17) |
Apr
|
May
|
Jun
(26) |
Jul
(5) |
Aug
|
Sep
(4) |
Oct
(23) |
Nov
(80) |
Dec
(48) |
2015 |
Jan
(80) |
Feb
(50) |
Mar
(58) |
Apr
(20) |
May
(11) |
Jun
(16) |
Jul
(24) |
Aug
(27) |
Sep
(56) |
Oct
(30) |
Nov
(16) |
Dec
(6) |
2016 |
Jan
(31) |
Feb
(14) |
Mar
(23) |
Apr
(17) |
May
(40) |
Jun
(12) |
Jul
(17) |
Aug
(9) |
Sep
(32) |
Oct
(36) |
Nov
(23) |
Dec
(9) |
2017 |
Jan
(37) |
Feb
(23) |
Mar
(65) |
Apr
(22) |
May
(6) |
Jun
(3) |
Jul
|
Aug
|
Sep
(3) |
Oct
(22) |
Nov
(63) |
Dec
(71) |
2018 |
Jan
(83) |
Feb
(21) |
Mar
(35) |
Apr
(44) |
May
(14) |
Jun
(12) |
Jul
(8) |
Aug
(18) |
Sep
(10) |
Oct
(145) |
Nov
(144) |
Dec
(76) |
2019 |
Jan
(18) |
Feb
(28) |
Mar
(5) |
Apr
(208) |
May
(291) |
Jun
(158) |
Jul
(27) |
Aug
(8) |
Sep
(10) |
Oct
(83) |
Nov
(41) |
Dec
(31) |
2020 |
Jan
(16) |
Feb
(46) |
Mar
(100) |
Apr
(78) |
May
(69) |
Jun
(71) |
Jul
(28) |
Aug
(131) |
Sep
(176) |
Oct
(89) |
Nov
(147) |
Dec
(19) |
2021 |
Jan
(19) |
Feb
(25) |
Mar
(91) |
Apr
(98) |
May
(14) |
Jun
(44) |
Jul
(8) |
Aug
(3) |
Sep
(38) |
Oct
(57) |
Nov
(97) |
Dec
(74) |
2022 |
Jan
(89) |
Feb
(47) |
Mar
(15) |
Apr
(50) |
May
(54) |
Jun
(56) |
Jul
(80) |
Aug
(12) |
Sep
(11) |
Oct
(60) |
Nov
(48) |
Dec
(4) |
2023 |
Jan
(75) |
Feb
(49) |
Mar
(84) |
Apr
(24) |
May
(13) |
Jun
(74) |
Jul
(32) |
Aug
(66) |
Sep
(50) |
Oct
(38) |
Nov
(105) |
Dec
(181) |
2024 |
Jan
(21) |
Feb
(49) |
Mar
(77) |
Apr
(84) |
May
(20) |
Jun
(71) |
Jul
(53) |
Aug
(33) |
Sep
(54) |
Oct
(124) |
Nov
(151) |
Dec
(73) |
2025 |
Jan
(61) |
Feb
(17) |
Mar
(136) |
Apr
(72) |
May
(200) |
Jun
(238) |
Jul
(91) |
Aug
(8) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ho...@us...> - 2007-08-14 11:09:22
|
Revision: 2656 http://skim-app.svn.sourceforge.net/skim-app/?rev=2656&view=rev Author: hofman Date: 2007-08-14 04:09:16 -0700 (Tue, 14 Aug 2007) Log Message: ----------- Add hidden default to automatically open the downloads window. Modified Paths: -------------- trunk/InitialUserDefaults.plist trunk/SKDocumentController.m trunk/SKStringConstants.h trunk/SKStringConstants.m Modified: trunk/InitialUserDefaults.plist =================================================================== --- trunk/InitialUserDefaults.plist 2007-08-14 10:26:52 UTC (rev 2655) +++ trunk/InitialUserDefaults.plist 2007-08-14 11:09:16 UTC (rev 2656) @@ -224,6 +224,8 @@ <real>400.0</real> <key>SKLargeMagnificationWidth</key> <real>600.0</real> + <key>SKAutoOpenDownloadsWindow</key> + <true/> <key>SUScheduledCheckInterval</key> <integer>86400</integer> </dict> Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-14 10:26:52 UTC (rev 2655) +++ trunk/SKDocumentController.m 2007-08-14 11:09:16 UTC (rev 2656) @@ -41,6 +41,7 @@ #import "SKDownloadController.h" #import "NSString_SKExtensions.h" #import "NSURL_SKExtensions.h" +#import "SKStringConstants.h" // See CFBundleTypeName in Info.plist NSString *SKPDFDocumentType = nil; /* set to NSPDFPboardType, not @"NSPDFPboardType" */ @@ -174,7 +175,8 @@ document = [self openDocumentWithContentsOfURL:theURL display:YES error:outError]; } else if (theURL) { [[SKDownloadController sharedDownloadController] addDownloadForURL:theURL]; - [[SKDownloadController sharedDownloadController] showWindow:self]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:SKAutoOpenDownloadsWindowKey]) + [[SKDownloadController sharedDownloadController] showWindow:self]; if (outError) *outError = nil; } else if (outError) { Modified: trunk/SKStringConstants.h =================================================================== --- trunk/SKStringConstants.h 2007-08-14 10:26:52 UTC (rev 2655) +++ trunk/SKStringConstants.h 2007-08-14 11:09:16 UTC (rev 2656) @@ -100,3 +100,4 @@ extern NSString *SKActivateFullScreenNavigationAtBottomKey; extern NSString *SKActivatePresentationNavigationAtBottomKey; extern NSString *SKAutoHidePresentationContentsKey; +extern NSString *SKAutoOpenDownloadsWindowKey; Modified: trunk/SKStringConstants.m =================================================================== --- trunk/SKStringConstants.m 2007-08-14 10:26:52 UTC (rev 2655) +++ trunk/SKStringConstants.m 2007-08-14 11:09:16 UTC (rev 2656) @@ -101,3 +101,4 @@ NSString *SKActivateFullScreenNavigationAtBottomKey = @"SKActivateFullScreenNavigationAtBottom"; NSString *SKActivatePresentationNavigationAtBottomKey = @"SKActivatePresentationNavigationAtBottom"; NSString *SKAutoHidePresentationContentsKey = @"SKAutoHidePresentationContents"; +NSString *SKAutoOpenDownloadsWindowKey = @"SKAutoOpenDownloadsWindow"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-14 10:26:53
|
Revision: 2655 http://skim-app.svn.sourceforge.net/skim-app/?rev=2655&view=rev Author: hofman Date: 2007-08-14 03:26:52 -0700 (Tue, 14 Aug 2007) Log Message: ----------- Add services in Skim submenu. Modified Paths: -------------- trunk/Info.plist Modified: trunk/Info.plist =================================================================== --- trunk/Info.plist 2007-08-14 10:09:59 UTC (rev 2654) +++ trunk/Info.plist 2007-08-14 10:26:52 UTC (rev 2655) @@ -357,7 +357,7 @@ <key>NSMenuItem</key> <dict> <key>default</key> - <string>Open PDF at URL</string> + <string>Skim/Open PDF at URL</string> </dict> <key>NSMessage</key> <string>openDocumentFromURLOnPboard</string> @@ -374,7 +374,7 @@ <key>NSMenuItem</key> <dict> <key>default</key> - <string>Open Selected PDF</string> + <string>Skim/Open Selected PDF</string> </dict> <key>NSMessage</key> <string>openDocumentFromDataOnPboard</string> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-14 10:10:01
|
Revision: 2654 http://skim-app.svn.sourceforge.net/skim-app/?rev=2654&view=rev Author: hofman Date: 2007-08-14 03:09:59 -0700 (Tue, 14 Aug 2007) Log Message: ----------- Automatically hide scrollers in download table Modified Paths: -------------- trunk/Dutch.lproj/DownloadsWindow.nib/keyedobjects.nib trunk/English.lproj/DownloadsWindow.nib/keyedobjects.nib trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib Modified: trunk/Dutch.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/English.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-14 09:56:14
|
Revision: 2653 http://skim-app.svn.sourceforge.net/skim-app/?rev=2653&view=rev Author: hofman Date: 2007-08-14 02:56:09 -0700 (Tue, 14 Aug 2007) Log Message: ----------- Use documentcontroller method for URL service. Add a service to open selected PDF. Modified Paths: -------------- trunk/Info.plist trunk/SKApplicationController.m trunk/SKDocumentController.h trunk/SKDocumentController.m Modified: trunk/Info.plist =================================================================== --- trunk/Info.plist 2007-08-14 09:21:28 UTC (rev 2652) +++ trunk/Info.plist 2007-08-14 09:56:09 UTC (rev 2653) @@ -365,10 +365,28 @@ <string>Skim</string> <key>NSSendTypes</key> <array> + <string>NSURLPboardType</string> <string>NSStringPboardType</string> - <string>NSURLPboardType</string> + <string>CorePasteboardFlavorType 0x75726C20</string> </array> </dict> + <dict> + <key>NSMenuItem</key> + <dict> + <key>default</key> + <string>Open Selected PDF</string> + </dict> + <key>NSMessage</key> + <string>openDocumentFromDataOnPboard</string> + <key>NSPortName</key> + <string>Skim</string> + <key>NSSendTypes</key> + <array> + <string>NSPDFPboardType</string> + <string>NSPostScriptPboardType</string> + <string>NSTIFFPboardType</string> + </array> + </dict> </array> </dict> Modified: trunk/SKApplicationController.m =================================================================== --- trunk/SKApplicationController.m 2007-08-14 09:21:28 UTC (rev 2652) +++ trunk/SKApplicationController.m 2007-08-14 09:56:09 UTC (rev 2653) @@ -53,6 +53,8 @@ #import "SKLine.h" #import "NSImage_SKExtensions.h" #import "SKDownloadController.h" +#import "NSURL_SKExtensions.h" +#import "SKDocumentController.h" @implementation SKApplicationController @@ -189,54 +191,20 @@ #pragma mark Services Support -- (void)openDocumentFromURLOnPboard:(NSPasteboard *)pboard - userData:(NSString *)userData - error:(NSString **)error{ - - NSArray *types = [pboard types]; +- (void)openDocumentFromURLOnPboard:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { + NSError *outError; + id document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfPasteboard:pboard typesMask:SKURLPboardTypesMask error:&outError]; - bool pbHasStringType = [types containsObject:NSStringPboardType]; - bool pbHasURLType = [types containsObject:NSURLPboardType]; - - if (!pbHasStringType && !pbHasURLType) { - *error = NSLocalizedString(@"Error: couldn't get a URL.", - @"pboard couldn't give string or URL."); - return; - } - - NSURL *pdfURL = nil; - - if (pbHasURLType){ - pdfURL = [NSURL URLFromPasteboard:pboard]; - } - - if (pdfURL == nil && pbHasStringType){ - NSString *pboardString = [pboard stringForType:NSStringPboardType]; - - if (!pboardString) { - *error = NSLocalizedString(@"Error: couldn't get a URL.", - @"pboard couldn't give string."); - return; - } - pdfURL = [NSURL URLWithString:pboardString]; - } - - if (!pdfURL){ - *error = NSLocalizedString(@"Error: couldn't get a URL", - @"nothing worked."); - return; - } + if (document == nil && outError && error) + *error = [outError localizedDescription]; +} - if([pdfURL isFileURL]){ - NSError *newError; - [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:pdfURL - display:YES - error:&newError]; - }else{ - [[SKDownloadController sharedDownloadController] addDownloadForURL:pdfURL]; - } +- (void)openDocumentFromDataOnPboard:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { + NSError *outError; + id document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfPasteboard:pboard typesMask:SKImagePboardTypesMask error:&outError]; - return; + if (document == nil && outError && error) + *error = [outError localizedDescription]; } #pragma mark Actions Modified: trunk/SKDocumentController.h =================================================================== --- trunk/SKDocumentController.h 2007-08-14 09:21:28 UTC (rev 2652) +++ trunk/SKDocumentController.h 2007-08-14 09:56:09 UTC (rev 2653) @@ -47,8 +47,12 @@ extern NSString *SKPostScriptDocumentType; extern NSString *SKDVIDocumentType; +enum { + SKImagePboardTypesMask = 1, + SKURLPboardTypesMask = 2 +}; @interface SKDocumentController : NSDocumentController - (void)newDocumentFromClipboard:(id)sender; -- (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard error:(NSError **)outError; +- (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard typesMask:(int)mask error:(NSError **)outError; @end Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-14 09:21:28 UTC (rev 2652) +++ trunk/SKDocumentController.m 2007-08-14 09:56:09 UTC (rev 2653) @@ -136,13 +136,13 @@ return pdfData; } -- (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard error:(NSError **)outError { +- (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard typesMask:(int)mask error:(NSError **)outError { // allow any filter services to convert to TIFF data if we can't get PDF or PS directly pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:pboard]; NSString *pboardType; id document = nil; - if (pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]]) { + if ((mask & SKImagePboardTypesMask) && (pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]])) { NSData *data = [pboard dataForType:pboardType]; @@ -167,7 +167,7 @@ *outError = error; } - } else if (pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]) { + } else if ((mask & SKURLPboardTypesMask) && (pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]])) { NSURL *theURL = [NSURL URLFromPasteboardAnyType:pboard]; if ([theURL isFileURL]) { @@ -190,7 +190,7 @@ - (void)newDocumentFromClipboard:(id)sender { NSError *error = nil; - id document = [self openDocumentWithContentsOfPasteboard:[NSPasteboard generalPasteboard] error:&error]; + id document = [self openDocumentWithContentsOfPasteboard:[NSPasteboard generalPasteboard] typesMask:SKImagePboardTypesMask | SKURLPboardTypesMask error:&error]; if (document == nil && error) [NSApp presentError:error]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-14 09:21:45
|
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. |
From: <mm...@us...> - 2007-08-14 01:12:12
|
Revision: 2651 http://skim-app.svn.sourceforge.net/skim-app/?rev=2651&view=rev Author: mmcc Date: 2007-08-13 18:12:06 -0700 (Mon, 13 Aug 2007) Log Message: ----------- add service to download from URL Modified Paths: -------------- trunk/Info.plist trunk/SKApplicationController.h trunk/SKApplicationController.m Modified: trunk/Info.plist =================================================================== --- trunk/Info.plist 2007-08-13 23:15:15 UTC (rev 2650) +++ trunk/Info.plist 2007-08-14 01:12:06 UTC (rev 2651) @@ -351,5 +351,25 @@ </dict> </dict> </array> + <key>NSServices</key> + <array> + <dict> + <key>NSMenuItem</key> + <dict> + <key>default</key> + <string>Open PDF at URL</string> + </dict> + <key>NSMessage</key> + <string>openDocumentFromURLOnPboard</string> + <key>NSPortName</key> + <string>Skim</string> + <key>NSSendTypes</key> + <array> + <string>NSStringPboardType</string> + <string>NSURLPboardType</string> + </array> + </dict> + </array> + </dict> </plist> Modified: trunk/SKApplicationController.h =================================================================== --- trunk/SKApplicationController.h 2007-08-13 23:15:15 UTC (rev 2650) +++ trunk/SKApplicationController.h 2007-08-14 01:12:06 UTC (rev 2651) @@ -38,10 +38,11 @@ #import <Cocoa/Cocoa.h> -@class SUUpdater, SKLine; +@class SUUpdater, SKLine, SKDownloadController; @interface SKApplicationController : NSObject { BOOL remoteScrolling; + } + (void)setupDefaults; Modified: trunk/SKApplicationController.m =================================================================== --- trunk/SKApplicationController.m 2007-08-13 23:15:15 UTC (rev 2650) +++ trunk/SKApplicationController.m 2007-08-14 01:12:06 UTC (rev 2651) @@ -156,6 +156,7 @@ } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification{ + [NSApp setServicesProvider:self]; NSString *versionString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; SKVersionNumber *versionNumber = versionString ? [[[SKVersionNumber alloc] initWithVersionString:versionString] autorelease] : nil; NSString *lastVersionString = [[NSUserDefaults standardUserDefaults] stringForKey:SKLastVersionLaunchedKey]; @@ -186,6 +187,58 @@ } } +#pragma mark Services Support + +- (void)openDocumentFromURLOnPboard:(NSPasteboard *)pboard + userData:(NSString *)userData + error:(NSString **)error{ + + NSArray *types = [pboard types]; + + bool pbHasStringType = [types containsObject:NSStringPboardType]; + bool pbHasURLType = [types containsObject:NSURLPboardType]; + + if (!pbHasStringType && !pbHasURLType) { + *error = NSLocalizedString(@"Error: couldn't get a URL.", + @"pboard couldn't give string or URL."); + return; + } + + NSURL *pdfURL = nil; + + if (pbHasURLType){ + pdfURL = [NSURL URLFromPasteboard:pboard]; + } + + if (pdfURL == nil && pbHasStringType){ + NSString *pboardString = [pboard stringForType:NSStringPboardType]; + + if (!pboardString) { + *error = NSLocalizedString(@"Error: couldn't get a URL.", + @"pboard couldn't give string."); + return; + } + pdfURL = [NSURL URLWithString:pboardString]; + } + + if (!pdfURL){ + *error = NSLocalizedString(@"Error: couldn't get a URL", + @"nothing worked."); + return; + } + + if([pdfURL isFileURL]){ + NSError *newError; + [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:pdfURL + display:YES + error:&newError]; + }else{ + [[SKDownloadController sharedDownloadController] addDownloadForURL:pdfURL]; + } + + return; +} + #pragma mark Actions - (IBAction)visitWebSite:(id)sender{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 23:15:16
|
Revision: 2650 http://skim-app.svn.sourceforge.net/skim-app/?rev=2650&view=rev Author: hofman Date: 2007-08-13 16:15:15 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Decease size of images. Modified Paths: -------------- trunk/Images/Cancel.tiff trunk/Images/Delete.tiff Modified: trunk/Images/Cancel.tiff =================================================================== (Binary files differ) Modified: trunk/Images/Delete.tiff =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 21:15:31
|
Revision: 2649 http://skim-app.svn.sourceforge.net/skim-app/?rev=2649&view=rev Author: hofman Date: 2007-08-13 14:15:25 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Implement paste for download window Modified Paths: -------------- trunk/SKDownloadController.m Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-13 21:11:36 UTC (rev 2648) +++ trunk/SKDownloadController.m 2007-08-13 21:15:25 UTC (rev 2649) @@ -140,6 +140,16 @@ } } +- (IBAction)paste:(id)sender { + NSPasteboard *pboard = [NSPasteboard generalPasteboard]; + NSURL *theURL = [NSURL URLFromPasteboardAnyType:pboard]; + + if ([theURL isFileURL]) + [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:theURL display:YES error:NULL]; + else if (theURL) + [self addDownloadForURL:theURL]; +} + #pragma mark SKDownloadDelegate - (void)downloadDidStart:(SKDownload *)download { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 21:11:42
|
Revision: 2648 http://skim-app.svn.sourceforge.net/skim-app/?rev=2648&view=rev Author: hofman Date: 2007-08-13 14:11:36 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Register string drop type for download table Modified Paths: -------------- trunk/SKDownloadController.m Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-13 18:17:20 UTC (rev 2647) +++ trunk/SKDownloadController.m 2007-08-13 21:11:36 UTC (rev 2648) @@ -88,7 +88,7 @@ - (void)windowDidLoad { [self setWindowFrameAutosaveName:@"SKDownloadsWindow"]; [self updateButtons]; - [tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, nil]]; + [tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]; } - (void)addDownloadForURL:(NSURL *)aURL { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 18:17:21
|
Revision: 2647 http://skim-app.svn.sourceforge.net/skim-app/?rev=2647&view=rev Author: hofman Date: 2007-08-13 11:17:20 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Set filename of downloaded files to just the file name, as the temporary file is deleted. Modified Paths: -------------- trunk/SKDownloadController.m Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-13 18:16:35 UTC (rev 2646) +++ trunk/SKDownloadController.m 2007-08-13 18:17:20 UTC (rev 2647) @@ -159,7 +159,10 @@ if ([download status] == SKDownloadStatusFinished) { NSURL *URL = [NSURL fileURLWithPath:[download filePath]]; NSError *error = nil; - if (NO == [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:URL display:YES error:&error]) + id document = [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:URL display:YES error:&error]; + if (document) + [document setFileName:[[URL path] lastPathComponent]]; + else [NSApp presentError:error]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 18:16:36
|
Revision: 2646 http://skim-app.svn.sourceforge.net/skim-app/?rev=2646&view=rev Author: hofman Date: 2007-08-13 11:16:35 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Check image and URL pboard types separately. Modified Paths: -------------- trunk/SKDocumentController.m Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-13 17:00:14 UTC (rev 2645) +++ trunk/SKDocumentController.m 2007-08-13 18:16:35 UTC (rev 2646) @@ -139,10 +139,10 @@ - (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard error:(NSError **)outError { // allow any filter services to convert to TIFF data if we can't get PDF or PS directly pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:pboard]; - NSString *pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]; + NSString *pboardType; id document = nil; - if ([pboardType isEqualToString:NSPDFPboardType] || [pboardType isEqualToString:NSPostScriptPboardType] || [pboardType isEqualToString:NSTIFFPboardType]) { + if (pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]]) { NSData *data = [pboard dataForType:pboardType]; @@ -167,7 +167,7 @@ *outError = error; } - } else if ([pboardType isEqualToString:NSURLPboardType] || [pboardType isEqualToString:SKWeblocFilePboardType] || [pboardType isEqualToString:NSStringPboardType]) { + } else if (pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]) { NSURL *theURL = [NSURL URLFromPasteboardAnyType:pboard]; if ([theURL isFileURL]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 17:00:15
|
Revision: 2645 http://skim-app.svn.sourceforge.net/skim-app/?rev=2645&view=rev Author: hofman Date: 2007-08-13 10:00:14 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Draw status of progress cell in location of progress bar when it is not downloading. Modified Paths: -------------- trunk/SKProgressCell.m Modified: trunk/SKProgressCell.m =================================================================== --- trunk/SKProgressCell.m 2007-08-13 16:16:49 UTC (rev 2644) +++ trunk/SKProgressCell.m 2007-08-13 17:00:14 UTC (rev 2645) @@ -91,10 +91,11 @@ if ([progressIndicator isDescendantOf:controlView] == NO) [controlView addSubview:progressIndicator]; } else { - if ([controlView isFlipped] == NO) + if ([controlView isFlipped]) + textRect.origin.y = NSMinY(cellFrame); + else textRect.origin.y = NSMaxY(cellFrame) - NSHeight(textRect); id value = [[[self objectValue] retain] autorelease]; - textRect.origin.x += ([[self attributedStringValue] size].width + MARGIN_X); NSString *string = nil; switch (status) { case SKDownloadStatusStarting: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-08-13 16:20:16
|
Revision: 2644 http://skim-app.svn.sourceforge.net/skim-app/?rev=2644&view=rev Author: amaxwell Date: 2007-08-13 09:16:49 -0700 (Mon, 13 Aug 2007) Log Message: ----------- When the cell was deselected after a download finished, the file name and status were drawn superimposed. This fixes that issue, but I'm not sure what the original intent was. Modified Paths: -------------- trunk/SKProgressCell.m Modified: trunk/SKProgressCell.m =================================================================== --- trunk/SKProgressCell.m 2007-08-13 16:14:37 UTC (rev 2643) +++ trunk/SKProgressCell.m 2007-08-13 16:16:49 UTC (rev 2644) @@ -94,6 +94,7 @@ if ([controlView isFlipped] == NO) textRect.origin.y = NSMaxY(cellFrame) - NSHeight(textRect); id value = [[[self objectValue] retain] autorelease]; + textRect.origin.x += ([[self attributedStringValue] size].width + MARGIN_X); NSString *string = nil; switch (status) { case SKDownloadStatusStarting: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-08-13 16:14:38
|
Revision: 2643 http://skim-app.svn.sourceforge.net/skim-app/?rev=2643&view=rev Author: amaxwell Date: 2007-08-13 09:14:37 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Fix resizing struts for cancel button. Set last table column to be non-resizable, and have a fixed width of the same size as the icons to keep it from shrinking the icon out of sight. 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 Modified: trunk/Dutch.lproj/DownloadsWindow.nib/info.nib =================================================================== --- trunk/Dutch.lproj/DownloadsWindow.nib/info.nib 2007-08-13 15:05:28 UTC (rev 2642) +++ trunk/Dutch.lproj/DownloadsWindow.nib/info.nib 2007-08-13 16:14:37 UTC (rev 2643) @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>100 77 356 240 0 0 1440 938 </string> + <string>115 82 356 240 0 0 1600 1178 </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-13 15:05:28 UTC (rev 2642) +++ trunk/English.lproj/DownloadsWindow.nib/info.nib 2007-08-13 16:14:37 UTC (rev 2643) @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>100 77 356 240 0 0 1440 938 </string> + <string>115 103 356 240 0 0 1600 1178 </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-13 15:05:28 UTC (rev 2642) +++ trunk/French.lproj/DownloadsWindow.nib/info.nib 2007-08-13 16:14:37 UTC (rev 2643) @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>100 77 356 240 0 0 1440 938 </string> + <string>115 103 356 240 0 0 1600 1178 </string> <key>IBFramework Version</key> <string>446.1</string> <key>IBOpenObjects</key> Modified: trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/Italian.lproj/DownloadsWindow.nib/info.nib =================================================================== --- trunk/Italian.lproj/DownloadsWindow.nib/info.nib 2007-08-13 15:05:28 UTC (rev 2642) +++ trunk/Italian.lproj/DownloadsWindow.nib/info.nib 2007-08-13 16:14:37 UTC (rev 2643) @@ -3,7 +3,7 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>100 77 356 240 0 0 1440 938 </string> + <string>115 103 356 240 0 0 1600 1178 </string> <key>IBFramework Version</key> <string>446.1</string> <key>IBOpenObjects</key> Modified: trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 15:35:26
|
Revision: 2642 http://skim-app.svn.sourceforge.net/skim-app/?rev=2642&view=rev Author: hofman Date: 2007-08-13 08:05:28 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Move code to get a URL from a pasteboard to a separate NSURL category. Modified Paths: -------------- trunk/SKDocumentController.m trunk/SKDownloadController.h trunk/SKDownloadController.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/NSURL_SKExtensions.h trunk/NSURL_SKExtensions.m Added: trunk/NSURL_SKExtensions.h =================================================================== --- trunk/NSURL_SKExtensions.h (rev 0) +++ trunk/NSURL_SKExtensions.h 2007-08-13 15:05:28 UTC (rev 2642) @@ -0,0 +1,45 @@ +// +// NSURL_SKExtensions.h +// Skim +// +// Created by Christiaan Hofman on 8/13/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +extern NSString *SKWeblocFilePboardType; + +@interface NSURL (SKExtensions) ++ (NSURL *)URLFromPasteboardAnyType:(NSPasteboard *)pasteboard; +@end Added: trunk/NSURL_SKExtensions.m =================================================================== --- trunk/NSURL_SKExtensions.m (rev 0) +++ trunk/NSURL_SKExtensions.m 2007-08-13 15:05:28 UTC (rev 2642) @@ -0,0 +1,67 @@ +// +// NSURL_SKExtensions.m +// Skim +// +// Created by Christiaan Hofman on 8/13/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "NSURL_SKExtensions.h" + +NSString *SKWeblocFilePboardType = @"CorePasteboardFlavorType 0x75726C20"; + +@implementation NSURL (SKExtensions) + ++ (NSURL *)URLFromPasteboardAnyType:(NSPasteboard *)pasteboard { + NSString *pboardType = [pasteboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]; + NSURL *theURL = nil; + if ([pboardType isEqualToString:NSURLPboardType]) { + theURL = [NSURL URLFromPasteboard:pasteboard]; + } else if ([pboardType isEqualToString:SKWeblocFilePboardType]) { + theURL = [NSURL URLWithString:[pasteboard stringForType:SKWeblocFilePboardType]]; + } else if ([pboardType isEqualToString:NSStringPboardType]) { + NSString *string = [[pasteboard stringForType:NSStringPboardType] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if ([string hasPrefix:@"<"] && [string hasSuffix:@">"]) + string = [string substringWithRange:NSMakeRange(1, [string length] - 2)]; + theURL = [NSURL URLWithString:string]; + if (theURL == nil) { + if ([string hasPrefix:@"~"]) + string = [string stringByExpandingTildeInPath]; + if ([[NSFileManager defaultManager] fileExistsAtPath:string]) + theURL = [NSURL fileURLWithPath:string]; + } + } + return theURL; +} + +@end Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-13 14:48:43 UTC (rev 2641) +++ trunk/SKDocumentController.m 2007-08-13 15:05:28 UTC (rev 2642) @@ -40,6 +40,7 @@ #import "SKDocument.h" #import "SKDownloadController.h" #import "NSString_SKExtensions.h" +#import "NSURL_SKExtensions.h" // See CFBundleTypeName in Info.plist NSString *SKPDFDocumentType = nil; /* set to NSPDFPboardType, not @"NSPDFPboardType" */ @@ -168,23 +169,7 @@ } else if ([pboardType isEqualToString:NSURLPboardType] || [pboardType isEqualToString:SKWeblocFilePboardType] || [pboardType isEqualToString:NSStringPboardType]) { - NSURL *theURL = nil; - if ([pboardType isEqualToString:NSURLPboardType]) { - theURL = [NSURL URLFromPasteboard:pboard]; - } else if ([pboardType isEqualToString:SKWeblocFilePboardType]) { - theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; - } else if ([pboardType isEqualToString:NSStringPboardType]) { - NSString *string = [[pboard stringForType:NSStringPboardType] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - if ([string hasPrefix:@"<"] && [string hasSuffix:@">"]) - string = [string substringWithRange:NSMakeRange(1, [string length] - 2)]; - theURL = [NSURL URLWithString:string]; - if (theURL == nil) { - if ([string hasPrefix:@"~"]) - string = [string stringByExpandingTildeInPath]; - if ([[NSFileManager defaultManager] fileExistsAtPath:string]) - theURL = [NSURL fileURLWithPath:string]; - } - } + NSURL *theURL = [NSURL URLFromPasteboardAnyType:pboard]; if ([theURL isFileURL]) { document = [self openDocumentWithContentsOfURL:theURL display:YES error:outError]; } else if (theURL) { Modified: trunk/SKDownloadController.h =================================================================== --- trunk/SKDownloadController.h 2007-08-13 14:48:43 UTC (rev 2641) +++ trunk/SKDownloadController.h 2007-08-13 15:05:28 UTC (rev 2642) @@ -38,7 +38,6 @@ #import <Cocoa/Cocoa.h> -extern NSString *SKWeblocFilePboardType; @interface SKDownloadController : NSWindowController { IBOutlet NSTableView *tableView; Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-13 14:48:43 UTC (rev 2641) +++ trunk/SKDownloadController.m 2007-08-13 15:05:28 UTC (rev 2642) @@ -39,8 +39,8 @@ #import "SKDownloadController.h" #import "SKDownload.h" #import "SKProgressCell.h" +#import "NSURL_SKExtensions.h" -NSString *SKWeblocFilePboardType = @"CorePasteboardFlavorType 0x75726C20"; @implementation SKDownloadController @@ -197,25 +197,8 @@ - (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op { NSPasteboard *pboard = [info draggingPasteboard]; - NSString *type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]; - NSURL *theURL; + NSURL *theURL = [NSURL URLFromPasteboardAnyType:pboard]; - if ([type isEqualToString:NSURLPboardType]) { - theURL = [NSURL URLFromPasteboard:pboard]; - } else if ([type isEqualToString:SKWeblocFilePboardType]) { - theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; - } else if ([type isEqualToString:NSStringPboardType]) { - NSString *string = [[pboard stringForType:NSStringPboardType] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - if ([string hasPrefix:@"<"] && [string hasSuffix:@">"]) - string = [string substringWithRange:NSMakeRange(1, [string length] - 2)]; - theURL = [NSURL URLWithString:string]; - if (theURL == nil) { - if ([string hasPrefix:@"~"]) - string = [string stringByExpandingTildeInPath]; - if ([[NSFileManager defaultManager] fileExistsAtPath:string]) - theURL = [NSURL fileURLWithPath:string]; - } - } if ([theURL isFileURL]) { if ([[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:theURL display:YES error:NULL]) return YES; Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-08-13 14:48:43 UTC (rev 2641) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-08-13 15:05:28 UTC (rev 2642) @@ -161,6 +161,8 @@ CEAA55F10C6DE5AE006BD633 /* DownloadsWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = CEAA55EF0C6DE5AE006BD633 /* DownloadsWindow.nib */; }; CEAA56D40C6DEE83006BD633 /* Cancel.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CEAA56D20C6DEE83006BD633 /* Cancel.tiff */; }; 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 */; }; 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 */; }; @@ -269,6 +271,7 @@ dstSubfolderSpec = 10; files = ( CE2BD8450BD4135600A5F4DB /* Sparkle.framework in CopyFiles */, + CEAA67250C70A882006BD633 /* NSURL_SKExtensions.h in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -537,6 +540,8 @@ CEAA56600C6DE96F006BD633 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Italian; path = Italian.lproj/DownloadsWindow.nib; sourceTree = "<group>"; }; CEAA56D20C6DEE83006BD633 /* Cancel.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Cancel.tiff; path = Images/Cancel.tiff; sourceTree = "<group>"; }; 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>"; }; 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>"; }; @@ -801,6 +806,8 @@ CE070EA10B89039700733CC8 /* NSScrollView_SKExtensions.m */, CE38ECD10B8093B200A1B779 /* NSString_SKExtensions.h */, CE38ECD20B8093B200A1B779 /* NSString_SKExtensions.m */, + CEAA67230C70A882006BD633 /* NSURL_SKExtensions.h */, + CEAA67240C70A882006BD633 /* NSURL_SKExtensions.m */, CEF7119F0B90B714003A2771 /* NSUserDefaultsController_SKExtensions.h */, CEF711A00B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m */, CE41B2C90C08D17100E36EB7 /* NSValue_SKExtensions.h */, @@ -1434,6 +1441,7 @@ CEAA55800C6DE030006BD633 /* SKDownloadController.m in Sources */, CEAA559E0C6DE235006BD633 /* SKDownload.m in Sources */, CEAA55B70C6DE452006BD633 /* SKProgressCell.m in Sources */, + CEAA67260C70A882006BD633 /* NSURL_SKExtensions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-13 14:48:44
|
Revision: 2641 http://skim-app.svn.sourceforge.net/skim-app/?rev=2641&view=rev Author: hofman Date: 2007-08-13 07:48:43 -0700 (Mon, 13 Aug 2007) Log Message: ----------- Clean string for URL or path from pasteboard. Modified Paths: -------------- trunk/SKDocumentController.m trunk/SKDownloadController.m Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-12 23:12:01 UTC (rev 2640) +++ trunk/SKDocumentController.m 2007-08-13 14:48:43 UTC (rev 2641) @@ -174,10 +174,16 @@ } else if ([pboardType isEqualToString:SKWeblocFilePboardType]) { theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; } else if ([pboardType isEqualToString:NSStringPboardType]) { - NSString *string = [pboard stringForType:NSStringPboardType]; + NSString *string = [[pboard stringForType:NSStringPboardType] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if ([string hasPrefix:@"<"] && [string hasSuffix:@">"]) + string = [string substringWithRange:NSMakeRange(1, [string length] - 2)]; theURL = [NSURL URLWithString:string]; - if (theURL == nil && [[NSFileManager defaultManager] fileExistsAtPath:string]) - theURL = [NSURL fileURLWithPath:string]; + if (theURL == nil) { + if ([string hasPrefix:@"~"]) + string = [string stringByExpandingTildeInPath]; + if ([[NSFileManager defaultManager] fileExistsAtPath:string]) + theURL = [NSURL fileURLWithPath:string]; + } } if ([theURL isFileURL]) { document = [self openDocumentWithContentsOfURL:theURL display:YES error:outError]; Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-12 23:12:01 UTC (rev 2640) +++ trunk/SKDownloadController.m 2007-08-13 14:48:43 UTC (rev 2641) @@ -205,10 +205,16 @@ } else if ([type isEqualToString:SKWeblocFilePboardType]) { theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; } else if ([type isEqualToString:NSStringPboardType]) { - NSString *string = [pboard stringForType:NSStringPboardType]; + NSString *string = [[pboard stringForType:NSStringPboardType] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + if ([string hasPrefix:@"<"] && [string hasSuffix:@">"]) + string = [string substringWithRange:NSMakeRange(1, [string length] - 2)]; theURL = [NSURL URLWithString:string]; - if (theURL == nil && [[NSFileManager defaultManager] fileExistsAtPath:string]) - theURL = [NSURL fileURLWithPath:string]; + if (theURL == nil) { + if ([string hasPrefix:@"~"]) + string = [string stringByExpandingTildeInPath]; + if ([[NSFileManager defaultManager] fileExistsAtPath:string]) + theURL = [NSURL fileURLWithPath:string]; + } } if ([theURL isFileURL]) { if ([[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:theURL display:YES error:NULL]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-12 23:12:04
|
Revision: 2640 http://skim-app.svn.sourceforge.net/skim-app/?rev=2640&view=rev Author: hofman Date: 2007-08-12 16:12:01 -0700 (Sun, 12 Aug 2007) Log Message: ----------- Allow URL or path as a string on the pasteboard. Modified Paths: -------------- trunk/SKDocumentController.m trunk/SKDownloadController.m Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-12 14:44:55 UTC (rev 2639) +++ trunk/SKDocumentController.m 2007-08-12 23:12:01 UTC (rev 2640) @@ -138,7 +138,7 @@ - (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard error:(NSError **)outError { // allow any filter services to convert to TIFF data if we can't get PDF or PS directly pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:pboard]; - NSString *pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, NSURLPboardType, SKWeblocFilePboardType, nil]]; + NSString *pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]; id document = nil; if ([pboardType isEqualToString:NSPDFPboardType] || [pboardType isEqualToString:NSPostScriptPboardType] || [pboardType isEqualToString:NSTIFFPboardType]) { @@ -166,13 +166,18 @@ *outError = error; } - } else if ([pboardType isEqualToString:NSURLPboardType] || [pboardType isEqualToString:SKWeblocFilePboardType]) { + } else if ([pboardType isEqualToString:NSURLPboardType] || [pboardType isEqualToString:SKWeblocFilePboardType] || [pboardType isEqualToString:NSStringPboardType]) { NSURL *theURL = nil; if ([pboardType isEqualToString:NSURLPboardType]) { theURL = [NSURL URLFromPasteboard:pboard]; } else if ([pboardType isEqualToString:SKWeblocFilePboardType]) { theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; + } else if ([pboardType isEqualToString:NSStringPboardType]) { + NSString *string = [pboard stringForType:NSStringPboardType]; + theURL = [NSURL URLWithString:string]; + if (theURL == nil && [[NSFileManager defaultManager] fileExistsAtPath:string]) + theURL = [NSURL fileURLWithPath:string]; } if ([theURL isFileURL]) { document = [self openDocumentWithContentsOfURL:theURL display:YES error:outError]; @@ -217,7 +222,7 @@ - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { if ([anItem action] == @selector(newDocumentFromClipboard:)) { NSPasteboard *pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:[NSPasteboard generalPasteboard]]; - return ([[pboard types] firstObjectCommonWithArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]] != nil); + return ([pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]] != nil); } else if ([super respondsToSelector:_cmd]) { return [super validateUserInterfaceItem:anItem]; } else Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-12 14:44:55 UTC (rev 2639) +++ trunk/SKDownloadController.m 2007-08-12 23:12:01 UTC (rev 2640) @@ -186,7 +186,7 @@ - (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op { NSPasteboard *pboard = [info draggingPasteboard]; - NSString *type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, nil]]; + NSString *type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]; if (type) { [tv setDropRow:-1 dropOperation:NSTableViewDropOn]; @@ -197,13 +197,18 @@ - (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op { NSPasteboard *pboard = [info draggingPasteboard]; - NSString *type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, nil]]; + NSString *type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, NSStringPboardType, nil]]; NSURL *theURL; if ([type isEqualToString:NSURLPboardType]) { theURL = [NSURL URLFromPasteboard:pboard]; } else if ([type isEqualToString:SKWeblocFilePboardType]) { theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; + } else if ([type isEqualToString:NSStringPboardType]) { + NSString *string = [pboard stringForType:NSStringPboardType]; + theURL = [NSURL URLWithString:string]; + if (theURL == nil && [[NSFileManager defaultManager] fileExistsAtPath:string]) + theURL = [NSURL fileURLWithPath:string]; } if ([theURL isFileURL]) { if ([[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:theURL display:YES error:NULL]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-12 14:44:58
|
Revision: 2639 http://skim-app.svn.sourceforge.net/skim-app/?rev=2639&view=rev Author: hofman Date: 2007-08-12 07:44:55 -0700 (Sun, 12 Aug 2007) Log Message: ----------- Open download window after adding a download from the clipboard. Select new downloads. Modified Paths: -------------- trunk/SKDocumentController.m trunk/SKDownloadController.m Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-11 22:52:12 UTC (rev 2638) +++ trunk/SKDocumentController.m 2007-08-12 14:44:55 UTC (rev 2639) @@ -178,6 +178,7 @@ document = [self openDocumentWithContentsOfURL:theURL display:YES error:outError]; } else if (theURL) { [[SKDownloadController sharedDownloadController] addDownloadForURL:theURL]; + [[SKDownloadController sharedDownloadController] showWindow:self]; if (outError) *outError = nil; } else if (outError) { Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-11 22:52:12 UTC (rev 2638) +++ trunk/SKDownloadController.m 2007-08-12 14:44:55 UTC (rev 2639) @@ -93,8 +93,10 @@ - (void)addDownloadForURL:(NSURL *)aURL { if (aURL) { - [downloads addObject:[[[SKDownload alloc] initWithURL:aURL delegate:self] autorelease]]; + SKDownload *download = [[[SKDownload alloc] initWithURL:aURL delegate:self] autorelease]; + [downloads addObject:download]; [self reloadTableView]; + [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:[tableView numberOfRows] - 1] byExtendingSelection:NO]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-11 22:52:14
|
Revision: 2638 http://skim-app.svn.sourceforge.net/skim-app/?rev=2638&view=rev Author: hofman Date: 2007-08-11 15:52:12 -0700 (Sat, 11 Aug 2007) Log Message: ----------- Open URLs and webloc files from the clipboard. Add a download if it is a remote URL. Also allow dropping those on the download table. Modified Paths: -------------- trunk/SKDocumentController.h trunk/SKDocumentController.m trunk/SKDownloadController.h trunk/SKDownloadController.m Modified: trunk/SKDocumentController.h =================================================================== --- trunk/SKDocumentController.h 2007-08-11 13:56:44 UTC (rev 2637) +++ trunk/SKDocumentController.h 2007-08-11 22:52:12 UTC (rev 2638) @@ -50,4 +50,5 @@ @interface SKDocumentController : NSDocumentController - (void)newDocumentFromClipboard:(id)sender; +- (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard error:(NSError **)outError; @end Modified: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m 2007-08-11 13:56:44 UTC (rev 2637) +++ trunk/SKDocumentController.m 2007-08-11 22:52:12 UTC (rev 2638) @@ -37,6 +37,8 @@ */ #import "SKDocumentController.h" +#import "SKDocument.h" +#import "SKDownloadController.h" #import "NSString_SKExtensions.h" // See CFBundleTypeName in Info.plist @@ -133,35 +135,68 @@ return pdfData; } -- (void)newDocumentFromClipboard:(id)sender { - +- (id)openDocumentWithContentsOfPasteboard:(NSPasteboard *)pboard error:(NSError **)outError { // allow any filter services to convert to TIFF data if we can't get PDF or PS directly - NSPasteboard *pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:[NSPasteboard generalPasteboard]]; - NSString *pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]]; - if (nil == pboardType) { - NSBeep(); - return; - } + pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:pboard]; + NSString *pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, NSURLPboardType, SKWeblocFilePboardType, nil]]; + id document = nil; - NSData *data = [pboard dataForType:pboardType]; - - // if it's image data, convert to PDF, then explicitly set the pboard type to PDF - if ([pboardType isEqualToString:NSTIFFPboardType]) { - data = convertTIFFDataToPDF(data); - pboardType = NSPDFPboardType; + if ([pboardType isEqualToString:NSPDFPboardType] || [pboardType isEqualToString:NSPostScriptPboardType] || [pboardType isEqualToString:NSTIFFPboardType]) { + + NSData *data = [pboard dataForType:pboardType]; + + // if it's image data, convert to PDF, then explicitly set the pboard type to PDF + if ([pboardType isEqualToString:NSTIFFPboardType]) { + data = convertTIFFDataToPDF(data); + pboardType = NSPDFPboardType; + } + + NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ? SKPostScriptDocumentType : SKPDFDocumentType; + NSError *error = nil; + + document = [self makeUntitledDocumentOfType:type error:&error]; + + if ([document readFromData:data ofType:type error:&error]) { + [self addDocument:document]; + [document makeWindowControllers]; + [document showWindows]; + } else { + document = nil; + if (outError) + *outError = error; + } + + } else if ([pboardType isEqualToString:NSURLPboardType] || [pboardType isEqualToString:SKWeblocFilePboardType]) { + + NSURL *theURL = nil; + if ([pboardType isEqualToString:NSURLPboardType]) { + theURL = [NSURL URLFromPasteboard:pboard]; + } else if ([pboardType isEqualToString:SKWeblocFilePboardType]) { + theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; + } + if ([theURL isFileURL]) { + document = [self openDocumentWithContentsOfURL:theURL display:YES error:outError]; + } else if (theURL) { + [[SKDownloadController sharedDownloadController] addDownloadForURL:theURL]; + if (outError) + *outError = nil; + } else if (outError) { + *outError = [NSError errorWithDomain:SKDocumentErrorDomain code:0 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to load data from clipboard", @"Error description"), NSLocalizedDescriptionKey, nil]]; + } + + } else if (outError) { + *outError = [NSError errorWithDomain:SKDocumentErrorDomain code:0 userInfo:[NSDictionary dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to load data from clipboard", @"Error description"), NSLocalizedDescriptionKey, nil]]; } - NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ? SKPostScriptDocumentType : SKPDFDocumentType; + return document; +} + +- (void)newDocumentFromClipboard:(id)sender { NSError *error = nil; - id document = [self makeUntitledDocumentOfType:type error:&error]; + id document = [self openDocumentWithContentsOfPasteboard:[NSPasteboard generalPasteboard] error:&error]; - if ([document readFromData:data ofType:type error:&error]) { - [self addDocument:document]; - [document makeWindowControllers]; - [document showWindows]; - } else { + if (document == nil && error) [NSApp presentError:error]; - } } - (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL display:(BOOL)displayDocument error:(NSError **)outError { Modified: trunk/SKDownloadController.h =================================================================== --- trunk/SKDownloadController.h 2007-08-11 13:56:44 UTC (rev 2637) +++ trunk/SKDownloadController.h 2007-08-11 22:52:12 UTC (rev 2638) @@ -38,6 +38,7 @@ #import <Cocoa/Cocoa.h> +extern NSString *SKWeblocFilePboardType; @interface SKDownloadController : NSWindowController { IBOutlet NSTableView *tableView; Modified: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m 2007-08-11 13:56:44 UTC (rev 2637) +++ trunk/SKDownloadController.m 2007-08-11 22:52:12 UTC (rev 2638) @@ -40,6 +40,7 @@ #import "SKDownload.h" #import "SKProgressCell.h" +NSString *SKWeblocFilePboardType = @"CorePasteboardFlavorType 0x75726C20"; @implementation SKDownloadController @@ -87,6 +88,7 @@ - (void)windowDidLoad { [self setWindowFrameAutosaveName:@"SKDownloadsWindow"]; [self updateButtons]; + [tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, nil]]; } - (void)addDownloadForURL:(NSURL *)aURL { @@ -180,6 +182,37 @@ return nil; } +- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op { + NSPasteboard *pboard = [info draggingPasteboard]; + NSString *type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, nil]]; + + if (type) { + [tv setDropRow:-1 dropOperation:NSTableViewDropOn]; + return NSDragOperationEvery; + } + return NSDragOperationNone; +} + +- (BOOL)tableView:(NSTableView*)tv acceptDrop:(id <NSDraggingInfo>)info row:(int)row dropOperation:(NSTableViewDropOperation)op { + NSPasteboard *pboard = [info draggingPasteboard]; + NSString *type = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSURLPboardType, SKWeblocFilePboardType, nil]]; + NSURL *theURL; + + if ([type isEqualToString:NSURLPboardType]) { + theURL = [NSURL URLFromPasteboard:pboard]; + } else if ([type isEqualToString:SKWeblocFilePboardType]) { + theURL = [NSURL URLWithString:[pboard stringForType:SKWeblocFilePboardType]]; + } + if ([theURL isFileURL]) { + if ([[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:theURL display:YES error:NULL]) + return YES; + } else if (theURL) { + [self addDownloadForURL:theURL]; + return YES; + } + return NO; +} + #pragma mark NSTableViewDelegate - (void)tableView:(NSTableView *)tv willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(int)row { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-11 13:56:46
|
Revision: 2637 http://skim-app.svn.sourceforge.net/skim-app/?rev=2637&view=rev Author: hofman Date: 2007-08-11 06:56:44 -0700 (Sat, 11 Aug 2007) Log Message: ----------- Add downloads controller and supporting files and menu item. Let pdf view provide service to write pdf from a selection. Modified Paths: -------------- trunk/Dutch.lproj/MainMenu.nib/classes.nib trunk/Dutch.lproj/MainMenu.nib/info.nib trunk/Dutch.lproj/MainMenu.nib/keyedobjects.nib trunk/English.lproj/MainMenu.nib/classes.nib trunk/English.lproj/MainMenu.nib/keyedobjects.nib trunk/French.lproj/MainMenu.nib/classes.nib trunk/French.lproj/MainMenu.nib/keyedobjects.nib trunk/Italian.lproj/MainMenu.nib/classes.nib trunk/Italian.lproj/MainMenu.nib/keyedobjects.nib trunk/SKApplicationController.h trunk/SKApplicationController.m trunk/SKPDFView.m trunk/Skim.xcodeproj/project.pbxproj trunk/vendorsrc/andymatuschak/Sparkle/Sparkle.xcodeproj/project.pbxproj Added Paths: ----------- trunk/Dutch.lproj/DownloadsWindow.nib/ trunk/Dutch.lproj/DownloadsWindow.nib/classes.nib trunk/Dutch.lproj/DownloadsWindow.nib/info.nib trunk/Dutch.lproj/DownloadsWindow.nib/keyedobjects.nib trunk/English.lproj/DownloadsWindow.nib/ trunk/English.lproj/DownloadsWindow.nib/classes.nib trunk/English.lproj/DownloadsWindow.nib/info.nib trunk/English.lproj/DownloadsWindow.nib/keyedobjects.nib trunk/French.lproj/DownloadsWindow.nib/ trunk/French.lproj/DownloadsWindow.nib/classes.nib trunk/French.lproj/DownloadsWindow.nib/info.nib trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib trunk/Images/Cancel.tiff trunk/Images/Delete.tiff trunk/Italian.lproj/DownloadsWindow.nib/ trunk/Italian.lproj/DownloadsWindow.nib/classes.nib trunk/Italian.lproj/DownloadsWindow.nib/info.nib trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib trunk/SKDownload.h trunk/SKDownload.m trunk/SKDownloadController.h trunk/SKDownloadController.m trunk/SKProgressCell.h trunk/SKProgressCell.m Added: trunk/Dutch.lproj/DownloadsWindow.nib/classes.nib =================================================================== --- trunk/Dutch.lproj/DownloadsWindow.nib/classes.nib (rev 0) +++ trunk/Dutch.lproj/DownloadsWindow.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,19 @@ +{ + IBClasses = ( + { + ACTIONS = {"" = id; }; + CLASS = FirstResponder; + LANGUAGE = ObjC; + SUPERCLASS = NSObject; + }, + { + ACTIONS = {cancelDownload = id; clearDownloads = id; removeDownload = id; }; + CLASS = SKDownloadController; + LANGUAGE = ObjC; + OUTLETS = {clearButton = NSButton; tableView = NSTableView; }; + SUPERCLASS = NSWindowController; + }, + {CLASS = SKProgressCell; LANGUAGE = ObjC; SUPERCLASS = NSTextFieldCell; } + ); + IBVersion = 1; +} \ No newline at end of file Added: trunk/Dutch.lproj/DownloadsWindow.nib/info.nib =================================================================== --- trunk/Dutch.lproj/DownloadsWindow.nib/info.nib (rev 0) +++ trunk/Dutch.lproj/DownloadsWindow.nib/info.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>100 77 356 240 0 0 1440 938 </string> + <key>IBFramework Version</key> + <string>446.1</string> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>8R218</string> +</dict> +</plist> Added: trunk/Dutch.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Property changes on: trunk/Dutch.lproj/DownloadsWindow.nib/keyedobjects.nib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/Dutch.lproj/MainMenu.nib/classes.nib =================================================================== --- trunk/Dutch.lproj/MainMenu.nib/classes.nib 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/Dutch.lproj/MainMenu.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -69,6 +69,7 @@ ACTIONS = { editBookmarks = id; openBookmark = id; + showDownloads = id; showPreferencePanel = id; showReleaseNotes = id; visitWebSite = id; Modified: trunk/Dutch.lproj/MainMenu.nib/info.nib =================================================================== --- trunk/Dutch.lproj/MainMenu.nib/info.nib 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/Dutch.lproj/MainMenu.nib/info.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -7,10 +7,14 @@ <key>IBEditorPositions</key> <dict> <key>29</key> - <string>140 614 542 44 0 0 1440 938 </string> + <string>140 614 635 44 0 0 1440 938 </string> </dict> <key>IBFramework Version</key> <string>446.1</string> + <key>IBOpenObjects</key> + <array> + <integer>29</integer> + </array> <key>IBSystem Version</key> <string>8R218</string> </dict> Modified: trunk/Dutch.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Added: trunk/English.lproj/DownloadsWindow.nib/classes.nib =================================================================== --- trunk/English.lproj/DownloadsWindow.nib/classes.nib (rev 0) +++ trunk/English.lproj/DownloadsWindow.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,19 @@ +{ + IBClasses = ( + { + ACTIONS = {"" = id; }; + CLASS = FirstResponder; + LANGUAGE = ObjC; + SUPERCLASS = NSObject; + }, + { + ACTIONS = {cancelDownload = id; clearDownloads = id; removeDownload = id; }; + CLASS = SKDownloadController; + LANGUAGE = ObjC; + OUTLETS = {clearButton = NSButton; tableView = NSTableView; }; + SUPERCLASS = NSWindowController; + }, + {CLASS = SKProgressCell; LANGUAGE = ObjC; SUPERCLASS = NSTextFieldCell; } + ); + IBVersion = 1; +} \ No newline at end of file Added: trunk/English.lproj/DownloadsWindow.nib/info.nib =================================================================== --- trunk/English.lproj/DownloadsWindow.nib/info.nib (rev 0) +++ trunk/English.lproj/DownloadsWindow.nib/info.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>100 77 356 240 0 0 1440 938 </string> + <key>IBFramework Version</key> + <string>446.1</string> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>8R218</string> +</dict> +</plist> Added: trunk/English.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Property changes on: trunk/English.lproj/DownloadsWindow.nib/keyedobjects.nib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/English.lproj/MainMenu.nib/classes.nib =================================================================== --- trunk/English.lproj/MainMenu.nib/classes.nib 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/English.lproj/MainMenu.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -69,6 +69,7 @@ ACTIONS = { editBookmarks = id; openBookmark = id; + showDownloads = id; showPreferencePanel = id; showReleaseNotes = id; visitWebSite = id; Modified: trunk/English.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Added: trunk/French.lproj/DownloadsWindow.nib/classes.nib =================================================================== --- trunk/French.lproj/DownloadsWindow.nib/classes.nib (rev 0) +++ trunk/French.lproj/DownloadsWindow.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,19 @@ +{ + IBClasses = ( + { + ACTIONS = {"" = id; }; + CLASS = FirstResponder; + LANGUAGE = ObjC; + SUPERCLASS = NSObject; + }, + { + ACTIONS = {cancelDownload = id; clearDownloads = id; removeDownload = id; }; + CLASS = SKDownloadController; + LANGUAGE = ObjC; + OUTLETS = {clearButton = NSButton; tableView = NSTableView; }; + SUPERCLASS = NSWindowController; + }, + {CLASS = SKProgressCell; LANGUAGE = ObjC; SUPERCLASS = NSTextFieldCell; } + ); + IBVersion = 1; +} \ No newline at end of file Added: trunk/French.lproj/DownloadsWindow.nib/info.nib =================================================================== --- trunk/French.lproj/DownloadsWindow.nib/info.nib (rev 0) +++ trunk/French.lproj/DownloadsWindow.nib/info.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>100 77 356 240 0 0 1440 938 </string> + <key>IBFramework Version</key> + <string>446.1</string> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>8R218</string> +</dict> +</plist> Added: trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Property changes on: trunk/French.lproj/DownloadsWindow.nib/keyedobjects.nib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/French.lproj/MainMenu.nib/classes.nib =================================================================== --- trunk/French.lproj/MainMenu.nib/classes.nib 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/French.lproj/MainMenu.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -69,6 +69,7 @@ ACTIONS = { editBookmarks = id; openBookmark = id; + showDownloads = id; showPreferencePanel = id; showReleaseNotes = id; visitWebSite = id; Modified: trunk/French.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Added: trunk/Images/Cancel.tiff =================================================================== (Binary files differ) Property changes on: trunk/Images/Cancel.tiff ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Images/Delete.tiff =================================================================== (Binary files differ) Property changes on: trunk/Images/Delete.tiff ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/Italian.lproj/DownloadsWindow.nib/classes.nib =================================================================== --- trunk/Italian.lproj/DownloadsWindow.nib/classes.nib (rev 0) +++ trunk/Italian.lproj/DownloadsWindow.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,19 @@ +{ + IBClasses = ( + { + ACTIONS = {"" = id; }; + CLASS = FirstResponder; + LANGUAGE = ObjC; + SUPERCLASS = NSObject; + }, + { + ACTIONS = {cancelDownload = id; clearDownloads = id; removeDownload = id; }; + CLASS = SKDownloadController; + LANGUAGE = ObjC; + OUTLETS = {clearButton = NSButton; tableView = NSTableView; }; + SUPERCLASS = NSWindowController; + }, + {CLASS = SKProgressCell; LANGUAGE = ObjC; SUPERCLASS = NSTextFieldCell; } + ); + IBVersion = 1; +} \ No newline at end of file Added: trunk/Italian.lproj/DownloadsWindow.nib/info.nib =================================================================== --- trunk/Italian.lproj/DownloadsWindow.nib/info.nib (rev 0) +++ trunk/Italian.lproj/DownloadsWindow.nib/info.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>100 77 356 240 0 0 1440 938 </string> + <key>IBFramework Version</key> + <string>446.1</string> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>8R218</string> +</dict> +</plist> Added: trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib =================================================================== (Binary files differ) Property changes on: trunk/Italian.lproj/DownloadsWindow.nib/keyedobjects.nib ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/Italian.lproj/MainMenu.nib/classes.nib =================================================================== --- trunk/Italian.lproj/MainMenu.nib/classes.nib 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/Italian.lproj/MainMenu.nib/classes.nib 2007-08-11 13:56:44 UTC (rev 2637) @@ -67,6 +67,7 @@ ACTIONS = { editBookmarks = id; openBookmark = id; + showDownloads = id; showPreferencePanel = id; showReleaseNotes = id; visitWebSite = id; Modified: trunk/Italian.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/SKApplicationController.h =================================================================== --- trunk/SKApplicationController.h 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/SKApplicationController.h 2007-08-11 13:56:44 UTC (rev 2637) @@ -50,6 +50,7 @@ - (IBAction)showPreferencePanel:(id)sender; - (IBAction)showReleaseNotes:(id)sender; +- (IBAction)showDownloads:(id)sender; - (IBAction)editBookmarks:(id)sender; - (IBAction)openBookmark:(id)sender; Modified: trunk/SKApplicationController.m =================================================================== --- trunk/SKApplicationController.m 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/SKApplicationController.m 2007-08-11 13:56:44 UTC (rev 2637) @@ -52,6 +52,7 @@ #import "NSBezierPath_BDSKExtensions.h" #import "SKLine.h" #import "NSImage_SKExtensions.h" +#import "SKDownloadController.h" @implementation SKApplicationController @@ -200,6 +201,10 @@ [[SKReleaseNotesController sharedReleaseNotesController] showWindow:self]; } +- (IBAction)showDownloads:(id)sender{ + [[SKDownloadController sharedDownloadController] showWindow:self]; +} + - (IBAction)editBookmarks:(id)sender { [[SKBookmarkController sharedBookmarkController] showWindow:self]; } Added: trunk/SKDownload.h =================================================================== --- trunk/SKDownload.h (rev 0) +++ trunk/SKDownload.h 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,99 @@ +// +// SKDownload.h +// Skim +// +// Created by Christiaan Hofman on 8/11/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +enum { + SKDownloadStatusUndefined, + SKDownloadStatusStarting, + SKDownloadStatusDownloading, + SKDownloadStatusFinished, + SKDownloadStatusFailed, + SKDownloadStatusCanceled +}; + +@interface SKDownload : NSObject { + NSURL *URL; + NSURLDownload *URLDownload; + long long expectedContentLength; + long long receivedContentLength; + NSString *filePath; + NSImage *fileIcon; + NSProgressIndicator *progressIndicator; + int status; + id delegate; +} + +- (id)initWithURL:(NSURL *)aURL delegate:(id)aDelegate; + +- (id)delegate; +- (void)setDelegate:(id)newDelegate; + +- (int)status; +- (void)setStatus:(int)newStatus; + +- (NSURL *)URL; +- (void)setURL:(NSURL *)newURL; + +- (NSString *)filePath; +- (void)setFilePath:(NSString *)newFilePath; + +- (NSString *)fileName; +- (NSImage *)fileIcon; + +- (long long)expectedContentLength; +- (long long)receivedContentLength; + +- (NSURLDownload *)URLDownload; + +- (NSProgressIndicator *)progressIndicator; + +- (void)startDownload; +- (void)cancelDownload; +- (void)cleanupDownload; + +- (BOOL)canCancel; + +@end + + +@interface NSObject (SKDownloadDelegate) +- (void)downloadDidStart:(SKDownload *)download; +- (void)downloadDidUpdate:(SKDownload *)download; +- (void)downloadDidEnd:(SKDownload *)download; +@end Added: trunk/SKDownload.m =================================================================== --- trunk/SKDownload.m (rev 0) +++ trunk/SKDownload.m 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,293 @@ +// +// SKDownload.m +// Skim +// +// Created by Christiaan Hofman on 8/11/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SKDownload.h" +#import <ApplicationServices/ApplicationServices.h> + + +@implementation SKDownload + +- (id)initWithURL:(NSURL *)aURL delegate:(id)aDelegate { + if (self = [super init]) { + URL = [aURL retain]; + URLDownload = nil; + filePath = nil; + fileIcon = nil; + progressIndicator = nil; + status = SKDownloadStatusUndefined; + delegate = aDelegate; + + if (URL) + [self startDownload]; + } + return self; +} + +- (id)init { + return [self initWithURL:nil delegate:nil]; +} + +- (void)dealloc { + [self cancelDownload]; + [URL release]; + [URLDownload release]; + [filePath release]; + [fileIcon release]; + [progressIndicator release]; + [super dealloc]; +} + +#pragma mark Accessors + +- (id)delegate { + return delegate; +} + +- (void)setDelegate:(id)newDelegate { + delegate = newDelegate; +} + +- (int)status { + return status; +} + +- (void)setStatus:(int)newStatus { + if (status != newStatus) { + if (newStatus == SKDownloadStatusDownloading) { + [progressIndicator startAnimation:self]; + } else if (status == SKDownloadStatusDownloading) { + [progressIndicator stopAnimation:self]; + [progressIndicator removeFromSuperview]; + [progressIndicator release]; + progressIndicator = nil; + } + status = newStatus; + } +} + +- (NSURL *)URL { + return URL; +} + +- (void)setURL:(NSURL *)newURL { + if (URL != newURL) { + [URL release]; + URL = [newURL retain]; + } +} + +- (NSString *)filePath { + return filePath; +} + +- (void)setFilePath:(NSString *)newFilePath { + if (filePath != newFilePath) { + [filePath release]; + filePath = [newFilePath retain]; + + if (fileIcon == nil && filePath) { + fileIcon = [[[NSWorkspace sharedWorkspace] iconForFileType:[filePath pathExtension]] retain]; + } + } +} + +- (NSString *)fileName { + NSString *fileName = [[self filePath] lastPathComponent]; + if (fileName == nil) + fileName = [[[self URL] path] lastPathComponent]; + return fileName; +} + +- (NSImage *)fileIcon { + if (fileIcon == nil && URL) + return [[NSWorkspace sharedWorkspace] iconForFileType:[[[self URL] path] pathExtension]]; + return fileIcon; +} + +- (long long)expectedContentLength { + return expectedContentLength; +} + +- (void)setExpectedContentLength:(long long)newExpectedContentLength { + if (expectedContentLength != newExpectedContentLength) { + expectedContentLength = newExpectedContentLength; + if (expectedContentLength > 0) { + [progressIndicator setIndeterminate:NO]; + [progressIndicator setMaxValue:expectedContentLength]; + } else { + [progressIndicator setIndeterminate:YES]; + [progressIndicator setMaxValue:1.0]; + } + } +} + +- (long long)receivedContentLength { + return receivedContentLength; +} + +- (void)setReceivedContentLength:(long long)newReceivedContentLength { + if (receivedContentLength != newReceivedContentLength) { + receivedContentLength = newReceivedContentLength; + [progressIndicator setDoubleValue:(double)receivedContentLength]; + } +} + +- (NSURLDownload *)URLDownload { + return URLDownload; +} + +- (NSProgressIndicator *)progressIndicator { + if (progressIndicator == nil && [self status] == SKDownloadStatusDownloading) { + progressIndicator = [[NSProgressIndicator alloc] init]; + [progressIndicator setStyle:NSProgressIndicatorBarStyle]; + [progressIndicator setControlSize:NSSmallControlSize]; + [progressIndicator sizeToFit]; + if (expectedContentLength > 0) { + [progressIndicator setIndeterminate:NO]; + [progressIndicator setMaxValue:expectedContentLength]; + } else { + [progressIndicator setIndeterminate:YES]; + [progressIndicator setMaxValue:1.0]; + } + if ([self status] == SKDownloadStatusDownloading) + [progressIndicator startAnimation:self]; + } + return progressIndicator; +} + +#pragma mark Actions + +- (void)startDownload { + if (URLDownload || URL == nil) { + NSBeep(); + return; + } + + [self setStatus:SKDownloadStatusDownloading]; + [self setExpectedContentLength:-1]; + [self setReceivedContentLength:0]; + URLDownload = [[NSURLDownload alloc] initWithRequest:[NSURLRequest requestWithURL:URL] delegate:self]; + [self setStatus:SKDownloadStatusStarting]; + if ([delegate respondsToSelector:@selector(downloadDidUpdate:)]) + [delegate downloadDidUpdate:self]; +} + +- (void)cancelDownload { + if ([self canCancel]) { + [self setStatus:SKDownloadStatusCanceled]; + [URLDownload cancel]; + if ([delegate respondsToSelector:@selector(downloadDidEnd:)]) + [delegate downloadDidEnd: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; +} + +#pragma mark NSURLDownloadDelegate protocol + +- (void)downloadDidBegin:(NSURLDownload *)download{ + [self setStatus:SKDownloadStatusDownloading]; + if ([delegate respondsToSelector:@selector(downloadDidStart:)]) + [delegate downloadDidStart:self]; +} + +- (void)download:(NSURLDownload *)download didReceiveResponse:(NSURLResponse *)response { + [self setExpectedContentLength:[response expectedContentLength]]; + + CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (CFStringRef)[response MIMEType], kUTTypeData); + if (UTI) { + CFStringRef type = UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassFilenameExtension); + if (type) { + [fileIcon release]; + fileIcon = [[[NSWorkspace sharedWorkspace] iconForFileType:(NSString *)type] retain]; + CFRelease(type); + } + CFRelease(UTI); + } + + if ([delegate respondsToSelector:@selector(downloadDidUpdate:)]) + [delegate downloadDidUpdate:self]; +} + +- (void)download:(NSURLDownload *)download decideDestinationWithSuggestedFilename:(NSString *)filename { + NSString *tmpDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[[NSProcessInfo processInfo] globallyUniqueString]]; + [[NSFileManager defaultManager] createDirectoryAtPath:tmpDir attributes:nil]; + [URLDownload setDestination:[tmpDir stringByAppendingPathComponent:filename] allowOverwrite:YES]; +} + +- (void)download:(NSURLDownload *)download didCreateDestination:(NSString *)path { + [self setFilePath:path]; + if ([delegate respondsToSelector:@selector(downloadDidUpdate:)]) + [delegate downloadDidUpdate:self]; +} + +- (void)download:(NSURLDownload *)download didReceiveDataOfLength:(unsigned)length { + if (expectedContentLength > 0) { + receivedContentLength += length; + [progressIndicator setDoubleValue:(double)receivedContentLength]; + if ([delegate respondsToSelector:@selector(downloadDidUpdate:)]) + [delegate downloadDidUpdate:self]; + } +} + +- (void)downloadDidFinish:(NSURLDownload *)theDownload { + [self setStatus:SKDownloadStatusFinished]; + if ([delegate respondsToSelector:@selector(downloadDidEnd:)]) + [delegate downloadDidEnd:self]; +} + +- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error { + [self setStatus:SKDownloadStatusFailed]; + if (filePath) + [[NSFileManager defaultManager] removeFileAtPath:filePath handler:nil]; + [self setFilePath:nil]; + if ([delegate respondsToSelector:@selector(downloadDidEnd:)]) + [delegate downloadDidEnd:self]; +} + +@end Added: trunk/SKDownloadController.h =================================================================== --- trunk/SKDownloadController.h (rev 0) +++ trunk/SKDownloadController.h 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,56 @@ +// +// SKDownloadController.h +// Skim +// +// Created by Christiaan Hofman on 8/11/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + + +@interface SKDownloadController : NSWindowController { + IBOutlet NSTableView *tableView; + IBOutlet NSButton *clearButton; + NSMutableArray *downloads; +} + ++ (id)sharedDownloadController; + +- (void)addDownloadForURL:(NSURL *)aURL; + +- (IBAction)clearDownloads:(id)sender; +- (IBAction)removeDownload:(id)sender; +- (IBAction)cancelDownload:(id)sender; + +@end Added: trunk/SKDownloadController.m =================================================================== --- trunk/SKDownloadController.m (rev 0) +++ trunk/SKDownloadController.m 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,218 @@ +// +// SKDownloadController.m +// Skim +// +// Created by Christiaan Hofman on 8/11/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SKDownloadController.h" +#import "SKDownload.h" +#import "SKProgressCell.h" + + +@implementation SKDownloadController + ++ (id)sharedDownloadController { + static SKDownloadController *sharedDownloadController = nil; + if (sharedDownloadController == nil) + sharedDownloadController = [[self alloc] init]; + return sharedDownloadController; +} + +- (id)init { + if (self = [super init]) { + downloads = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void)dealloc { + [downloads release]; + [super dealloc]; +} + +- (NSString *)windowNibName { return @"DownloadsWindow"; } + +- (void)reloadTableView { + NSView *view; + while (view = [[tableView subviews] lastObject]) + [view removeFromSuperview]; + [tableView reloadData]; +} + +- (void)updateButtons { + BOOL enable = NO; + NSEnumerator *downloadEnum = [downloads objectEnumerator]; + SKDownload *download; + while (download = [downloadEnum nextObject]) { + if ([download canCancel] == NO) { + enable = YES; + break; + } + } + [clearButton setEnabled:enable]; +} + +- (void)windowDidLoad { + [self setWindowFrameAutosaveName:@"SKDownloadsWindow"]; + [self updateButtons]; +} + +- (void)addDownloadForURL:(NSURL *)aURL { + if (aURL) { + [downloads addObject:[[[SKDownload alloc] initWithURL:aURL delegate:self] autorelease]]; + [self reloadTableView]; + } +} + +#pragma mark Actions + +- (IBAction)clearDownloads:(id)sender { + int index = [downloads count]; + + if (index) { + while (index-- > 0) { + SKDownload *download = [downloads objectAtIndex:index]; + if ([download status] != SKDownloadStatusDownloading) + [downloads removeObjectAtIndex:index]; + } + [self reloadTableView]; + [self updateButtons]; + } +} + +- (IBAction)cancelDownload:(id)sender { + int row = [tableView clickedRow]; + + if (row != -1) { + SKDownload *download = [downloads objectAtIndex:row]; + if ([download status] == SKDownloadStatusDownloading) { + [download cancelDownload]; + } + } +} + +- (IBAction)removeDownload:(id)sender { + int row = [tableView clickedRow]; + + if (row != -1) { + SKDownload *download = [downloads objectAtIndex:row]; + if ([download status] == SKDownloadStatusDownloading) + [download cancelDownload]; + [downloads removeObjectAtIndex:row]; + [self reloadTableView]; + [self updateButtons]; + } +} + +#pragma mark SKDownloadDelegate + +- (void)downloadDidStart:(SKDownload *)download { + [self reloadTableView]; + [self updateButtons]; +} + +- (void)downloadDidUpdate:(SKDownload *)download { + [tableView reloadData]; + [self updateButtons]; +} + +- (void)downloadDidEnd:(SKDownload *)download { + [self reloadTableView]; + [self updateButtons]; + + if ([download status] == SKDownloadStatusFinished) { + NSURL *URL = [NSURL fileURLWithPath:[download filePath]]; + NSError *error = nil; + if (NO == [[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:URL display:YES error:&error]) + [NSApp presentError:error]; + } + + [download cleanupDownload]; +} + +#pragma mark NSTableViewDataSource + +- (int)numberOfRowsInTableView:(NSTableView *)tv { + return [downloads count]; +} + +- (id)tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { + NSString *identifier = [tableColumn identifier]; + SKDownload *download = [downloads objectAtIndex:row]; + + if ([identifier isEqualToString:@"progress"]) { + return [download fileName]; + } else if ([identifier isEqualToString:@"icon"]) { + return [download fileIcon]; + } + return nil; +} + +#pragma mark NSTableViewDelegate + +- (void)tableView:(NSTableView *)tv willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn row:(int)row { + NSString *identifier = [tableColumn identifier]; + SKDownload *download = [downloads objectAtIndex:row]; + + if ([identifier isEqualToString:@"progress"]) { + if ([cell respondsToSelector:@selector(setProgressIndicator:)]) + [(SKProgressCell *)cell setProgressIndicator:[download progressIndicator]]; + if ([cell respondsToSelector:@selector(setStatus:)]) + [(SKProgressCell *)cell setStatus:[download status]]; + } else if ([identifier isEqualToString:@"cancel"]) { + if ([download canCancel]) { + [cell setImage:[NSImage imageNamed:@"Cancel"]]; + [cell setAction:@selector(cancelDownload:)]; + [cell setTarget:self]; + } else { + [cell setImage:[NSImage imageNamed:@"Delete"]]; + [cell setAction:@selector(removeDownload:)]; + [cell setTarget:self]; + } + } +} + +- (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tableColumn row:(int)row mouseLocation:(NSPoint)mouseLocation { + NSString *toolTip = nil; + if ([[tableColumn identifier] isEqualToString:@"cancel"]) { + if ([[downloads objectAtIndex:row] canCancel]) + toolTip = NSLocalizedString(@"Cancel download", @""); + else + toolTip = NSLocalizedString(@"Remove download", @""); + } + return toolTip; +} + +@end Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/SKPDFView.m 2007-08-11 13:56:44 UTC (rev 2637) @@ -146,6 +146,15 @@ @implementation SKPDFView ++ (void)initialize { + static BOOL initialized = NO; + if (initialized == YES) return; + initialized = YES; + + NSArray *sendTypes = [NSArray arrayWithObjects:NSPDFPboardType, NSTIFFPboardType, nil]; + [NSApp registerServicesMenuSendTypes:sendTypes returnTypes:nil]; +} + - (void)commonInitialization { toolMode = [[NSUserDefaults standardUserDefaults] integerForKey:SKLastToolModeKey]; annotationMode = [[NSUserDefaults standardUserDefaults] integerForKey:SKLastAnnotationModeKey]; @@ -1554,6 +1563,99 @@ return performedDrag; } +#pragma mark Services + +- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types { + if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO && ([types containsObject:NSPDFPboardType] || [types containsObject:NSTIFFPboardType])) { + NSMutableArray *writeTypes = [NSMutableArray array]; + NSData *pdfData = nil; + NSData *tiffData = nil; + + NSRect selRect = NSIntegralRect(selectionRect); + NSRect targetRect = selRect; + + if ([types containsObject:NSPDFPboardType]) { + PDFPage *page = [self currentPage]; + + if ([page rotation]) { + NSAffineTransform *transform = [NSAffineTransform transform]; + NSRect bounds = [page boundsForBox:kPDFDisplayBoxMediaBox]; + switch ([page rotation]) { + case 90: + [transform translateXBy:0.0 yBy:NSWidth(bounds)]; + break; + case 180: + [transform translateXBy:NSWidth(bounds) yBy:NSHeight(bounds)]; + break; + case 270: + [transform translateXBy:NSHeight(bounds) yBy:0.0]; + break; + } + [transform rotateByDegrees:-[page rotation]]; + targetRect.origin = [transform transformPoint:targetRect.origin]; + targetRect.size = [transform transformSize:targetRect.size]; + if (NSWidth(targetRect) < 0.0) { + targetRect.origin.x += NSWidth(targetRect); + targetRect.size.width *= -1.0; + } + if (NSHeight(targetRect) < 0.0) { + targetRect.origin.y += NSHeight(targetRect); + targetRect.size.height *= -1.0; + } + } + + PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[page dataRepresentation]]; + page = [pdfDoc pageAtIndex:0]; + [page setBounds:targetRect forBox:kPDFDisplayBoxCropBox]; + [page setBounds:NSZeroRect forBox:kPDFDisplayBoxBleedBox]; + [page setBounds:NSZeroRect forBox:kPDFDisplayBoxTrimBox]; + [page setBounds:NSZeroRect forBox:kPDFDisplayBoxArtBox]; + + if (pdfData = [page dataRepresentation]) + [writeTypes addObject:NSPDFPboardType]; + [pdfDoc release]; + } + + if ([types containsObject:NSTIFFPboardType]) { + NSRect bounds = [[self currentPage] boundsForBox:[self displayBox]]; + NSRect sourceRect = selRect; + NSImage *pageImage = [[self currentPage] imageForBox:[self displayBox]]; + NSImage *image = nil; + + sourceRect.origin.x -= NSMinX(bounds); + sourceRect.origin.y -= NSMinY(bounds); + targetRect.origin = NSZeroPoint; + targetRect.size = sourceRect.size; + image = [[NSImage alloc] initWithSize:targetRect.size]; + [image lockFocus]; + [pageImage drawInRect:targetRect fromRect:sourceRect operation:NSCompositeCopy fraction:1.0]; + [image unlockFocus]; + if (tiffData = [image TIFFRepresentation]) + [writeTypes addObject:NSTIFFPboardType]; + [image release]; + } + + [pboard declareTypes:writeTypes owner:nil]; + if (pdfData) + [pboard setData:pdfData forType:NSPDFPboardType]; + if (tiffData) + [pboard setData:tiffData forType:NSTIFFPboardType]; + + return YES; + + } else if ([[SKPDFView superclass] instancesRespondToSelector:_cmd]) { + return [super writeSelectionToPasteboard:pboard types:types]; + } + return NO; +} + +- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { + if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO && returnType == nil && ([sendType isEqualToString:NSPDFPboardType] || [sendType isEqualToString:NSTIFFPboardType])) { + return self; + } + return [super validRequestorForSendType:sendType returnType:returnType]; +} + #pragma mark UndoManager - (NSUndoManager *)undoManager { Added: trunk/SKProgressCell.h =================================================================== --- trunk/SKProgressCell.h (rev 0) +++ trunk/SKProgressCell.h 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,53 @@ +// +// SKProgressCell.h +// Skim +// +// Created by Christiaan Hofman on 8/11/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + + +@interface SKProgressCell : NSTextFieldCell { + NSProgressIndicator *progressIndicator; + int status; +} + +- (NSProgressIndicator *)progressIndicator; +- (void)setProgressIndicator:(NSProgressIndicator *)newProgressIndicator; + +- (int)status; +- (void)setStatus:(int)newStatus; + +@end Added: trunk/SKProgressCell.m =================================================================== --- trunk/SKProgressCell.m (rev 0) +++ trunk/SKProgressCell.m 2007-08-11 13:56:44 UTC (rev 2637) @@ -0,0 +1,118 @@ +// +// SKProgressCell.m +// Skim +// +// Created by Christiaan Hofman on 8/11/07. +/* + This software is Copyright (c) 2007 + Christiaan Hofman. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + - Neither the name of Christiaan Hofman nor the names of any + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "SKProgressCell.h" +#import "SKDownload.h" +#import "NSString_SKExtensions.h" + +#define MARGIN_X 8.0 +#define MARGIN_Y 2.0 + +@implementation SKProgressCell + +- (void)dealloc { + [progressIndicator release]; + [super dealloc]; +} + +- (NSProgressIndicator *)progressIndicator { + return [[progressIndicator retain] autorelease]; +} + +- (void)setProgressIndicator:(NSProgressIndicator *)newProgressIndicator { + if (progressIndicator != newProgressIndicator) { + [progressIndicator release]; + progressIndicator = [newProgressIndicator retain]; + } +} + +- (int)status { + return status; +} + +- (void)setStatus:(int)newStatus { + if (status != newStatus) { + status = newStatus; + } +} + +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { + NSRect textRect = NSInsetRect(cellFrame, MARGIN_X, 0.0); + + textRect.size.height = [self cellSize].height; + if ([controlView isFlipped]) + textRect.origin.y = NSMaxY(cellFrame) - NSHeight(textRect); + [super drawWithFrame:textRect inView:controlView]; + + if (progressIndicator) { + NSRect barRect = NSInsetRect(cellFrame, MARGIN_X, 0.0); + barRect.size.height = NSHeight([progressIndicator frame]); + if ([controlView isFlipped]) + barRect.origin.y += MARGIN_Y; + else + barRect.origin.y = NSMaxY(cellFrame) - NSHeight(barRect) - MARGIN_Y; + [progressIndicator setFrame:barRect]; + + if ([progressIndicator isDescendantOf:controlView] == NO) + [controlView addSubview:progressIndicator]; + } else { + if ([controlView isFlipped] == NO) + textRect.origin.y = NSMaxY(cellFrame) - NSHeight(textRect); + id value = [[[self objectValue] retain] autorelease]; + NSString *string = nil; + switch (status) { + case SKDownloadStatusStarting: + string = [NSLocalizedString(@"Starting", @"") stringByAppendingEllipsis]; + break; + case SKDownloadStatusFinished: + string = NSLocalizedString(@"Finished", @""); + break; + case SKDownloadStatusFailed: + string = NSLocalizedString(@"Failed", @""); + break; + case SKDownloadStatusCanceled: + string = NSLocalizedString(@"Canceled", @""); + break; + } + [self setObjectValue:string]; + [super drawWithFrame:textRect inView:controlView]; + [self setObjectValue:value]; + } +} + +@end Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-08-11 13:56:44 UTC (rev 2637) @@ -155,6 +155,12 @@ CEA575CE0B9206E60003D2E7 /* SKNoteOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = CEA575CD0B9206E60003D2E7 /* SKNoteOutlineView.m */; }; CEA575E50B9207B80003D2E7 /* SKThumbnailTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = CEA575E40B9207B80003D2E7 /* SKThumbnailTableView.m */; }; CEA575FD0B9208B60003D2E7 /* SKOutlineView.m in Sources */ = {isa = PBXBuildFile; fileRef = CEA575FC0B9208B60003D2E7 /* SKOutlineView.m */; }; + CEAA55800C6DE030006BD633 /* SKDownloadController.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAA557E0C6DE030006BD633 /* SKDownloadController.m */; }; + CEAA559E0C6DE235006BD633 /* SKDownload.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAA559C0C6DE235006BD633 /* SKDownload.m */; }; + CEAA55B70C6DE452006BD633 /* SKProgressCell.m in Sources */ = {isa = PBXBuildFile; fileRef = CEAA55B50C6DE452006BD633 /* SKProgressCell.m */; }; + CEAA55F10C6DE5AE006BD633 /* DownloadsWindow.nib in Resources */ = {isa = PBXBuildFile; fileRef = CEAA55EF0C6DE5AE006BD633 /* DownloadsWindow.nib */; }; + CEAA56D40C6DEE83006BD633 /* Cancel.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CEAA56D20C6DEE83006BD633 /* Cancel.tiff */; }; + CEAA56D50C6DEE83006BD633 /* Delete.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CEAA56D30C6DEE83006BD633 /* Delete.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 */; }; @@ -519,6 +525,18 @@ CEA575E40B9207B80003D2E7 /* SKThumbnailTableView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKThumbnailTableView.m; sourceTree = "<group>"; }; CEA575FB0B9208B60003D2E7 /* SKOutlineView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKOutlineView.h; sourceTree = "<group>"; }; CEA575FC0B9208B60003D2E7 /* SKOutlineView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKOutlineView.m; sourceTree = "<group>"; }; + CEAA557D0C6DE02F006BD633 /* SKDownloadController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKDownloadController.h; sourceTree = "<group>"; }; + CEAA557E0C6DE030006BD633 /* SKDownloadController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKDownloadController.m; sourceTree = "<group>"; }; + CEAA559B0C6DE235006BD633 /* SKDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKDownload.h; sourceTree = "<group>"; }; + CEAA559C0C6DE235006BD633 /* SKDownload.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKDownload.m; sourceTree = "<group>"; }; + CEAA55B40C6DE452006BD633 /* SKProgressCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKProgressCell.h; sourceTree = "<group>"; }; + CEAA55B50C6DE452006BD633 /* SKProgressCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKProgressCell.m; sourceTree = "<group>"; }; + CEAA55F00C6DE5AE006BD633 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/DownloadsWindow.nib; sourceTree = "<group>"; }; + CEAA565E0C6DE967006BD633 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Dutch; path = Dutch.lproj/DownloadsWindow.nib; sourceTree = "<group>"; }; + CEAA565F0C6DE96A006BD633 /* French */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = French; path = French.lproj/DownloadsWindow.nib; sourceTree = "<group>"; }; + CEAA56600C6DE96F006BD633 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = Italian; path = Italian.lproj/DownloadsWindow.nib; sourceTree = "<group>"; }; + CEAA56D20C6DEE83006BD633 /* Cancel.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Cancel.tiff; path = Images/Cancel.tiff; sourceTree = "<group>"; }; + CEAA56D30C6DEE83006BD633 /* Delete.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = Delete.tiff; path = Images/Delete.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>"; }; @@ -715,6 +733,7 @@ CE327A440C11BF6700DB4BEB /* NoteTypeSheet.nib */, CE9A878D0C0C9E9A004F1F97 /* ProgressSheet.nib */, CE4A65CA0BAB1E2E004AD07D /* BookmarksWindow.nib */, + CEAA55EF0C6DE5AE006BD633 /* DownloadsWindow.nib */, 2A37F4B9FDCFA73011CA2CEA /* Credits.rtf */, CE54AA8E0BBC037400008750 /* ReleaseNotes.rtf */, 8D15AC360486D014006FF6A4 /* Info.plist */, @@ -839,6 +858,10 @@ CE8B46E70C29CA00005CE7F1 /* SKLineInspector.m */, CE4A659D0BAB1598004AD07D /* SKBookmarkController.h */, CE4A659E0BAB1598004AD07D /* SKBookmarkController.m */, + CEAA557D0C6DE02F006BD633 /* SKDownloadController.h */, + CEAA557E0C6DE030006BD633 /* SKDownloadController.m */, + CEAA559B0C6DE235006BD633 /* SKDownload.h */, + CEAA559C0C6DE235006BD633 /* SKDownload.m */, CE54898D0B35D50E00F8AFB6 /* SKInfoWindowController.h */, CE54898E0B35D50E00F8AFB6 /* SKInfoWindowController.m */, CE4EC4F30B7E24490091F228 /* SKPreferenceController.h */, @@ -887,6 +910,8 @@ CEA575FC0B9208B60003D2E7 /* SKOutlineView.m */, 4530DCF50B27CACE007C59F4 /* SKPDFView.h */, 4530DCF60B27CACE007C59F4 /* SKPDFView.m */, + CEAA55B40C6DE452006BD633 /* SKProgressCell.h */, + CEAA55B50C6DE452006BD633 /* SKProgressCell.m */, CE4EC88A0B7E6EDB0091F228 /* SKSplitView.h */, CE4EC88B0B7E6EDB0091F228 /* SKSplitView.m */, CEAF079A0C4139EB00C3ECBB /* SKStatusBar.h */, @@ -974,6 +999,8 @@ CE07158A0B8A3D6300733CC8 /* PDFDocument.icns */, CE4373B30BB5440E00A56987 /* PSDocument.icns */, CE4D88D70C3AE52F002C20CB /* DVIDocument.icns */, + CEAA56D20C6DEE83006BD633 /* Cancel.tiff */, + CEAA56D30C6DEE83006BD633 /* Delete.tiff */, CE0715890B8A3D6300733CC8 /* NoteDocument.icns */, CE7C5D180BD8086C0011315D /* ToolbarLineNote.tiff */, CE4190C20B94963A00ECF819 /* ToolbarCircleNote.tiff */, @@ -1222,6 +1249,9 @@ CE2082E40C5E09DC009D3EFB /* ResizeLeftUpCursor.tiff in Resources */, CE2082E50C5E09DC009D3EFB /* ResizeRightDownCursor.tiff in Resources */, CE2082E60C5E09DC009D3EFB /* ResizeRightUpCursor.tiff in Resources */, + CEAA55F10C6DE5AE006BD633 /* DownloadsWindow.nib in Resources */, + CEAA56D40C6DEE83006BD633 /* Cancel.tiff in Resources */, + CEAA56D50C6DEE83006BD633 /* Delete.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1401,6 +1431,9 @@ CECDD2990C5B68580026AAEC /* SKCenteredTextFieldCell.m in Sources */, CECDDBAE0C5BB9600026AAEC /* SKFindTableView.m in Sources */, CE2093910C5F9A8D009D3EFB /* BDSKGradientView.m in Sources */, + CEAA55800C6DE030006BD633 /* SKDownloadController.m in Sources */, + CEAA559E0C6DE235006BD633 /* SKDownload.m in Sources */, + CEAA55B70C6DE452006BD633 /* SKProgressCell.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1620,6 +1653,17 @@ name = PreferenceWindow.nib; sourceTree = "<group>"; }; + CEAA55EF0C6DE5AE006BD633 /* DownloadsWindow.nib */ = { + isa = PBXVariantGroup; + children = ( + CEAA55F00C6DE5AE006BD633 /* English */, + CEAA565E0C6DE967006BD633 /* Dutch */, + CEAA565F0C6DE96A006BD633 /* French */, + CEAA56600C6DE96F006BD633 /* Italian */, + ); + name = DownloadsWindow.nib; + sourceTree = "<group>"; + }; CEE106580BCBBE1200BF2D3E /* NotesDocument.nib */ = { isa = PBXVariantGroup; children = ( Modified: trunk/vendorsrc/andymatuschak/Sparkle/Sparkle.xcodeproj/project.pbxproj =================================================================== --- trunk/vendorsrc/andymatuschak/Sparkle/Sparkle.xcodeproj/project.pbxproj 2007-08-09 20:25:11 UTC (rev 2636) +++ trunk/vendorsrc/andymatuschak/Sparkle/Sparkle.xcodeproj/project.pbxproj 2007-08-11 13:56:44 UTC (rev 2637) @@ -104,7 +104,7 @@ 61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SUUpdater.m; sourceTree = "<group>"; }; 61B5F8E509C4CE3C00B25A18 /* NSFileManager+Authentication.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = "NSFileManager+Authentication.m"; sourceTree = "<group>"; }; 61B5F8F609C4CEB300B25A18 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; }; - 61B5F90209C4CEE200B25A18 /* Sparkle Test App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sparkle Test App.app"; sourceTree = BU... [truncated message content] |
From: <ho...@us...> - 2007-08-09 20:25:15
|
Revision: 2636 http://skim-app.svn.sourceforge.net/skim-app/?rev=2636&view=rev Author: hofman Date: 2007-08-09 13:25:11 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Shade secondary copies of the selection rect in select tool mode. Modified Paths: -------------- trunk/SKPDFView.h trunk/SKPDFView.m Modified: trunk/SKPDFView.h =================================================================== --- trunk/SKPDFView.h 2007-08-09 19:22:36 UTC (rev 2635) +++ trunk/SKPDFView.h 2007-08-09 20:25:11 UTC (rev 2636) @@ -177,6 +177,7 @@ - (void)handleAnnotationWillChangeNotification:(NSNotification *)notification; - (void)handleAnnotationDidChangeNotification:(NSNotification *)notification; +- (void)handlePageChangedNotification:(NSNotification *)notification; - (void)handleWindowWillCloseNotification:(NSNotification *)notification; - (void)resetHoverRects; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-08-09 19:22:36 UTC (rev 2635) +++ trunk/SKPDFView.m 2007-08-09 20:25:11 UTC (rev 2636) @@ -190,6 +190,8 @@ name:SKAnnotationWillChangeNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAnnotationDidChangeNotification:) name:SKAnnotationDidChangeNotification object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePageChangedNotification:) + name:PDFViewPageChangedNotification object:self]; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeys: [NSArray arrayWithObjects:SKReadingBarColorKey, SKReadingBarInvertKey, nil]]; } @@ -383,6 +385,11 @@ CGContextAddRect(context, *(CGRect *)&selectionRect); CGContextSetFillColor(context, color); CGContextEOFillPath(context); + if ([pdfPage isEqual:[self currentPage]] == NO) { + color[3] = 0.3; + CGContextSetFillColor(context, color); + CGContextFillRect(context, *(CGRect *)&selectionRect); + } SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMinY(selectionRect)), radius); SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMaxY(selectionRect)), radius); SKCGContextDrawGrabHandle(context, CGPointMake(NSMaxX(selectionRect), NSMinY(selectionRect)), radius); @@ -2022,6 +2029,11 @@ } } +- (void)handlePageChangedNotification:(NSNotification *)notification { + if ([self toolMode] == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) + [self setNeedsDisplay:YES]; +} + #pragma mark FullScreen navigation and autohide - (void)handleWindowWillCloseNotification:(NSNotification *)notification { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-09 19:22:37
|
Revision: 2635 http://skim-app.svn.sourceforge.net/skim-app/?rev=2635&view=rev Author: hofman Date: 2007-08-09 12:22:36 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Temporarily disable flushing while selecting a snapshot area for smoother drawing. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-08-09 18:31:27 UTC (rev 2634) +++ trunk/SKPDFView.m 2007-08-09 19:22:36 UTC (rev 2635) @@ -3212,11 +3212,14 @@ while (YES) { theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | NSLeftMouseDraggedMask | NSFlagsChangedMask]; + [[self window] disableFlushWindow]; [[self window] restoreCachedImage]; - [[self window] flushWindow]; - if ([theEvent type] == NSLeftMouseUp) + if ([theEvent type] == NSLeftMouseUp) { + [[self window] enableFlushWindow]; + [[self window] flushWindow]; break; + } if ([theEvent type] == NSLeftMouseDragged) { // change mouseLoc @@ -3260,6 +3263,7 @@ [NSBezierPath strokeRect:NSInsetRect(NSIntegralRect([self convertRect:selRect fromView:[self documentView]]), 0.5, 0.5)]; [NSGraphicsContext restoreGraphicsState]; [self unlockFocus]; + [[self window] enableFlushWindow]; [[self window] flushWindow]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-09 18:31:36
|
Revision: 2634 http://skim-app.svn.sourceforge.net/skim-app/?rev=2634&view=rev Author: hofman Date: 2007-08-09 11:31:27 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Remove Fit popup item from zoomable PDF view, and instead redefine the Auto item to automatically fit the content. Rename flag. Modified Paths: -------------- trunk/BDSKZoomablePDFView.h trunk/BDSKZoomablePDFView.m trunk/SKMainWindowController.h trunk/SKMainWindowController.m trunk/SKPDFView.m trunk/SKSnapshotWindowController.h trunk/SKSnapshotWindowController.m Modified: trunk/BDSKZoomablePDFView.h =================================================================== --- trunk/BDSKZoomablePDFView.h 2007-08-09 15:30:11 UTC (rev 2633) +++ trunk/BDSKZoomablePDFView.h 2007-08-09 18:31:27 UTC (rev 2634) @@ -42,15 +42,14 @@ @interface BDSKZoomablePDFView : PDFView { NSPopUpButton *scalePopUpButton; - PDFPage *page; - NSRect fitRect; - BOOL fits; + PDFPage *autoFitPage; + NSRect autoFitRect; + BOOL autoFits; } -- (BOOL)fits; -- (void)setFits:(BOOL)newFits; -- (void)setFits:(BOOL)newFits adjustPopup:(BOOL)flag; -- (void)setAutoScales:(BOOL)newAuto adjustPopup:(BOOL)flag; +- (BOOL)autoFits; +- (void)setAutoFits:(BOOL)newAuto; +- (void)setAutoFits:(BOOL)newAuto adjustPopup:(BOOL)flag; - (void)setScaleFactor:(float)factor adjustPopup:(BOOL)flag; - (void)scalePopUpAction:(id)sender; - (NSScrollView *)scrollView; @@ -58,6 +57,6 @@ - (void)setScrollerSize:(NSControlSize)controlSize; - (void)dragWithEvent:(NSEvent *)theEvent; - (void)handlePDFViewFrameChangedNotification:(NSNotification *)notification; -- (void)resetFitRectIfNeeded; +- (void)resetAutoFitRectIfNeeded; @end Modified: trunk/BDSKZoomablePDFView.m =================================================================== --- trunk/BDSKZoomablePDFView.m 2007-08-09 15:30:11 UTC (rev 2633) +++ trunk/BDSKZoomablePDFView.m 2007-08-09 18:31:27 UTC (rev 2634) @@ -48,7 +48,6 @@ @implementation BDSKZoomablePDFView /* For genstrings: - NSLocalizedStringFromTable(@"Fit", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"Auto", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"10%", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"25%", @"ZoomValues", @"Zoom popup entry") @@ -60,8 +59,8 @@ NSLocalizedStringFromTable(@"400%", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"800%", @"ZoomValues", @"Zoom popup entry") */ -static NSString *BDSKDefaultScaleMenuLabels[] = {/* @"Set...", */ @"Fit", @"Auto", @"10%", @"25%", @"50%", @"75%", @"100%", @"128%", @"150%", @"200%", @"400%", @"800%"}; -static float BDSKDefaultScaleMenuFactors[] = {/* 0.0, */ -1, 0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.28, 1.5, 2.0, 4.0, 8.0}; +static NSString *BDSKDefaultScaleMenuLabels[] = {/* @"Set...", */ @"Auto", @"10%", @"25%", @"50%", @"75%", @"100%", @"128%", @"150%", @"200%", @"400%", @"800%"}; +static float BDSKDefaultScaleMenuFactors[] = {/* 0.0, */ 0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.28, 1.5, 2.0, 4.0, 8.0}; static float BDSKScaleMenuFontSize = 11.0; #pragma mark Popup button @@ -69,8 +68,8 @@ - (id)initWithFrame:(NSRect)frameRect { if (self = [super initWithFrame:frameRect]) { scalePopUpButton = nil; - page = nil; - fitRect = NSZeroRect; + autoFitPage = nil; + autoFitRect = NSZeroRect; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) name:NSViewFrameDidChangeNotification object:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) @@ -82,8 +81,8 @@ - (id)initWithCoder:(NSCoder *)decoder { if (self = [super initWithCoder:decoder]) { scalePopUpButton = nil; - page = nil; - fitRect = NSZeroRect; + autoFitPage = nil; + autoFitRect = NSZeroRect; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) name:NSViewFrameDidChangeNotification object:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) @@ -163,56 +162,55 @@ } - (void)handlePDFViewFrameChangedNotification:(NSNotification *)notification { - if (fits) { + if ([self autoFits]) { NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; NSRect rect = [self convertRect:[clipView visibleRect] fromView:clipView]; - BOOL scaleWidth = NSWidth(rect) / NSHeight(rect) < NSWidth(fitRect) / NSHeight(fitRect); - float factor = scaleWidth ? NSWidth(rect) / NSWidth(fitRect) : NSHeight(rect) / NSHeight(fitRect); - NSRect viewRect = scaleWidth ? NSInsetRect(fitRect, 0.0, 0.5 * (NSHeight(fitRect) - NSHeight(rect) / factor)) : NSInsetRect(fitRect, 0.5 * (NSWidth(fitRect) - NSWidth(rect) / factor), 0.0); + BOOL scaleWidth = NSWidth(rect) / NSHeight(rect) < NSWidth(autoFitRect) / NSHeight(autoFitRect); + float factor = scaleWidth ? NSWidth(rect) / NSWidth(autoFitRect) : NSHeight(rect) / NSHeight(autoFitRect); + NSRect viewRect = scaleWidth ? NSInsetRect(autoFitRect, 0.0, 0.5 * (NSHeight(autoFitRect) - NSHeight(rect) / factor)) : NSInsetRect(autoFitRect, 0.5 * (NSWidth(autoFitRect) - NSWidth(rect) / factor), 0.0); [super setScaleFactor:factor]; - viewRect = [self convertRect:[self convertRect:viewRect fromPage:page] toView:[self documentView]]; + viewRect = [self convertRect:[self convertRect:viewRect fromPage:autoFitPage] toView:[self documentView]]; [[self documentView] scrollRectToVisible:viewRect]; } } -- (void)resetFitRectIfNeeded { - if ([self fits]) { +- (void)resetAutoFitRectIfNeeded { + if ([self autoFits]) { NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; - page = [self currentPage]; - fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + autoFitPage = [self currentPage]; + autoFitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:autoFitPage]; } } - (void)scalePopUpAction:(id)sender { - int index = [sender indexOfSelectedItem]; - NSNumber *selectedFactorObject = [[sender selectedCell] representedObject]; - if(index == 0) - [self setFits:YES adjustPopup:NO]; - else if(index == 1) - [self setAutoScales:YES adjustPopup:NO]; - else if(selectedFactorObject) + NSNumber *selectedFactorObject = [[sender selectedItem] representedObject]; + if(selectedFactorObject) [self setScaleFactor:[selectedFactorObject floatValue] adjustPopup:NO]; + else + [self setAutoFits:YES adjustPopup:NO]; } -- (BOOL)fits { - return fits; +- (BOOL)autoFits { + return autoFits; } -- (void)setFits:(BOOL)newFits { - [self setFits:newFits adjustPopup:YES]; +- (void)setAutoFits:(BOOL)newAuto { + [self setAutoFits:newAuto adjustPopup:YES]; } -- (void)setFits:(BOOL)newFits adjustPopup:(BOOL)flag { - if (fits != newFits) { - fits = newFits; - if (fits) { - [self setAutoScales:NO adjustPopup:NO]; - [self resetFitRectIfNeeded]; +- (void)setAutoFits:(BOOL)newAuto adjustPopup:(BOOL)flag { + if (autoFits != newAuto) { + autoFits = newAuto; + if (autoFits) { + [super setAutoScales:NO]; + [self resetAutoFitRectIfNeeded]; if (flag) [scalePopUpButton selectItemAtIndex:0]; } else { - page = nil; - fitRect = NSZeroRect; + autoFitPage = nil; + autoFitRect = NSZeroRect; + if (flag) + [self setScaleFactor:[self scaleFactor] adjustPopup:flag]; } } } @@ -224,12 +222,10 @@ - (void)setScaleFactor:(float)newScaleFactor adjustPopup:(BOOL)flag { if (flag) { - if (newScaleFactor < -0.01) { - newScaleFactor = -1.0; - } else if (newScaleFactor < 0.01) { + if (newScaleFactor < 0.01) { newScaleFactor = 0.0; } else { - unsigned cnt = 2, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + unsigned cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); // We only work with some preset zoom values, so choose one of the appropriate values while (cnt < numberOfDefaultItems - 1 && newScaleFactor > 0.5 * (BDSKDefaultScaleMenuFactors[cnt] + BDSKDefaultScaleMenuFactors[cnt + 1])) cnt++; @@ -238,38 +234,22 @@ } } - if(newScaleFactor < -0.01) - [self setFits:YES]; - if(newScaleFactor < 0.01) - [self setAutoScales:YES]; - else{ - [self setFits:NO adjustPopup:NO]; + if(newScaleFactor < 0.01){ + [self setAutoFits:YES]; + }else{ + [self setAutoFits:NO adjustPopup:NO]; [super setScaleFactor:newScaleFactor]; } } -- (void)setAutoScales:(BOOL)newAuto { - [self setAutoScales:newAuto adjustPopup:YES]; -} +- (void)setAutoScales:(BOOL)newAuto {} -- (void)setAutoScales:(BOOL)newAuto adjustPopup:(BOOL)flag { - if (newAuto) - [self setFits:NO adjustPopup:NO]; - - [super setAutoScales:newAuto]; - - if(newAuto && flag) - [scalePopUpButton selectItemAtIndex:1]; -} - - (IBAction)zoomIn:(id)sender{ - if([self fits]){ + if([self autoFits]){ [super zoomIn:sender]; - [self resetFitRectIfNeeded]; - }else if([self autoScales]){ - [super zoomIn:sender]; + [self setAutoFits:NO adjustPopup:YES]; }else{ - int cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + int cnt = 0, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); float scaleFactor = [self scaleFactor]; // We only work with some preset zoom values, so choose one of the appropriate values (Fudge a little for floating point == to work) @@ -281,19 +261,17 @@ } - (IBAction)zoomOut:(id)sender{ - if([self fits]){ + if([self autoFits]){ [super zoomOut:sender]; - [self resetFitRectIfNeeded]; - }else if([self autoScales]){ - [super zoomOut:sender]; + [self setAutoFits:NO adjustPopup:YES]; }else{ - int cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + int cnt = 0, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); float scaleFactor = [self scaleFactor]; // We only work with some preset zoom values, so choose one of the appropriate values (Fudge a little for floating point == to work) while (cnt < numberOfDefaultItems && scaleFactor * .99 > BDSKDefaultScaleMenuFactors[cnt]) cnt++; cnt--; - if (cnt < 1) cnt++; + if (cnt < 0) cnt++; [self setScaleFactor:BDSKDefaultScaleMenuFactors[cnt]]; } } @@ -301,9 +279,7 @@ - (BOOL)canZoomIn{ if ([super canZoomIn] == NO) return NO; - if([self autoScales]) - return YES; - unsigned cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + unsigned cnt = 0, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); float scaleFactor = [self scaleFactor]; // We only work with some preset zoom values, so choose one of the appropriate values (Fudge a little for floating point == to work) while (cnt < numberOfDefaultItems && scaleFactor * .99 > BDSKDefaultScaleMenuFactors[cnt]) cnt++; @@ -313,8 +289,6 @@ - (BOOL)canZoomOut{ if ([super canZoomOut] == NO) return NO; - if([self autoScales]) - return YES; unsigned cnt = 0, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); float scaleFactor = [self scaleFactor]; // We only work with some preset zoom values, so choose one of the appropriate values (Fudge a little for floating point == to work) @@ -324,14 +298,43 @@ - (void)goToPage:(PDFPage *)aPage { [super goToPage:aPage]; - [self resetFitRectIfNeeded]; + [self resetAutoFitRectIfNeeded]; } - (void)goToDestination:(PDFDestination *)destination { [super goToDestination:destination]; - [self resetFitRectIfNeeded]; + [self resetAutoFitRectIfNeeded]; } +- (void)doAutoFit:(id)sender { + [self setAutoFits:YES]; +} + +- (NSMenu *)menuForEvent:(NSEvent *)theEvent { + NSMenu *menu = [super menuForEvent:theEvent]; + int i, count = [menu numberOfItems]; + + for (i = 0; i < count; i++) { + NSMenuItem *item = [menu itemAtIndex:i]; + if ([item action] == NSSelectorFromString(@"_setAutoSize:")) { + [item setAction:@selector(doAutoFit:)]; + break; + } + } + + return menu; +} + +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem { + if ([menuItem action] == @selector(doAutoFit:)) { + [menuItem setState:[self autoFits] ? NSOnState : NSOffState]; + return YES; + } else if ([PDFView instancesRespondToSelector:_cmd]) { + return [super validateMenuItem:menuItem]; + } + return YES; +} + #pragma mark Scrollview - (NSScrollView *)scrollView; @@ -464,10 +467,10 @@ } // end of switch (event type) } // end of mouse-tracking loop - if ([self fits]) { + if ([self autoFits]) { NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; - page = [self currentPage]; - fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + autoFitPage = [self currentPage]; + autoFitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:autoFitPage]; } } Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2007-08-09 15:30:11 UTC (rev 2633) +++ trunk/SKMainWindowController.h 2007-08-09 18:31:27 UTC (rev 2634) @@ -264,7 +264,7 @@ - (IBAction)chooseTransition:(id)sender; - (IBAction)dismissTransitionSheet:(id)sender; -- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor fits:(BOOL)fits display:(BOOL)display; +- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor autoFits:(BOOL)autoFits display:(BOOL)display; - (void)toggleSnapshots:(NSArray *)snapshotArray; - (void)showNote:(PDFAnnotation *)annotation; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-08-09 15:30:11 UTC (rev 2633) +++ trunk/SKMainWindowController.m 2007-08-09 18:31:27 UTC (rev 2634) @@ -368,7 +368,7 @@ NSEnumerator *setupEnum = [[[SKBookmarkController sharedBookmarkController] snapshotsAtPath:[[[self document] fileURL] path]] objectEnumerator]; NSDictionary *setup; if (setup = [setupEnum nextObject]) - [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] fits:[[setup objectForKey:@"fits"] boolValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; + [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] autoFits:[[setup objectForKey:@"autoFits"] boolValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; } // This update toolbar item and other states @@ -781,7 +781,7 @@ NSEnumerator *setupEnum = [snapshotDicts objectEnumerator]; NSDictionary *setup; while (setup = [setupEnum nextObject]) - [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] fits:[[setup objectForKey:@"fits"] boolValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; + [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] autoFits:[[setup objectForKey:@"autoFits"] boolValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; if (pageIndex != NSNotFound && [document pageCount]) { PDFPage *page = [document pageAtIndex:MIN(pageIndex, [document pageCount] - 1)]; @@ -2485,7 +2485,7 @@ #pragma mark Sub- and note- windows -- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor fits:(BOOL)fits display:(BOOL)display{ +- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor autoFits:(BOOL)autoFits display:(BOOL)display{ SKSnapshotWindowController *swc = [[SKSnapshotWindowController alloc] init]; BOOL snapshotsOnTop = [[NSUserDefaults standardUserDefaults] boolForKey:SKSnapshotsOnTopKey]; @@ -2497,7 +2497,7 @@ scaleFactor:[pdfView scaleFactor] * factor goToPageNumber:pageNum rect:rect - fits:fits]; + autoFits:autoFits]; [swc setForceOnTop:[self isFullScreen] || [self isPresentation]]; [[swc window] setHidesOnDeactivate:snapshotsOnTop]; @@ -3369,7 +3369,7 @@ rect.origin.y = NSMidY(rect) - 100.0; rect.size.height = 200.0; - [self showSnapshotAtPageNumber:row forRect:rect factor:1 fits:NO display:YES]; + [self showSnapshotAtPageNumber:row forRect:rect factor:1 autoFits:NO display:YES]; return YES; } return NO; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-08-09 15:30:11 UTC (rev 2633) +++ trunk/SKPDFView.m 2007-08-09 18:31:27 UTC (rev 2634) @@ -1968,12 +1968,12 @@ NSPoint point; PDFPage *page = nil; NSRect rect = NSZeroRect; - BOOL fits = NO; + BOOL autoFits = NO; if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) { rect = NSIntersectionRect(selectionRect, [[self currentPage] boundsForBox:kPDFDisplayBoxCropBox]); page = [self currentPage]; - fits = YES; + autoFits = YES; } if (NSIsEmptyRect(rect)) { if ([sender respondsToSelector:@selector(representedObject)] && [[sender representedObject] respondsToSelector:@selector(pointValue)]) { @@ -2002,7 +2002,7 @@ SKMainWindowController *controller = [[self window] windowController]; - [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:rect factor:1 fits:fits display:YES]; + [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:rect factor:1 autoFits:autoFits display:YES]; } #pragma mark Notification handling @@ -3271,7 +3271,7 @@ PDFPage *page = [self pageForPoint:point nearest:YES]; NSRect rect = [self convertRect:selRect fromView:[self documentView]]; int factor = 1; - BOOL fits = NO; + BOOL autoFits = NO; if (dragged) { @@ -3297,7 +3297,7 @@ rect.origin.y = NSMaxY(bounds) - NSHeight(rect); } - fits = YES; + autoFits = YES; } else { @@ -3318,7 +3318,7 @@ SKMainWindowController *controller = [[self window] windowController]; - [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:[self convertRect:rect toPage:page] factor:factor fits:fits display:YES]; + [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:[self convertRect:rect toPage:page] factor:factor autoFits:autoFits display:YES]; } - (void)magnifyWithEvent:(NSEvent *)theEvent { Modified: trunk/SKSnapshotWindowController.h =================================================================== --- trunk/SKSnapshotWindowController.h 2007-08-09 15:30:11 UTC (rev 2633) +++ trunk/SKSnapshotWindowController.h 2007-08-09 18:31:27 UTC (rev 2634) @@ -49,7 +49,7 @@ BOOL forceOnTop; } -- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect fits:(BOOL)fits; +- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect autoFits:(BOOL)autoFits; - (BOOL)isPageVisible:(PDFPage *)page; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2007-08-09 15:30:11 UTC (rev 2633) +++ trunk/SKSnapshotWindowController.m 2007-08-09 18:31:27 UTC (rev 2634) @@ -186,7 +186,7 @@ [[self delegate] performSelector:@selector(snapshotControllerDidFinishSetup:) withObject:self afterDelay:0.1]; } -- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect fits:(BOOL)fits { +- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect autoFits:(BOOL)autoFits { [self window]; [pdfView setDocument:pdfDocument]; @@ -230,8 +230,8 @@ PDFDestination *dest = [[[PDFDestination alloc] initWithPage:page atPoint:point] autorelease]; - if (fits && [pdfView respondsToSelector:@selector(fits)]) - [(BDSKZoomablePDFView *)pdfView setFits:fits]; + if (autoFits && [pdfView respondsToSelector:@selector(setAutoFits:)]) + [(BDSKZoomablePDFView *)pdfView setAutoFits:autoFits]; // Delayed to allow PDFView to finish its bookkeeping // fixes bug of apparently ignoring the point but getting the page right. @@ -301,9 +301,8 @@ - (NSDictionary *)currentSetup { NSView *clipView = [[[pdfView documentView] enclosingScrollView] contentView]; NSRect rect = [pdfView convertRect:[pdfView convertRect:[clipView bounds] fromView:clipView] toPage:[pdfView currentPage]]; - float factor = [pdfView autoScales] ? 0.0 : [pdfView scaleFactor]; - BOOL fits = [pdfView respondsToSelector:@selector(fits)] && [(BDSKZoomablePDFView *)pdfView fits]; - return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:[self pageIndex]], @"page", NSStringFromRect(rect), @"rect", [NSNumber numberWithFloat:factor], @"scaleFactor", [NSNumber numberWithBool:fits], @"fits", [NSNumber numberWithBool:[[self window] isVisible]], @"hasWindow", nil]; + BOOL autoFits = [pdfView respondsToSelector:@selector(autoFits)] && [(BDSKZoomablePDFView *)pdfView autoFits]; + return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:[self pageIndex]], @"page", NSStringFromRect(rect), @"rect", [NSNumber numberWithFloat:[pdfView scaleFactor]], @"scaleFactor", [NSNumber numberWithBool:autoFits], @"autoFits", [NSNumber numberWithBool:[[self window] isVisible]], @"hasWindow", nil]; } #pragma mark Thumbnails This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-09 15:30:15
|
Revision: 2633 http://skim-app.svn.sourceforge.net/skim-app/?rev=2633&view=rev Author: hofman Date: 2007-08-09 08:30:11 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Automatically fit new snapshot that were created from an explicit selection. Keep autoscales/fits in reverted snapshots. Modified Paths: -------------- trunk/BDSKZoomablePDFView.h trunk/BDSKZoomablePDFView.m trunk/SKMainWindowController.h trunk/SKMainWindowController.m trunk/SKPDFView.m trunk/SKSnapshotWindowController.h trunk/SKSnapshotWindowController.m Modified: trunk/BDSKZoomablePDFView.h =================================================================== --- trunk/BDSKZoomablePDFView.h 2007-08-09 14:36:05 UTC (rev 2632) +++ trunk/BDSKZoomablePDFView.h 2007-08-09 15:30:11 UTC (rev 2633) @@ -58,5 +58,6 @@ - (void)setScrollerSize:(NSControlSize)controlSize; - (void)dragWithEvent:(NSEvent *)theEvent; - (void)handlePDFViewFrameChangedNotification:(NSNotification *)notification; +- (void)resetFitRectIfNeeded; @end Modified: trunk/BDSKZoomablePDFView.m =================================================================== --- trunk/BDSKZoomablePDFView.m 2007-08-09 14:36:05 UTC (rev 2632) +++ trunk/BDSKZoomablePDFView.m 2007-08-09 15:30:11 UTC (rev 2633) @@ -175,6 +175,14 @@ } } +- (void)resetFitRectIfNeeded { + if ([self fits]) { + NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; + page = [self currentPage]; + fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + } +} + - (void)scalePopUpAction:(id)sender { int index = [sender indexOfSelectedItem]; NSNumber *selectedFactorObject = [[sender selectedCell] representedObject]; @@ -198,10 +206,8 @@ if (fits != newFits) { fits = newFits; if (fits) { - NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; - page = [self currentPage]; - fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; [self setAutoScales:NO adjustPopup:NO]; + [self resetFitRectIfNeeded]; if (flag) [scalePopUpButton selectItemAtIndex:0]; } else { @@ -259,9 +265,7 @@ - (IBAction)zoomIn:(id)sender{ if([self fits]){ [super zoomIn:sender]; - NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; - page = [self currentPage]; - fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + [self resetFitRectIfNeeded]; }else if([self autoScales]){ [super zoomIn:sender]; }else{ @@ -279,9 +283,7 @@ - (IBAction)zoomOut:(id)sender{ if([self fits]){ [super zoomOut:sender]; - NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; - page = [self currentPage]; - fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + [self resetFitRectIfNeeded]; }else if([self autoScales]){ [super zoomOut:sender]; }else{ @@ -320,6 +322,16 @@ return cnt > 0; } +- (void)goToPage:(PDFPage *)aPage { + [super goToPage:aPage]; + [self resetFitRectIfNeeded]; +} + +- (void)goToDestination:(PDFDestination *)destination { + [super goToDestination:destination]; + [self resetFitRectIfNeeded]; +} + #pragma mark Scrollview - (NSScrollView *)scrollView; Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2007-08-09 14:36:05 UTC (rev 2632) +++ trunk/SKMainWindowController.h 2007-08-09 15:30:11 UTC (rev 2633) @@ -264,7 +264,7 @@ - (IBAction)chooseTransition:(id)sender; - (IBAction)dismissTransitionSheet:(id)sender; -- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor display:(BOOL)display; +- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor fits:(BOOL)fits display:(BOOL)display; - (void)toggleSnapshots:(NSArray *)snapshotArray; - (void)showNote:(PDFAnnotation *)annotation; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-08-09 14:36:05 UTC (rev 2632) +++ trunk/SKMainWindowController.m 2007-08-09 15:30:11 UTC (rev 2633) @@ -368,7 +368,7 @@ NSEnumerator *setupEnum = [[[SKBookmarkController sharedBookmarkController] snapshotsAtPath:[[[self document] fileURL] path]] objectEnumerator]; NSDictionary *setup; if (setup = [setupEnum nextObject]) - [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; + [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] fits:[[setup objectForKey:@"fits"] boolValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; } // This update toolbar item and other states @@ -781,7 +781,7 @@ NSEnumerator *setupEnum = [snapshotDicts objectEnumerator]; NSDictionary *setup; while (setup = [setupEnum nextObject]) - [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; + [self showSnapshotAtPageNumber:[[setup objectForKey:@"page"] unsignedIntValue] forRect:NSRectFromString([setup objectForKey:@"rect"]) factor:[[setup objectForKey:@"scaleFactor"] floatValue] fits:[[setup objectForKey:@"fits"] boolValue] display:[[setup objectForKey:@"hasWindow"] boolValue]]; if (pageIndex != NSNotFound && [document pageCount]) { PDFPage *page = [document pageAtIndex:MIN(pageIndex, [document pageCount] - 1)]; @@ -2485,7 +2485,7 @@ #pragma mark Sub- and note- windows -- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor display:(BOOL)display{ +- (void)showSnapshotAtPageNumber:(int)pageNum forRect:(NSRect)rect factor:(int)factor fits:(BOOL)fits display:(BOOL)display{ SKSnapshotWindowController *swc = [[SKSnapshotWindowController alloc] init]; BOOL snapshotsOnTop = [[NSUserDefaults standardUserDefaults] boolForKey:SKSnapshotsOnTopKey]; @@ -2496,7 +2496,8 @@ [swc setPdfDocument:doc scaleFactor:[pdfView scaleFactor] * factor goToPageNumber:pageNum - rect:rect]; + rect:rect + fits:fits]; [swc setForceOnTop:[self isFullScreen] || [self isPresentation]]; [[swc window] setHidesOnDeactivate:snapshotsOnTop]; @@ -3368,7 +3369,7 @@ rect.origin.y = NSMidY(rect) - 100.0; rect.size.height = 200.0; - [self showSnapshotAtPageNumber:row forRect:rect factor:1 display:YES]; + [self showSnapshotAtPageNumber:row forRect:rect factor:1 fits:NO display:YES]; return YES; } return NO; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-08-09 14:36:05 UTC (rev 2632) +++ trunk/SKPDFView.m 2007-08-09 15:30:11 UTC (rev 2633) @@ -1968,10 +1968,12 @@ NSPoint point; PDFPage *page = nil; NSRect rect = NSZeroRect; + BOOL fits = NO; if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) { rect = NSIntersectionRect(selectionRect, [[self currentPage] boundsForBox:kPDFDisplayBoxCropBox]); page = [self currentPage]; + fits = YES; } if (NSIsEmptyRect(rect)) { if ([sender respondsToSelector:@selector(representedObject)] && [[sender representedObject] respondsToSelector:@selector(pointValue)]) { @@ -2000,7 +2002,7 @@ SKMainWindowController *controller = [[self window] windowController]; - [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:rect factor:1 display:YES]; + [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:rect factor:1 fits:fits display:YES]; } #pragma mark Notification handling @@ -3269,6 +3271,7 @@ PDFPage *page = [self pageForPoint:point nearest:YES]; NSRect rect = [self convertRect:selRect fromView:[self documentView]]; int factor = 1; + BOOL fits = NO; if (dragged) { @@ -3287,13 +3290,15 @@ rect.origin.x = NSMaxX(bounds) - NSWidth(rect); } if (factor * NSHeight(rect) < 60.0) { - rect = NSInsetRect(rect, 0.5 * (NSHeight(rect) - 60.0 / factor), 0.0); + rect = NSInsetRect(rect, 0.0, 0.5 * (NSHeight(rect) - 60.0 / factor)); if (NSMinY(rect) < NSMinY(bounds)) rect.origin.y = NSMinY(bounds); if (NSMaxX(rect) > NSMaxY(bounds)) rect.origin.y = NSMaxY(bounds) - NSHeight(rect); } + fits = YES; + } else { BOOL isLink = NO; @@ -3313,7 +3318,7 @@ SKMainWindowController *controller = [[self window] windowController]; - [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:[self convertRect:rect toPage:page] factor:factor display:YES]; + [controller showSnapshotAtPageNumber:[[self document] indexForPage:page] forRect:[self convertRect:rect toPage:page] factor:factor fits:fits display:YES]; } - (void)magnifyWithEvent:(NSEvent *)theEvent { Modified: trunk/SKSnapshotWindowController.h =================================================================== --- trunk/SKSnapshotWindowController.h 2007-08-09 14:36:05 UTC (rev 2632) +++ trunk/SKSnapshotWindowController.h 2007-08-09 15:30:11 UTC (rev 2633) @@ -49,7 +49,7 @@ BOOL forceOnTop; } -- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect; +- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect fits:(BOOL)fits; - (BOOL)isPageVisible:(PDFPage *)page; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2007-08-09 14:36:05 UTC (rev 2632) +++ trunk/SKSnapshotWindowController.m 2007-08-09 15:30:11 UTC (rev 2633) @@ -41,6 +41,7 @@ #import "SKDocument.h" #import "SKMiniaturizeWindow.h" #import <Quartz/Quartz.h> +#import "BDSKZoomablePDFView.h" #import "SKPDFAnnotationNote.h" #import "SKPDFView.h" #import "NSWindowController_SKExtensions.h" @@ -185,7 +186,7 @@ [[self delegate] performSelector:@selector(snapshotControllerDidFinishSetup:) withObject:self afterDelay:0.1]; } -- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect{ +- (void)setPdfDocument:(PDFDocument *)pdfDocument scaleFactor:(float)factor goToPageNumber:(int)pageNum rect:(NSRect)rect fits:(BOOL)fits { [self window]; [pdfView setDocument:pdfDocument]; @@ -229,6 +230,9 @@ PDFDestination *dest = [[[PDFDestination alloc] initWithPage:page atPoint:point] autorelease]; + if (fits && [pdfView respondsToSelector:@selector(fits)]) + [(BDSKZoomablePDFView *)pdfView setFits:fits]; + // Delayed to allow PDFView to finish its bookkeeping // fixes bug of apparently ignoring the point but getting the page right. [self performSelector:@selector(goToDestination:) withObject:dest afterDelay:0.1]; @@ -297,7 +301,9 @@ - (NSDictionary *)currentSetup { NSView *clipView = [[[pdfView documentView] enclosingScrollView] contentView]; NSRect rect = [pdfView convertRect:[pdfView convertRect:[clipView bounds] fromView:clipView] toPage:[pdfView currentPage]]; - return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:[self pageIndex]], @"page", NSStringFromRect(rect), @"rect", [NSNumber numberWithFloat:[pdfView scaleFactor]], @"scaleFactor", [NSNumber numberWithBool:[[self window] isVisible]], @"hasWindow", nil]; + float factor = [pdfView autoScales] ? 0.0 : [pdfView scaleFactor]; + BOOL fits = [pdfView respondsToSelector:@selector(fits)] && [(BDSKZoomablePDFView *)pdfView fits]; + return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:[self pageIndex]], @"page", NSStringFromRect(rect), @"rect", [NSNumber numberWithFloat:factor], @"scaleFactor", [NSNumber numberWithBool:fits], @"fits", [NSNumber numberWithBool:[[self window] isVisible]], @"hasWindow", nil]; } #pragma mark Thumbnails This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-08-09 14:36:13
|
Revision: 2632 http://skim-app.svn.sourceforge.net/skim-app/?rev=2632&view=rev Author: hofman Date: 2007-08-09 07:36:05 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Add a zoom option to the popup to automatically adjust the scale factor to fit the currently displayed rect. Modified Paths: -------------- trunk/BDSKZoomablePDFView.h trunk/BDSKZoomablePDFView.m Modified: trunk/BDSKZoomablePDFView.h =================================================================== --- trunk/BDSKZoomablePDFView.h 2007-08-09 11:40:55 UTC (rev 2631) +++ trunk/BDSKZoomablePDFView.h 2007-08-09 14:36:05 UTC (rev 2632) @@ -42,13 +42,21 @@ @interface BDSKZoomablePDFView : PDFView { NSPopUpButton *scalePopUpButton; + PDFPage *page; + NSRect fitRect; + BOOL fits; } +- (BOOL)fits; +- (void)setFits:(BOOL)newFits; +- (void)setFits:(BOOL)newFits adjustPopup:(BOOL)flag; +- (void)setAutoScales:(BOOL)newAuto adjustPopup:(BOOL)flag; - (void)setScaleFactor:(float)factor adjustPopup:(BOOL)flag; - (void)scalePopUpAction:(id)sender; - (NSScrollView *)scrollView; - (void)layoutScrollView; - (void)setScrollerSize:(NSControlSize)controlSize; - (void)dragWithEvent:(NSEvent *)theEvent; +- (void)handlePDFViewFrameChangedNotification:(NSNotification *)notification; @end Modified: trunk/BDSKZoomablePDFView.m =================================================================== --- trunk/BDSKZoomablePDFView.m 2007-08-09 11:40:55 UTC (rev 2631) +++ trunk/BDSKZoomablePDFView.m 2007-08-09 14:36:05 UTC (rev 2632) @@ -48,6 +48,7 @@ @implementation BDSKZoomablePDFView /* For genstrings: + NSLocalizedStringFromTable(@"Fit", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"Auto", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"10%", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"25%", @"ZoomValues", @"Zoom popup entry") @@ -59,12 +60,43 @@ NSLocalizedStringFromTable(@"400%", @"ZoomValues", @"Zoom popup entry") NSLocalizedStringFromTable(@"800%", @"ZoomValues", @"Zoom popup entry") */ -static NSString *BDSKDefaultScaleMenuLabels[] = {/* @"Set...", */ @"Auto", @"10%", @"25%", @"50%", @"75%", @"100%", @"128%", @"150%", @"200%", @"400%", @"800%"}; -static float BDSKDefaultScaleMenuFactors[] = {/* 0.0, */ 0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.28, 1.5, 2.0, 4.0, 8.0}; +static NSString *BDSKDefaultScaleMenuLabels[] = {/* @"Set...", */ @"Fit", @"Auto", @"10%", @"25%", @"50%", @"75%", @"100%", @"128%", @"150%", @"200%", @"400%", @"800%"}; +static float BDSKDefaultScaleMenuFactors[] = {/* 0.0, */ -1, 0, 0.1, 0.25, 0.5, 0.75, 1.0, 1.28, 1.5, 2.0, 4.0, 8.0}; static float BDSKScaleMenuFontSize = 11.0; #pragma mark Popup button +- (id)initWithFrame:(NSRect)frameRect { + if (self = [super initWithFrame:frameRect]) { + scalePopUpButton = nil; + page = nil; + fitRect = NSZeroRect; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) + name:NSViewFrameDidChangeNotification object:self]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) + name:NSViewBoundsDidChangeNotification object:self]; + } + return self; +} + +- (id)initWithCoder:(NSCoder *)decoder { + if (self = [super initWithCoder:decoder]) { + scalePopUpButton = nil; + page = nil; + fitRect = NSZeroRect; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) + name:NSViewFrameDidChangeNotification object:self]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePDFViewFrameChangedNotification:) + name:NSViewBoundsDidChangeNotification object:self]; + } + return self; +} + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; + [super dealloc]; +} + - (void)makeScalePopUpButton { if (scalePopUpButton == nil) { @@ -130,14 +162,55 @@ } } +- (void)handlePDFViewFrameChangedNotification:(NSNotification *)notification { + if (fits) { + NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; + NSRect rect = [self convertRect:[clipView visibleRect] fromView:clipView]; + BOOL scaleWidth = NSWidth(rect) / NSHeight(rect) < NSWidth(fitRect) / NSHeight(fitRect); + float factor = scaleWidth ? NSWidth(rect) / NSWidth(fitRect) : NSHeight(rect) / NSHeight(fitRect); + NSRect viewRect = scaleWidth ? NSInsetRect(fitRect, 0.0, 0.5 * (NSHeight(fitRect) - NSHeight(rect) / factor)) : NSInsetRect(fitRect, 0.5 * (NSWidth(fitRect) - NSWidth(rect) / factor), 0.0); + [super setScaleFactor:factor]; + viewRect = [self convertRect:[self convertRect:viewRect fromPage:page] toView:[self documentView]]; + [[self documentView] scrollRectToVisible:viewRect]; + } +} + - (void)scalePopUpAction:(id)sender { + int index = [sender indexOfSelectedItem]; NSNumber *selectedFactorObject = [[sender selectedCell] representedObject]; - if(!selectedFactorObject) - [super setAutoScales:YES]; - else + if(index == 0) + [self setFits:YES adjustPopup:NO]; + else if(index == 1) + [self setAutoScales:YES adjustPopup:NO]; + else if(selectedFactorObject) [self setScaleFactor:[selectedFactorObject floatValue] adjustPopup:NO]; } +- (BOOL)fits { + return fits; +} + +- (void)setFits:(BOOL)newFits { + [self setFits:newFits adjustPopup:YES]; +} + +- (void)setFits:(BOOL)newFits adjustPopup:(BOOL)flag { + if (fits != newFits) { + fits = newFits; + if (fits) { + NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; + page = [self currentPage]; + fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + [self setAutoScales:NO adjustPopup:NO]; + if (flag) + [scalePopUpButton selectItemAtIndex:0]; + } else { + page = nil; + fitRect = NSZeroRect; + } + } +} + - (void)setScaleFactor:(float)newScaleFactor { [self setScaleFactor:newScaleFactor adjustPopup:YES]; } @@ -145,10 +218,12 @@ - (void)setScaleFactor:(float)newScaleFactor adjustPopup:(BOOL)flag { if (flag) { - if (newScaleFactor < 0.01) { + if (newScaleFactor < -0.01) { + newScaleFactor = -1.0; + } else if (newScaleFactor < 0.01) { newScaleFactor = 0.0; } else { - unsigned cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + unsigned cnt = 2, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); // We only work with some preset zoom values, so choose one of the appropriate values while (cnt < numberOfDefaultItems - 1 && newScaleFactor > 0.5 * (BDSKDefaultScaleMenuFactors[cnt] + BDSKDefaultScaleMenuFactors[cnt + 1])) cnt++; @@ -157,24 +232,40 @@ } } + if(newScaleFactor < -0.01) + [self setFits:YES]; if(newScaleFactor < 0.01) [self setAutoScales:YES]; - else + else{ + [self setFits:NO adjustPopup:NO]; [super setScaleFactor:newScaleFactor]; + } } - (void)setAutoScales:(BOOL)newAuto { + [self setAutoScales:newAuto adjustPopup:YES]; +} + +- (void)setAutoScales:(BOOL)newAuto adjustPopup:(BOOL)flag { + if (newAuto) + [self setFits:NO adjustPopup:NO]; + [super setAutoScales:newAuto]; - if(newAuto) - [scalePopUpButton selectItemAtIndex:0]; + if(newAuto && flag) + [scalePopUpButton selectItemAtIndex:1]; } - (IBAction)zoomIn:(id)sender{ - if([self autoScales]){ + if([self fits]){ [super zoomIn:sender]; + NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; + page = [self currentPage]; + fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + }else if([self autoScales]){ + [super zoomIn:sender]; }else{ - int cnt = 0, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + int cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); float scaleFactor = [self scaleFactor]; // We only work with some preset zoom values, so choose one of the appropriate values (Fudge a little for floating point == to work) @@ -186,16 +277,21 @@ } - (IBAction)zoomOut:(id)sender{ - if([self autoScales]){ + if([self fits]){ [super zoomOut:sender]; + NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; + page = [self currentPage]; + fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + }else if([self autoScales]){ + [super zoomOut:sender]; }else{ - int cnt = 0, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + int cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); float scaleFactor = [self scaleFactor]; // We only work with some preset zoom values, so choose one of the appropriate values (Fudge a little for floating point == to work) while (cnt < numberOfDefaultItems && scaleFactor * .99 > BDSKDefaultScaleMenuFactors[cnt]) cnt++; cnt--; - if (cnt < 0) cnt++; + if (cnt < 1) cnt++; [self setScaleFactor:BDSKDefaultScaleMenuFactors[cnt]]; } } @@ -205,7 +301,7 @@ return NO; if([self autoScales]) return YES; - unsigned cnt = 0, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); + unsigned cnt = 1, numberOfDefaultItems = (sizeof(BDSKDefaultScaleMenuFactors) / sizeof(float)); float scaleFactor = [self scaleFactor]; // We only work with some preset zoom values, so choose one of the appropriate values (Fudge a little for floating point == to work) while (cnt < numberOfDefaultItems && scaleFactor * .99 > BDSKDefaultScaleMenuFactors[cnt]) cnt++; @@ -355,6 +451,12 @@ break; } // end of switch (event type) } // end of mouse-tracking loop + + if ([self fits]) { + NSView *clipView = [[[self documentView] enclosingScrollView] contentView]; + page = [self currentPage]; + fitRect = [self convertRect:[self convertRect:[clipView visibleRect] fromView:clipView] toPage:page]; + } } @end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |