Revision: 5477
http://skim-app.svn.sourceforge.net/skim-app/?rev=5477&view=rev
Author: hofman
Date: 2009-07-14 10:01:00 +0000 (Tue, 14 Jul 2009)
Log Message:
-----------
allow opening a folder, by opening all containing documents
Modified Paths:
--------------
trunk/Dutch.lproj/InfoPlist.strings
trunk/English.lproj/InfoPlist.strings
trunk/French.lproj/InfoPlist.strings
trunk/German.lproj/InfoPlist.strings
trunk/Italian.lproj/InfoPlist.strings
trunk/SKDocumentController.h
trunk/SKDocumentController.m
trunk/Spanish.lproj/InfoPlist.strings
trunk/ru.lproj/InfoPlist.strings
Modified: trunk/Dutch.lproj/InfoPlist.strings
===================================================================
(Binary files differ)
Modified: trunk/English.lproj/InfoPlist.strings
===================================================================
(Binary files differ)
Modified: trunk/French.lproj/InfoPlist.strings
===================================================================
(Binary files differ)
Modified: trunk/German.lproj/InfoPlist.strings
===================================================================
(Binary files differ)
Modified: trunk/Italian.lproj/InfoPlist.strings
===================================================================
(Binary files differ)
Modified: trunk/SKDocumentController.h
===================================================================
--- trunk/SKDocumentController.h 2009-07-14 10:00:17 UTC (rev 5476)
+++ trunk/SKDocumentController.h 2009-07-14 10:01:00 UTC (rev 5477)
@@ -53,6 +53,7 @@
extern BOOL SKIsBarePostScriptDocumentType(NSString *docType);
extern BOOL SKIsDVIDocumentType(NSString *docType);
extern BOOL SKIsBareDVIDocumentType(NSString *docType);
+extern BOOL SKIsFolderDocumentType(NSString *docType);
extern NSString *SKNormalizedDocumentType(NSString *docType);
@@ -69,6 +70,7 @@
extern NSString *SKBarePostScriptDocumentType;
extern NSString *SKDVIDocumentType;
extern NSString *SKBareDVIDocumentType;
+extern NSString *SKFolderDocumentType;
extern NSString *SKDocumentSetupAliasKey;
extern NSString *SKDocumentSetupFileNameKey;
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2009-07-14 10:00:17 UTC (rev 5476)
+++ trunk/SKDocumentController.m 2009-07-14 10:01:00 UTC (rev 5477)
@@ -66,6 +66,7 @@
NSString *SKBarePostScriptDocumentType = @"PostScript Without Notes";
NSString *SKDVIDocumentType = @"DVI document";
NSString *SKBareDVIDocumentType = @"DVI Without Notes";
+NSString *SKFolderDocumentType = @"Folder";
#define DEFINE_IS_DOCUMENT_TYPE(name) BOOL SKIs##name##DocumentType(NSString
*docType) { return [docType isEqualToString:SK##name##DocumentType]; }
@@ -82,6 +83,7 @@
DEFINE_IS_DOCUMENT_TYPE(NotesFDF)
DEFINE_IS_DOCUMENT_TYPE(BarePostScript)
DEFINE_IS_DOCUMENT_TYPE(BareDVI)
+DEFINE_IS_DOCUMENT_TYPE(Folder)
#define RETURN_IF_IS_DOCUMENT_TYPE(name) if
(SKIs##name##DocumentType(docType)) return SK##name##DocumentType
@@ -99,6 +101,7 @@
RETURN_IF_IS_DOCUMENT_TYPE(BarePostScript);
RETURN_IF_IS_DOCUMENT_TYPE(DVI);
RETURN_IF_IS_DOCUMENT_TYPE(BareDVI);
+ RETURN_IF_IS_DOCUMENT_TYPE(Folder);
if ([docType isEqualToString:@"PDF"]) return SKPDFDocumentType;
if ([docType isEqualToString:@"PostScript"]) return
SKPostScriptDocumentType;
if ([docType isEqualToString:@"DVI"]) return SKDVIDocumentType;
@@ -200,8 +203,13 @@
NSError *error = nil;
NSString *type = [super typeForContentsOfURL:inAbsoluteURL error:&error];
+ BOOL isDir;
- if ([self documentClassForType:type] == NULL) {
+ // folders are not recognized, so we have to check for those ourselves,
rdar://problem/7056540
+ if ([[NSFileManager defaultManager] fileExistsAtPath:[inAbsoluteURL path]
isDirectory:&isDir] && isDir &&
+ [[NSWorkspace sharedWorkspace] isFilePackageAtPath:[inAbsoluteURL
path]] == NO) {
+ type = SKFolderDocumentType;
+ } else if ([self documentClassForType:type] == NULL) {
// "open -f" creates a temporary file with a .txt extension, we want
to be able to open these file as it can be very handy to e.g. display man pages
and pretty printed text file from the command line
if ([inAbsoluteURL isFileURL]) {
NSString *fileName = [inAbsoluteURL path];
@@ -369,6 +377,24 @@
if ([[NSFileManager defaultManager] fileExistsAtPath:pdfFile
isDirectory:&isDir] && isDir == NO)
absoluteURL = [NSURL fileURLWithPath:pdfFile];
}
+ } else if (SKIsFolderDocumentType(type)) {
+ NSDocument *doc = nil;
+ NSError *error = nil;
+ NSString *basePath = [absoluteURL path];
+ NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager]
enumeratorAtPath:basePath];
+ NSString *path;
+
+ while (path = [dirEnum nextObject]) {
+ NSURL *url = [NSURL fileURLWithPath:[basePath
stringByAppendingPathComponent:path]];
+ NSString *aType = [self typeForContentsOfURL:url error:NULL];
+ if ([self documentClassForType:aType])
+ doc = [self openDocumentWithContentsOfURL:url
display:displayDocument error:&error] ?: doc;
+ }
+
+ if (doc == nil && outError)
+ *outError = error ?: [NSError
errorWithDomain:SKDocumentErrorDomain code:0 userInfo:[NSDictionary
dictionaryWithObjectsAndKeys:NSLocalizedString(@"Unable to open folder",
@"Error description"), NSLocalizedDescriptionKey, nil]];
+
+ return doc;
}
return [super openDocumentWithContentsOfURL:absoluteURL
display:displayDocument error:outError];
}
Modified: trunk/Spanish.lproj/InfoPlist.strings
===================================================================
(Binary files differ)
Modified: trunk/ru.lproj/InfoPlist.strings
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit