Revision: 7090
http://skim-app.svn.sourceforge.net/skim-app/?rev=7090&view=rev
Author: hofman
Date: 2011-02-09 18:34:02 +0000 (Wed, 09 Feb 2011)
Log Message:
-----------
Add a service to open a notes document with the attached notes for a file
Modified Paths:
--------------
trunk/Dutch.lproj/ServicesMenu.strings
trunk/English.lproj/ServicesMenu.strings
trunk/French.lproj/ServicesMenu.strings
trunk/German.lproj/ServicesMenu.strings
trunk/Info.plist
trunk/Italian.lproj/ServicesMenu.strings
trunk/Japanese.lproj/ServicesMenu.strings
trunk/SKApplicationController.m
trunk/SKDocumentController.h
trunk/SKDocumentController.m
trunk/Spanish.lproj/ServicesMenu.strings
trunk/pl.lproj/ServicesMenu.strings
trunk/ru.lproj/ServicesMenu.strings
trunk/zh_TW.lproj/ServicesMenu.strings
Modified: trunk/Dutch.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/English.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/French.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/German.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/Info.plist
===================================================================
--- trunk/Info.plist 2011-02-09 16:17:05 UTC (rev 7089)
+++ trunk/Info.plist 2011-02-09 18:34:02 UTC (rev 7090)
@@ -616,6 +616,28 @@
<string>NSTIFFPboardType</string>
</array>
</dict>
+ <dict>
+ <key>NSMenuItem</key>
+ <dict>
+ <key>default</key>
+ <string>Skim/Show Skim Notes</string>
+ </dict>
+ <key>NSMessage</key>
+ <string>openNotesDocumentFromURLOnPboard</string>
+ <key>NSPortName</key>
+ <string>Skim</string>
+ <key>NSRequiredContext</key>
+ <dict>
+ <key>NSTextContent</key>
+ <string>FilePath</string>
+ </dict>
+ <key>NSSendTypes</key>
+ <array>
+ <string>NSURLPboardType</string>
+ <string>NSStringPboardType</string>
+ <string>CorePasteboardFlavorType
0x75726C20</string>
+ </array>
+ </dict>
</array>
<key>OSAScriptingDefinition</key>
<string>Skim.sdef</string>
Modified: trunk/Italian.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/Japanese.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m 2011-02-09 16:17:05 UTC (rev 7089)
+++ trunk/SKApplicationController.m 2011-02-09 18:34:02 UTC (rev 7090)
@@ -257,6 +257,14 @@
*errorString = [error localizedDescription];
}
+- (void)openNotesDocumentFromURLOnPboard:(NSPasteboard *)pboard
userData:(NSString *)userData error:(NSString **)errorString {
+ NSError *error;
+ id document = [[NSDocumentController sharedDocumentController]
openNotesDocumentWithURLFromPasteboard:pboard error:&error];
+
+ if (document == nil && errorString)
+ *errorString = [error localizedDescription];
+}
+
#pragma mark Actions
- (IBAction)orderFrontLineInspector:(id)sender {
Modified: trunk/SKDocumentController.h
===================================================================
--- trunk/SKDocumentController.h 2011-02-09 16:17:05 UTC (rev 7089)
+++ trunk/SKDocumentController.h 2011-02-09 18:34:02 UTC (rev 7090)
@@ -75,6 +75,7 @@
// this method may return an SKDownload instance
- (id)openDocumentWithURLFromPasteboard:(NSPasteboard *)pboard error:(NSError
**)outError;
- (id)openDocumentWithSetup:(NSDictionary *)setup error:(NSError **)outError;
+- (id)openNotesDocumentWithURLFromPasteboard:(NSPasteboard *)pboard
error:(NSError **)outError;
- (Class)documentClassForContentsOfURL:(NSURL *)inAbsoluteURL;
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2011-02-09 16:17:05 UTC (rev 7089)
+++ trunk/SKDocumentController.m 2011-02-09 18:34:02 UTC (rev 7090)
@@ -47,9 +47,11 @@
#import "BDAlias.h"
#import "SKMainWindowController.h"
#import "NSError_SKExtensions.h"
+#import <SkimNotes/SkimNotes.h>
#define SKAutosaveIntervalKey @"SKAutosaveInterval"
+#define SKIM_NOTES_KEY @"net_sourceforge_skim-app_notes"
// See CFBundleTypeName in Info.plist
NSString *SKPDFDocumentType = nil;
@@ -267,6 +269,43 @@
return document;
}
+- (id)openNotesDocumentWithURLFromPasteboard:(NSPasteboard *)pboard
error:(NSError **)outError {
+ NSURL *theURL = [NSURL URLFromPasteboardAnyType:pboard];
+ id document = nil;
+
+ if ([theURL isFileURL]) {
+ NSError *error = nil;
+ NSString *type = [self typeForContentsOfURL:theURL error:&error];
+ NSData *data = nil;
+
+ if ([type isEqualToString:SKPDFDocumentType]) {
+ data = [[SKNExtendedAttributeManager sharedManager]
extendedAttributeNamed:SKIM_NOTES_KEY atPath:[theURL path] traverseLink:YES
error:&error];
+ } else if ([type isEqualToString:SKPDFBundleDocumentType]) {
+ NSString *skimFile = [[NSFileManager defaultManager]
bundledFileWithExtension:@"skim" inPDFBundleAtPath:[theURL path] error:&error];
+ data = skimFile ? [NSData dataWithContentsOfFile:skimFile
options:0 error:&error] : nil;
+ } else if ([type isEqualToString:SKNotesDocumentType]) {
+ data = [NSData dataWithContentsOfURL:theURL options:0
error:&error];
+ }
+
+ if (data)
+ document = [self makeUntitledDocumentOfType:SKNotesDocumentType
error:&error];
+
+ if ([document readFromData:data ofType:SKNotesDocumentType
error:&error]) {
+ [self addDocument:document];
+ [document makeWindowControllers];
+ [document showWindows];
+ } else {
+ document = nil;
+ if (outError)
+ *outError = error;
+ }
+ } else if (outError) {
+ *outError = [NSError
readPasteboardErrorWithLocalizedDescription:NSLocalizedString(@"Unable to load
data from clipboard", @"Error description")];
+ }
+
+ return document;
+}
+
- (IBAction)newDocumentFromClipboard:(id)sender {
NSError *error = nil;
id document = [self openDocumentWithContentsOfPasteboard:[NSPasteboard
generalPasteboard] error:&error];
Modified: trunk/Spanish.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/pl.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/ru.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
Modified: trunk/zh_TW.lproj/ServicesMenu.strings
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit