Revision: 7210
http://skim-app.svn.sourceforge.net/skim-app/?rev=7210&view=rev
Author: hofman
Date: 2011-04-13 11:59:38 +0000 (Wed, 13 Apr 2011)
Log Message:
-----------
search notes document when opening from spotlight
Modified Paths:
--------------
trunk/SKNotesDocument.m
Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m 2011-04-13 11:55:45 UTC (rev 7209)
+++ trunk/SKNotesDocument.m 2011-04-13 11:59:38 UTC (rev 7210)
@@ -124,6 +124,31 @@
NSWindowController *wc = [[self windowControllers] lastObject];
BOOL wasVisible = [wc isWindowLoaded] && [[wc window] isVisible];
[super showWindows];
+
+ // Get the search string keyword if available (Spotlight passes this)
+ NSAppleEventDescriptor *event = [[NSAppleEventManager
sharedAppleEventManager] currentAppleEvent];
+ NSString *searchString;
+
+ if ([event eventID] == kAEOpenDocuments &&
+ (searchString = [[event descriptorForKeyword:keyAESearchText]
stringValue]) &&
+ [@"" isEqualToString:searchString] == NO &&
+ [searchField window]) {
+ if ([searchString length] > 2 && [searchString characterAtIndex:0] ==
'"' && [searchString characterAtIndex:[searchString length] - 1] == '"') {
+ //strip quotes
+ searchString = [searchString substringWithRange:NSMakeRange(1,
[searchString length] - 2)];
+ } else {
+ // strip extra search criteria
+ NSRange range = [searchString rangeOfString:@":"];
+ if (range.location != NSNotFound) {
+ range = [searchString rangeOfCharacterFromSet:[NSCharacterSet
whitespaceCharacterSet] options:NSBackwardsSearch range:NSMakeRange(0,
range.location)];
+ if (range.location != NSNotFound && range.location > 0)
+ searchString = [searchString
substringWithRange:NSMakeRange(0, range.location)];
+ }
+ }
+ [searchField setStringValue:searchString];
+ [self performSelector:@selector(searchNotes:) withObject:searchField
afterDelay:0.0];
+ }
+
if (wasVisible == NO)
[[NSNotificationCenter defaultCenter]
postNotificationName:SKDocumentDidShowNotification object:self];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Forrester Wave Report - Recovery time is now measured in hours and minutes
not days. Key insights are discussed in the 2010 Forrester Wave Report as
part of an in-depth evaluation of disaster recovery service providers.
Forrester found the best-in-class provider in terms of services and vision.
Read this report now! http://p.sf.net/sfu/ibm-webcastpromo
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit