Revision: 6715
http://skim-app.svn.sourceforge.net/skim-app/?rev=6715&view=rev
Author: hofman
Date: 2010-08-19 10:04:56 +0000 (Thu, 19 Aug 2010)
Log Message:
-----------
only add script menu file info once and include code to clean title in place
Modified Paths:
--------------
trunk/SKScriptMenu.m
Modified: trunk/SKScriptMenu.m
===================================================================
--- trunk/SKScriptMenu.m 2010-08-19 09:24:29 UTC (rev 6714)
+++ trunk/SKScriptMenu.m 2010-08-19 10:04:56 UTC (rev 6715)
@@ -138,24 +138,6 @@
[scriptMenu setDelegate:nil];
}
-static NSString *menuItemTitle(NSString *path) {
- static NSSet *scriptExtensions = nil;
- if (scriptExtensions == nil)
- scriptExtensions = [[NSSet alloc] initWithObjects:@"scpt", @"scptd",
@"applescript", @"sh", @"csh", @"command", @"py", @"rb", @"pl", @"pm", @"app",
@"workflow", nil];
-
- NSString *name = [path lastPathComponent];
-
- if ([scriptExtensions containsObject:[[name pathExtension]
lowercaseString]])
- name = [name stringByDeletingPathExtension];
-
- NSScanner *scanner = [NSScanner scannerWithString:name];
- [scanner setCharactersToBeSkipped:nil];
- if ([scanner scanCharactersFromSet:[NSCharacterSet
decimalDigitCharacterSet] intoString:NULL] && [scanner scanString:@"-"
intoString:NULL])
- name = [name substringFromIndex:[scanner scanLocation]];
-
- return name;
-}
-
- (void)updateSubmenu:(NSMenu *)menu withScripts:(NSArray *)scripts {
[menu removeAllItems];
@@ -233,26 +215,32 @@
NSString *fileType = [fileAttributes valueForKey:NSFileType];
BOOL isDir = [fileType isEqualToString:NSFileTypeDirectory];
NSString *theUTI = [ws typeOfFile:[[filePath
stringByStandardizingPath] stringByResolvingSymlinksInPath] error:NULL];
- NSString *title = menuItemTitle(file);
+ NSString *title = [path lastPathComponent];
+ NSDictionary *dict = nil;
- NSMutableDictionary *dict;
+ NSScanner *scanner = [NSScanner scannerWithString:title];
+ [scanner setCharactersToBeSkipped:nil];
+ if ([scanner scanCharactersFromSet:[NSCharacterSet
decimalDigitCharacterSet] intoString:NULL] && [scanner scanString:@"-"
intoString:NULL])
+ title = [title substringFromIndex:[scanner scanLocation]];
if ([title isEqualToString:@"-"] || [title length] == 0) {
dict = [[NSDictionary alloc] initWithObjectsAndKeys:filePath,
FILENAME_KEY, nil];
- [files addObject:dict];
- [dict release];
} else if (isAppleScriptUTI(theUTI) || isApplicationUTI(theUTI) ||
isAutomatorWorkflowUTI(theUTI) || ([fm isExecutableFileAtPath:filePath] &&
isDir == NO)) {
+ static NSSet *scriptExtensions = nil;
+ if (scriptExtensions == nil)
+ scriptExtensions = [[NSSet alloc] initWithObjects:@"scpt",
@"scptd", @"applescript", @"sh", @"csh", @"command", @"py", @"rb", @"pl",
@"pm", @"app", @"workflow", nil];
+ if ([scriptExtensions containsObject:[[title pathExtension]
lowercaseString]])
+ title = [title stringByDeletingPathExtension];
dict = [[NSDictionary alloc] initWithObjectsAndKeys:filePath,
FILENAME_KEY, title, TITLE_KEY, nil];
- [files addObject:dict];
- [dict release];
} else if (isDir && isFolderUTI(theUTI) && depth < 3) {
NSArray *content = [self directoryContentsAtPath:filePath
recursionDepth:depth + 1];
- if ([content count] > 0) {
+ if ([content count] > 0)
dict = [[NSDictionary alloc] initWithObjectsAndKeys:filePath,
FILENAME_KEY, title, TITLE_KEY, content, CONTENT_KEY, nil];
- [files addObject:dict];
- [dict release];
- }
}
+ if (dict) {
+ [files addObject:dict];
+ [dict release];
+ }
}
[files sortUsingDescriptors:sortDescriptors];
return files;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit