Revision: 5691
http://skim-app.svn.sourceforge.net/skim-app/?rev=5691&view=rev
Author: hofman
Date: 2009-09-06 00:24:12 +0000 (Sun, 06 Sep 2009)
Log Message:
-----------
replace use of more deprecated methods, such as file manager methods and
fileName
Modified Paths:
--------------
trunk/SKDownload.m
trunk/SKFontWell.m
trunk/SKInfoWindowController.m
trunk/SKMainDocument.h
trunk/SKMainDocument.m
trunk/SKNotesDocument.m
trunk/SKSnapshotWindowController.m
trunk/SKTableView.m
trunk/SKTocOutlineView.m
trunk/SkimImporter/GetMetadataForFile.m
Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKDownload.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -39,7 +39,6 @@
#import "SKDownload.h"
#import <ApplicationServices/ApplicationServices.h>
#import "NSFileManager_SKExtensions.h"
-#import "SKRuntime.h"
NSString *SKDownloadFileNameKey = @"fileName";
NSString *SKDownloadStatusKey = @"status";
@@ -56,22 +55,34 @@
@implementation SKDownload
-+ (NSArray *)infoKeys {
- return [NSArray arrayWithObjects:SKDownloadFileNameKey,
SKDownloadStatusKey, SKDownloadProgressIndicatorKey, nil];
++ (NSSet *)infoKeys {
+ return [NSSet setWithObjects:SKDownloadFileNameKey, SKDownloadStatusKey,
SKDownloadProgressIndicatorKey, nil];
}
-+ (void)initialize {
- NSArray *keys = [NSArray arrayWithObjects:@"filePath", nil];
- [self setKeys:keys triggerChangeNotificationsForDependentKey:@"fileName"];
- [self setKeys:keys triggerChangeNotificationsForDependentKey:@"fileIcon"];
- keys = [NSArray arrayWithObjects:SKDownloadStatusKey, nil];
- [self setKeys:keys triggerChangeNotificationsForDependentKey:@"canCancel"];
- [self setKeys:keys triggerChangeNotificationsForDependentKey:@"canRemove"];
- [self setKeys:keys triggerChangeNotificationsForDependentKey:@"canResume"];
- [self setKeys:[self infoKeys]
triggerChangeNotificationsForDependentKey:@"info"];
- SKINITIALIZE;
++ (NSSet *)keyPathsForValuesAffectingFileName {
+ return [NSSet setWithObjects:@"filePath", nil];
}
++ (NSSet *)keyPathsForValuesAffectingFileIcon {
+ return [NSSet setWithObjects:@"filePath", nil];
+}
+
++ (NSSet *)keyPathsForValuesAffectingCanCancel {
+ return [NSSet setWithObjects:@"filePath", nil];
+}
+
++ (NSSet *)keyPathsForValuesAffectingCanRemove {
+ return [NSSet setWithObjects:@"filePath", nil];
+}
+
++ (NSSet *)keyPathsForValuesAffectingCanResume {
+ return [NSSet setWithObjects:@"filePath", nil];
+}
+
++ (NSSet *)keyPathsForValuesAffectingInfo {
+ return [self infoKeys];
+}
+
- (id)initWithURL:(NSURL *)aURL delegate:(id)aDelegate {
if (self = [super init]) {
URL = [aURL retain];
Modified: trunk/SKFontWell.m
===================================================================
--- trunk/SKFontWell.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKFontWell.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -71,12 +71,17 @@
[self exposeBinding:FONTSIZE_KEY];
[self exposeBinding:TEXTCOLOR_KEY];
- [self setKeys:[NSArray arrayWithObjects:FONT_KEY, nil]
triggerChangeNotificationsForDependentKey:FONTNAME_KEY];
- [self setKeys:[NSArray arrayWithObjects:FONT_KEY, nil]
triggerChangeNotificationsForDependentKey:FONTSIZE_KEY];
-
SKINITIALIZE;
}
++ (NSSet *)keyPathsForValuesAffectingFontName {
+ return [NSSet setWithObjects:FONT_KEY, nil];
+}
+
++ (NSSet *)keyPathsForValuesAffectingFontSize {
+ return [NSSet setWithObjects:FONT_KEY, nil];
+}
+
+ (Class)cellClass {
return [SKFontWellCell class];
}
Modified: trunk/SKInfoWindowController.m
===================================================================
--- trunk/SKInfoWindowController.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKInfoWindowController.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -215,7 +215,7 @@
[dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsPrinting]]
forKey:SKInfoAllowsPrintingKey];
[dictionary setValue:[NSNumber numberWithBool:[pdfDoc allowsCopying]]
forKey:SKInfoAllowsCopyingKey];
}
- [dictionary setValue:[[doc fileName] lastPathComponent]
forKey:SKInfoFileNameKey];
+ [dictionary setValue:[[[doc fileURL] path] lastPathComponent]
forKey:SKInfoFileNameKey];
[dictionary setValue:SKFileSizeStringForFileURL([doc fileURL],
&physicalSize, &logicalSize) forKey:SKInfoFileSizeKey];
[dictionary setValue:[NSNumber numberWithUnsignedLongLong:physicalSize]
forKey:SKInfoPhysicalSizeKey];
[dictionary setValue:[NSNumber numberWithUnsignedLongLong:logicalSize]
forKey:SKInfoLogicalSizeKey];
Modified: trunk/SKMainDocument.h
===================================================================
--- trunk/SKMainDocument.h 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKMainDocument.h 2009-09-06 00:24:12 UTC (rev 5691)
@@ -66,8 +66,6 @@
SKMainWindowController *mainWindowController;
- NSButton *autoRotateButton;
-
// variables to be saved:
NSData *pdfData;
NSData *psOrDviData;
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKMainDocument.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -151,7 +151,6 @@
[readNotesAccessoryView release];
[lastModifiedDate release];
[progressController release];
- [autoRotateButton release];
[tmpData release];
[super dealloc];
}
@@ -415,7 +414,7 @@
// we move everything that's not ours out of the way, so we can
preserve version control info
if ([fm fileExistsAtPath:path isDirectory:&isDir] && isDir) {
NSSet *ourExtensions = [NSSet setWithObjects:@"pdf", @"skim",
@"fdf", @"txt", @"text", @"rtf", @"plist", nil];
- fileEnum = [[fm directoryContentsAtPath:path] objectEnumerator];
+ fileEnum = [[fm contentsOfDirectoryAtPath:path error:NULL]
objectEnumerator];
while (file = [fileEnum nextObject]) {
if ([ourExtensions containsObject:[[file pathExtension]
lowercaseString]] == NO) {
if (tmpPath == nil)
@@ -428,7 +427,7 @@
success = [super saveToURL:absoluteURL ofType:typeName
forSaveOperation:saveOperation error:&error];
if (tmpPath) {
- fileEnum = [[fm directoryContentsAtPath:tmpPath] objectEnumerator];
+ fileEnum = [[fm contentsOfDirectoryAtPath:tmpPath error:NULL]
objectEnumerator];
while (file = [fileEnum nextObject])
[fm moveItemAtPath:[tmpPath
stringByAppendingPathComponent:file] toPath:[path
stringByAppendingPathComponent:file] error:NULL];
[fm removeItemAtPath:tmpPath error:NULL];
@@ -450,7 +449,7 @@
[self updateChangeCount:NSChangeCleared];
docFlags.fileChangedOnDisk = NO;
[lastModifiedDate release];
- lastModifiedDate = [[[[NSFileManager defaultManager]
attributesOfItemAtPath:[self fileName] error:NULL] fileModificationDate]
retain];
+ lastModifiedDate = [[[[NSFileManager defaultManager]
attributesOfItemAtPath:[[self fileURL] path] error:NULL] fileModificationDate]
retain];
}
[self checkFileUpdatesIfNeeded];
docFlags.isSaving = NO;
@@ -1203,11 +1202,11 @@
}
- (void)revertDocumentToSaved:(id)sender {
- if ([self fileName]) {
+ if ([self fileURL]) {
if ([self isDocumentEdited]) {
[super revertDocumentToSaved:sender];
} else if (docFlags.fileChangedOnDisk) {
- NSAlert *alert = [NSAlert alertWithMessageText:[NSString
stringWithFormat:NSLocalizedString(@"Do you want to revert to the version of
the document \"%...@\" on disk?", @"Message in alert dialog"), [[self fileName]
lastPathComponent]]
+ NSAlert *alert = [NSAlert alertWithMessageText:[NSString
stringWithFormat:NSLocalizedString(@"Do you want to revert to the version of
the document \"%...@\" on disk?", @"Message in alert dialog"), [[[self fileURL]
path] lastPathComponent]]
defaultButton:NSLocalizedString(@"Revert", @"Button title")
alternateButton:NSLocalizedString(@"Cancel", @"Button title")
otherButton:nil
@@ -1228,7 +1227,7 @@
if ([anItem action] == @selector(performFindPanelAction:)) {
return [[SKFindController sharedFindController]
validateUserInterfaceItem:anItem];
} else if ([anItem action] == @selector(revertDocumentToSaved:)) {
- NSString *fileName = [self fileName];
+ NSString *fileName = [[self fileURL] path];
if (fileName == nil || [[NSFileManager defaultManager]
fileExistsAtPath:fileName] == NO)
return NO;
return [self isDocumentEdited] || docFlags.fileChangedOnDisk;
@@ -1289,7 +1288,7 @@
}
- (void)checkForFileModification:(NSTimer *)timer {
- NSDate *currentFileModifiedDate = [[[NSFileManager defaultManager]
attributesOfItemAtPath:[self fileName] error:NULL] fileModificationDate];
+ NSDate *currentFileModifiedDate = [[[NSFileManager defaultManager]
attributesOfItemAtPath:[[self fileURL] path] error:NULL] fileModificationDate];
if (nil == lastModifiedDate) {
lastModifiedDate = [currentFileModifiedDate copy];
} else if ([lastModifiedDate compare:currentFileModifiedDate] ==
NSOrderedAscending) {
@@ -1302,13 +1301,13 @@
}
- (void)checkFileUpdatesIfNeeded {
- if ([self fileName]) {
+ if ([self fileURL]) {
[self stopCheckingFileUpdates];
if ([[NSUserDefaults standardUserDefaults]
boolForKey:SKAutoCheckFileUpdateKey]) {
// AFP, NFS, SMB etc. don't support kqueues, so we have to
manually poll and compare mod dates
- if (isFileOnHFSVolume([self fileName])) {
- watchedFile = [[self fileName] retain];
+ if (isFileOnHFSVolume([[self fileURL] path])) {
+ watchedFile = [[[self fileURL] path] retain];
UKKQueue *kQueue = [UKKQueue sharedFileWatcher];
[kQueue addPath:watchedFile];
@@ -1380,7 +1379,7 @@
}
- (void)fileUpdated {
- NSString *fileName = [self fileName];
+ NSString *fileName = [[self fileURL] path];
// should never happen
if (docFlags.isUpdatingFile)
@@ -1435,7 +1434,7 @@
if ([watchedFile isEqualToString:path] || notification == nil) {
// should never happen
- if (notification && [path isEqualToString:[self fileName]] == NO)
+ if (notification && [path isEqualToString:[[self fileURL] path]] == NO)
NSLog(@"*** received change notice for %@", path);
if (docFlags.isUpdatingFile)
@@ -1493,7 +1492,7 @@
- (void)setFileURL:(NSURL *)absoluteURL {
// this shouldn't be necessary, but better be sure
- if ([self fileName] && [[self fileURL] isEqual:absoluteURL] == NO)
+ if ([self fileURL] && [[self fileURL] isEqual:absoluteURL] == NO)
[self stopCheckingFileUpdates];
[super setFileURL:absoluteURL];
if ([absoluteURL isFileURL])
@@ -1509,7 +1508,7 @@
if (synchronizer == nil) {
synchronizer = [[SKPDFSynchronizer alloc] init];
[synchronizer setDelegate:self];
- [synchronizer setFileName:[self fileName]];
+ [synchronizer setFileName:[[self fileURL] path]];
}
return synchronizer;
}
@@ -1625,7 +1624,7 @@
- (NSDictionary *)currentDocumentSetup {
NSMutableDictionary *setup = [NSMutableDictionary dictionary];
- NSString *fileName = [self fileName];
+ NSString *fileName = [[self fileURL] path];
if (fileName) {
NSData *data = [[BDAlias aliasWithPath:fileName] aliasData];
@@ -1729,32 +1728,11 @@
}
- (void)setPrintInfo:(NSPrintInfo *)printInfo {
- if (autoRotateButton) {
- BOOL autoRotate = [autoRotateButton state] == NSOnState;
- if (autoRotate != [[printInfo
valueForKeyPath:@"dictionary.PDFPrintAutoRotate"] boolValue]) {
- [printInfo setValue:[NSNumber numberWithBool:autoRotate]
forKeyPath:@"dictionary.PDFPrintAutoRotate"];
- [[NSUserDefaults standardUserDefaults] setBool:autoRotate
forKey:SKAutoRotatePrintedPagesKey];
- }
- }
[[self undoManager] disableUndoRegistration];
[super setPrintInfo:printInfo];
[[self undoManager] enableUndoRegistration];
}
-- (BOOL)preparePageLayout:(NSPageLayout *)pageLayout {
- if (autoRotateButton == nil) {
- autoRotateButton = [[NSButton alloc] init];
- [autoRotateButton setBezelStyle:NSRoundedBezelStyle];
- [autoRotateButton setButtonType:NSSwitchButton];
- [autoRotateButton setTitle:NSLocalizedString(@"Auto Rotate Pages",
@"Print layout sheet button title")];
- [autoRotateButton sizeToFit];
- }
- BOOL autoRotate = [[[self printInfo]
valueForKeyPath:@"dictionary.PDFPrintAutoRotate"] boolValue];
- [autoRotateButton setState:autoRotate ? NSOnState : NSOffState];
- [pageLayout setAccessoryView:autoRotateButton];
- return YES;
-}
-
- (NSArray *)snapshots {
return [[self mainWindowController] snapshots];
}
@@ -1797,7 +1775,7 @@
}
if (saveOption == NSAlertDefaultReturn) {
const char *userName = [NSUserName() UTF8String];
- const char *comment = [[self fileName] UTF8String];
+ const char *comment = [[[self fileURL] path] UTF8String];
OSStatus err;
SecKeychainItemRef itemRef = NULL;
@@ -2078,7 +2056,7 @@
}
- (void)handleRevertScriptCommand:(NSScriptCommand *)command {
- if ([self fileURL] && [[NSFileManager defaultManager]
fileExistsAtPath:[self fileName]]) {
+ if ([self fileURL] && [[NSFileManager defaultManager]
fileExistsAtPath:[[self fileURL] path]]) {
if (docFlags.isUpdatingFile == NO && [self revertToContentsOfURL:[self
fileURL] ofType:[self fileType] error:NULL] == NO) {
[command setScriptErrorNumber:NSInternalScriptError];
[command setScriptErrorString:@"Revert failed."];
Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKNotesDocument.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -258,7 +258,7 @@
// these are necessary for the app controller, we may change it there
- (NSDictionary *)currentDocumentSetup {
NSMutableDictionary *setup = [NSMutableDictionary dictionary];
- NSString *fileName = [self fileName];
+ NSString *fileName = [[self fileURL] path];
if (fileName) {
NSData *data = [[BDAlias aliasWithPath:fileName] aliasData];
@@ -301,7 +301,7 @@
#pragma mark Actions
- (IBAction)openPDF:(id)sender {
- NSString *path = [[self fileName] stringByReplacingPathExtension:@"pdf"];
+ NSString *path = [[[self fileURL] path]
stringByReplacingPathExtension:@"pdf"];
NSError *error = nil;
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
// resolve symlinks and aliases
@@ -678,7 +678,7 @@
if ([[[[[self windowControllers] objectAtIndex:0] window] toolbar]
customizationPaletteIsRunning])
return NO;
else if ([[toolbarItem itemIdentifier]
isEqualToString:SKNotesDocumentOpenPDFToolbarItemIdentifier])
- return [[NSFileManager defaultManager] fileExistsAtPath:[[self
fileName] stringByReplacingPathExtension:@"pdf"]];
+ return [[NSFileManager defaultManager] fileExistsAtPath:[[[self
fileURL] path] stringByReplacingPathExtension:@"pdf"]];
return YES;
}
Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKSnapshotWindowController.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -50,7 +50,6 @@
#import "NSGeometry_SKExtensions.h"
#import "PDFPage_SKExtensions.h"
#import "SKSnapshotPageCell.h"
-#import "SKRuntime.h"
#import "PDFAnnotation_SKExtensions.h"
#define EM_DASH_CHARACTER 0x2014
@@ -78,9 +77,8 @@
@implementation SKSnapshotWindowController
-+ (void)initialize {
- [self setKeys:[NSArray arrayWithObjects:PAGELABEL_KEY, HASWINDOW_KEY, nil]
triggerChangeNotificationsForDependentKey:PAGEANDWINDOW_KEY];
- SKINITIALIZE;
++ (NSSet *)keyPathsForValuesAffectingPageAndWindow {
+ return [NSSet setWithObjects:PAGELABEL_KEY, HASWINDOW_KEY, nil];
}
- (void)dealloc {
Modified: trunk/SKTableView.m
===================================================================
--- trunk/SKTableView.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKTableView.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -265,13 +265,13 @@
if ([self window]) {
NSRange rowRange = [self rowsInRect:[self visibleRect]];
- NSRange columnRange = [self columnsInRect:[self visibleRect]];
- NSUInteger row, column;
+ NSIndexSet *columnIndexes = [self columnIndexesInRect:[self
visibleRect]];
+ NSUInteger row, column = [columnIndexes firstIndex];
NSTableColumn *tableColumn;
NSInteger userData;
NSTrackingRectTag tag;
- for (column = columnRange.location; column < NSMaxRange(columnRange);
column++) {
+ while (column != NSNotFound) {
tableColumn = [[self tableColumns] objectAtIndex:column];
for (row = rowRange.location; row < NSMaxRange(rowRange); row++) {
if ([[self delegate] tableView:self
shouldTrackTableColumn:tableColumn row:row]) {
@@ -280,6 +280,7 @@
CFArrayAppendValue(trackingRects, (const void *)tag);
}
}
+ column = [columnIndexes indexGreaterThanIndex:column];
}
}
}
Modified: trunk/SKTocOutlineView.m
===================================================================
--- trunk/SKTocOutlineView.m 2009-09-06 00:23:32 UTC (rev 5690)
+++ trunk/SKTocOutlineView.m 2009-09-06 00:24:12 UTC (rev 5691)
@@ -125,13 +125,13 @@
if ([self window]) {
NSRange rowRange = [self rowsInRect:[self visibleRect]];
- NSRange columnRange = [self columnsInRect:[self visibleRect]];
- NSUInteger row, column;
+ NSIndexSet *columnIndexes = [self columnIndexesInRect:[self
visibleRect]];
+ NSUInteger row, column = [columnIndexes firstIndex];
NSTableColumn *tableColumn;
NSInteger userData;
NSTrackingRectTag tag;
- for (column = columnRange.location; column < NSMaxRange(columnRange);
column++) {
+ while (column != NSNotFound) {
tableColumn = [[self tableColumns] objectAtIndex:column];
for (row = rowRange.location; row < NSMaxRange(rowRange); row++) {
if ([[self delegate] outlineView:self
shouldTrackTableColumn:tableColumn item:[self itemAtRow:row]]) {
@@ -140,6 +140,7 @@
CFArrayAppendValue(trackingRects, (const void *)tag);
}
}
+ column = [columnIndexes indexGreaterThanIndex:column];
}
}
}
Modified: trunk/SkimImporter/GetMetadataForFile.m
===================================================================
--- trunk/SkimImporter/GetMetadataForFile.m 2009-09-06 00:23:32 UTC (rev
5690)
+++ trunk/SkimImporter/GetMetadataForFile.m 2009-09-06 00:24:12 UTC (rev
5691)
@@ -165,7 +165,7 @@
if (sourcePath && [[NSFileManager defaultManager]
fileExistsAtPath:sourcePath])
CFDictionarySetValue(attributes, kMDItemWhereFroms, [NSArray
arrayWithObjects:sourcePath, nil]);
- NSDictionary *fileAttributes = [[NSFileManager defaultManager]
fileAttributesAtPath:(NSString *)pathToFile traverseLink:YES];
+ NSDictionary *fileAttributes = [[NSFileManager defaultManager]
attributesOfItemAtPath:(NSString *)pathToFile error:NULL];
NSDate *date;
if (date = [fileAttributes objectForKey:NSFileModificationDate])
CFDictionarySetValue(attributes, kMDItemContentModificationDate,
date);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit