Revision: 12289
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=12289&view=rev
Author: hofman
Date: 2008-01-05 14:12:50 -0800 (Sat, 05 Jan 2008)
Log Message:
-----------
Add default scripts at top of script menu and add a separator.
Modified Paths:
--------------
trunk/bibdesk/BDSKScriptMenu.m
Modified: trunk/bibdesk/BDSKScriptMenu.m
===================================================================
--- trunk/bibdesk/BDSKScriptMenu.m 2008-01-05 20:30:48 UTC (rev 12288)
+++ trunk/bibdesk/BDSKScriptMenu.m 2008-01-05 22:12:50 UTC (rev 12289)
@@ -115,19 +115,20 @@
- (void)reloadScriptMenu;
{
NSMutableArray *scripts;
+ NSMutableArray *defaultScripts;
NSArray *scriptFolders;
- unsigned int scriptFolderIndex, scriptFolderCount;
+ unsigned int i, count;
scripts = [[NSMutableArray alloc] init];
scriptFolders = [self scriptPaths];
- scriptFolderCount = [scriptFolders count];
+ count = [scriptFolders count];
// must initialize this date before passing it by reference
NSDate *modDate = earliestDateFromBaseScriptsFolders(scriptFolders);
// walk the subdirectories for each domain
- for (scriptFolderIndex = 0; scriptFolderIndex < scriptFolderCount;
scriptFolderIndex++) {
- NSString *scriptFolder = [scriptFolders
objectAtIndex:scriptFolderIndex];
+ for (i = 0; i < count; i++) {
+ NSString *scriptFolder = [scriptFolders objectAtIndex:i];
recursionDepth = 0;
[scripts addObjectsFromArray:[self
directoryContentsAtPath:scriptFolder lastModified:&modDate]];
}
@@ -138,6 +139,17 @@
cachedDate = [modDate retain];
[scripts sortUsingDescriptors:sortDescriptors];
+
+ defaultScripts = [[self directoryContentsAtPath:[[[NSBundle
mainBundle] sharedSupportPath] stringByAppendingPathComponent:@"Scripts"]
lastModified:&modDate] mutableCopy];
+ [defaultScripts sortUsingDescriptors:sortDescriptors];
+
+ if (count = [defaultScripts count]) {
+ if ([scripts count])
+ [scripts insertObject:[NSDictionary dictionary] atIndex:0];
+ [scripts insertObjects:defaultScripts atIndexes:[NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, count)]];
+ }
+ [scriptFolders release];
+
[self updateSubmenu:self withScripts:scripts];
}
[scripts release];
@@ -207,7 +219,9 @@
NSString *scriptName = [scriptFilename lastPathComponent];
NSMenuItem *item;
- if (folderContent) {
+ if (scriptName == nil) {
+ [menu addItem:[NSMenuItem separatorItem]];
+ } else if (folderContent) {
NSMenu *submenu = [[NSMenu allocWithZone:[NSMenu
menuZone]] initWithTitle:scriptName];
item = [[NSMenuItem allocWithZone:[NSMenu menuZone]]
initWithTitle:scriptName action:NULL keyEquivalent:@""];
@@ -268,7 +282,6 @@
[result addObject:[[[library
stringByAppendingPathComponent:@"Application Support"]
stringByAppendingPathComponent:appSupportDirectory]
stringByAppendingPathComponent:@"Scripts"]];
}
- [result addObject:[[[NSBundle mainBundle] sharedSupportPath]
stringByAppendingPathComponent:@"Scripts"]];
scriptPaths = [result copy];
[result release];
}
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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit