Revision: 7766
http://skim-app.svn.sourceforge.net/skim-app/?rev=7766&view=rev
Author: hofman
Date: 2012-11-01 21:53:24 +0000 (Thu, 01 Nov 2012)
Log Message:
-----------
Replace more path based code by URL based code
Modified Paths:
--------------
trunk/SKBookmark.h
trunk/SKBookmark.m
trunk/SKBookmarkController.m
trunk/SKScriptMenu.m
trunk/Skim.sdef
Modified: trunk/SKBookmark.h
===================================================================
--- trunk/SKBookmark.h 2012-11-01 17:39:12 UTC (rev 7765)
+++ trunk/SKBookmark.h 2012-11-01 21:53:24 UTC (rev 7766)
@@ -71,7 +71,7 @@
@property (nonatomic, readonly) SKBookmarkType bookmarkType;
@property (nonatomic, retain) NSString *label;
@property (nonatomic, readonly) NSImage *icon, *alternateIcon;
-@property (nonatomic, readonly) NSString *path;
+@property (nonatomic, readonly) NSURL *fileURL;
@property (nonatomic) NSUInteger pageIndex;
@property (nonatomic, retain) NSNumber *pageNumber;
@property (nonatomic, assign) SKBookmark *parent;
@@ -82,7 +82,6 @@
- (void)insertObject:(SKBookmark *)child inChildrenAtIndex:(NSUInteger)anIndex;
- (void)removeObjectFromChildrenAtIndex:(NSUInteger)anIndex;
-@property (nonatomic, readonly) NSURL *scriptingFile;
@property (nonatomic, readonly) SKBookmark *scriptingParent;
@property (nonatomic, readonly) NSArray *entireContents;
Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m 2012-11-01 17:39:12 UTC (rev 7765)
+++ trunk/SKBookmark.m 2012-11-01 21:53:24 UTC (rev 7766)
@@ -93,7 +93,7 @@
@implementation SKBookmark
@synthesize parent;
-@dynamic properties, bookmarkType, label, icon, alternateIcon, path,
pageIndex, pageNumber, scriptingFile, scriptingParent, entireContents;
+@dynamic properties, bookmarkType, label, icon, alternateIcon, fileURL,
pageIndex, pageNumber, scriptingParent, entireContents;
static SKPlaceholderBookmark *defaultPlaceholderBookmark = nil;
static Class SKBookmarkClass = Nil;
@@ -137,7 +137,8 @@
NSString *fileType = [dc typeForContentsOfURL:url error:NULL];
Class docClass;
SKBookmark *bookmark;
- NSString *label = [fm displayNameAtPath:[url path]];
+ NSString *label = nil;
+ [url getResourceValue:&label forKey:NSURLLocalizedNameKey error:NULL];
if ([[NSWorkspace sharedWorkspace] type:fileType
conformsToType:SKFolderDocumentType]) {
NSArray *children = [self bookmarksForURLs:[fm
contentsOfDirectoryAtURL:url includingPropertiesForKeys:nil
options:NSDirectoryEnumerationSkipsHiddenFiles error:NULL]];
if ([children count] && (bookmark = [[self alloc]
initFolderWithChildren:children label:label])) {
@@ -214,7 +215,7 @@
- (NSString *)label { return nil; }
- (void)setLabel:(NSString *)newLabel {}
-- (NSString *)path { return nil; }
+- (NSURL *)fileURL { return nil; }
- (NSUInteger)pageIndex { return NSNotFound; }
- (void)setPageIndex:(NSUInteger)newPageIndex {}
- (NSNumber *)pageNumber { return nil; }
@@ -243,11 +244,6 @@
}
}
-- (NSURL *)scriptingFile {
- NSString *path = [self path];
- return path ? [NSURL fileURLWithPath:path] : nil;
-}
-
- (SKBookmark *)scriptingParent {
return [parent parent] == nil ? nil : parent;
}
@@ -451,7 +447,7 @@
}
- (NSString *)description {
- return [NSString stringWithFormat:@"<%@: label=%@, path=%@, page=%lu>",
[self class], label, [self path], (unsigned long)pageIndex];
+ return [NSString stringWithFormat:@"<%@: label=%@, path=%@, page=%lu>",
[self class], label, [[self fileURL] path], (unsigned long)pageIndex];
}
- (NSDictionary *)properties {
@@ -464,8 +460,8 @@
return SKBookmarkTypeBookmark;
}
-- (NSString *)path {
- return [alias fullPathNoUI];
+- (NSURL *)fileURL {
+ return [alias fileURLNoUI];
}
- (BDAlias *)alias {
@@ -474,14 +470,14 @@
- (NSData *)aliasData {
NSData *data = nil;
- if ([self path])
+ if ([self fileURL])
data = [alias aliasData];
return data ?: aliasData;
}
- (NSImage *)icon {
- NSString *filePath = [self path];
- return filePath ? [[NSWorkspace sharedWorkspace] iconForFile:filePath] :
[[self class] missingFileImage];
+ NSURL *fileURL = [self fileURL];
+ return fileURL ? [[NSWorkspace sharedWorkspace] iconForFile:[fileURL
path]] : [[self class] missingFileImage];
}
- (NSUInteger)pageIndex {
@@ -501,7 +497,10 @@
}
- (NSString *)label {
- return [label length] > 0 ? label : [[NSFileManager defaultManager]
displayNameAtPath:[self path]] ?: @"";
+ NSString *theLabel = label;
+ if ([theLabel length] == 0)
+ [[self fileURL] getResourceValue:&theLabel
forKey:NSURLLocalizedNameKey error:NULL];
+ return theLabel ?: @"";
}
- (void)setLabel:(NSString *)newLabel {
@@ -517,8 +516,7 @@
if (setup) {
document = [[NSDocumentController sharedDocumentController]
openDocumentWithSetup:[self properties] error:&error];
} else {
- NSString *path = [self path];
- NSURL *fileURL = path ? [NSURL fileURLWithPath:path] : nil;
+ NSURL *fileURL = [self fileURL];
if (fileURL && NO == [[NSFileManager defaultManager]
isTrashedFileAtURL:fileURL] &&
(document = [[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfURL:fileURL display:YES error:&error]) &&
[document isPDFDocument] && [self pageIndex] != NSNotFound)
@@ -644,7 +642,7 @@
else
aPageNumber = [docClass isPDFDocument] ? 0 :
NSNotFound;
if (aLabel == nil)
- aLabel = [[NSFileManager defaultManager]
displayNameAtPath:[aURL path]];
+ [aURL getResourceValue:&aLabel
forKey:NSURLLocalizedNameKey error:NULL];
bookmark = [[SKBookmark alloc] initWithURL:aURL
pageIndex:aPageNumber label:aLabel ?: @""];
} else {
[[NSScriptCommand currentCommand]
setScriptErrorNumber:NSArgumentsWrongScriptError];
@@ -658,7 +656,7 @@
if (aURL) {
aChildren = [SKBookmark bookmarksForURLs:[[NSFileManager
defaultManager] contentsOfDirectoryAtURL:aURL includingPropertiesForKeys:nil
options:NSDirectoryEnumerationSkipsHiddenFiles error:NULL]];
if (aLabel == nil)
- aLabel = [[NSFileManager defaultManager]
displayNameAtPath:[aURL path]];
+ [aURL getResourceValue:&aLabel
forKey:NSURLLocalizedNameKey error:NULL];
}
bookmark = [[SKBookmark alloc]
initFolderWithChildren:aChildren label:aLabel ?: @""];
break;
Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m 2012-11-01 17:39:12 UTC (rev 7765)
+++ trunk/SKBookmarkController.m 2012-11-01 21:53:24 UTC (rev 7766)
@@ -208,7 +208,7 @@
if (row != -1) {
SKBookmark *bookmark = [outlineView itemAtRow:row];
if ([bookmark bookmarkType] == SKBookmarkTypeBookmark) {
- message = [bookmark path];
+ message = [[bookmark fileURL] path];
} else if ([bookmark bookmarkType] == SKBookmarkTypeFolder) {
NSInteger count = [bookmark countOfChildren];
message = count == 1 ? NSLocalizedString(@"1 item", @"Bookmark
folder description") : [NSString stringWithFormat:NSLocalizedString(@"%ld
items", @"Bookmark folder description"), (long)count];
@@ -595,7 +595,7 @@
NSInteger count = [item countOfChildren];
return count == 1 ? NSLocalizedString(@"1 item", @"Bookmark folder
description") : [NSString stringWithFormat:NSLocalizedString(@"%ld items",
@"Bookmark folder description"), (long)count];
} else {
- return [[item path] stringByAbbreviatingWithTildeInPath];
+ return [[[item fileURL] path] stringByAbbreviatingWithTildeInPath];
}
} else if ([tcID isEqualToString:PAGE_COLUMNID]) {
return [item pageNumber];
@@ -730,7 +730,7 @@
NSInteger count = [item countOfChildren];
return count == 1 ? NSLocalizedString(@"1 item", @"Bookmark folder
description") : [NSString stringWithFormat:NSLocalizedString(@"%ld items",
@"Bookmark folder description"), (long)count];
} else {
- return [item path];
+ return [[item fileURL] path];
}
} else if ([tcID isEqualToString:PAGE_COLUMNID]) {
return [[item pageNumber] stringValue];
Modified: trunk/SKScriptMenu.m
===================================================================
--- trunk/SKScriptMenu.m 2012-11-01 17:39:12 UTC (rev 7765)
+++ trunk/SKScriptMenu.m 2012-11-01 21:53:24 UTC (rev 7766)
@@ -204,16 +204,17 @@
NSMutableArray *files = [NSMutableArray array];
NSFileManager *fm = [NSFileManager defaultManager];
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
- NSArray *keys = [NSArray arrayWithObjects:NSURLIsDirectoryKey, nil];
+ NSArray *keys = [NSArray arrayWithObjects:NSURLIsDirectoryKey,
NSURLLocalizedNameKey, nil];
for (NSURL *fileURL in [fm contentsOfDirectoryAtURL:url
includingPropertiesForKeys:keys options:NSDirectoryEnumerationSkipsHiddenFiles
error:NULL]) {
NSNumber *isDirNumber = nil;
BOOL isDir;
NSString *theUTI = [ws typeOfFile:[[[fileURL URLByStandardizingPath]
URLByResolvingSymlinksInPath] path] error:NULL];
NSString *filePath = [fileURL path];
- NSString *title = [[NSFileManager defaultManager]
displayNameAtPath:filePath];
+ NSString *title = nil;
NSDictionary *dict = nil;
+ [fileURL getResourceValue:&title forKey:NSURLLocalizedNameKey
error:NULL];
[fileURL getResourceValue:&isDirNumber forKey:NSURLIsDirectoryKey
error:NULL];
isDir = [isDirNumber boolValue];
Modified: trunk/Skim.sdef
===================================================================
--- trunk/Skim.sdef 2012-11-01 17:39:12 UTC (rev 7765)
+++ trunk/Skim.sdef 2012-11-01 21:53:24 UTC (rev 7766)
@@ -1203,7 +1203,7 @@
</property>
<contents name="file" code="file" type="file" access="r"
description="The file for the bookmark.">
- <cocoa key="scriptingFile"/>
+ <cocoa key="fileURL"/>
</contents>
<property name="page index" code="PIdx" type="integer"
description="The page index for the bookmark.">
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit