Revision: 6703
http://skim-app.svn.sourceforge.net/skim-app/?rev=6703&view=rev
Author: hofman
Date: 2010-08-16 11:32:18 +0000 (Mon, 16 Aug 2010)
Log Message:
-----------
update script menu even when we cannot create an event stream to watch the
folders
Modified Paths:
--------------
trunk/SKScriptMenu.m
Modified: trunk/SKScriptMenu.m
===================================================================
--- trunk/SKScriptMenu.m 2010-08-15 12:34:06 UTC (rev 6702)
+++ trunk/SKScriptMenu.m 2010-08-16 11:32:18 UTC (rev 6703)
@@ -49,6 +49,7 @@
@interface SKScriptMenuController : NSObject <NSMenuDelegate> {
NSMenu *scriptMenu;
FSEventStreamRef streamRef;
+ NSArray *scriptFolders;
NSArray *sortDescriptors;
}
@@ -84,16 +85,16 @@
NSInteger itemIndex = [[NSApp mainMenu] numberOfItems] - 1;
NSFileManager *fm = [NSFileManager defaultManager];
- NSMutableArray *scriptFolders = [NSMutableArray array];
+ NSMutableArray *folders = [NSMutableArray array];
BOOL isDir;
for (NSString *folder in [fm applicationSupportDirectories]) {
folder = [folder
stringByAppendingPathComponent:SCRIPTS_FOLDER_NAME];
if ([fm fileExistsAtPath:folder isDirectory:&isDir] && isDir)
- [scriptFolders addObject:folder];
+ [folders addObject:folder];
}
- if (itemIndex > 0 && [scriptFolders count]) {
+ if (itemIndex > 0 && [folders count]) {
scriptMenu = [[NSMenu allocWithZone:[NSMenu menuZone]]
initWithTitle:SCRIPTS_MENU_TITLE];
NSMenuItem *menuItem = [[NSMenuItem allocWithZone:[NSMenu
menuZone]] initWithTitle:SCRIPTS_MENU_TITLE action:NULL keyEquivalent:@""];
@@ -104,6 +105,8 @@
sortDescriptors = [[NSArray alloc]
initWithObjects:[[[NSSortDescriptor alloc] initWithKey:FILENAME_KEY
ascending:YES selector:@selector(localizedCaseInsensitiveNumericCompare:)]
autorelease], nil];
+ scriptFolders = [folders copy];
+
streamRef = FSEventStreamCreate(kCFAllocatorDefault,
(FSEventStreamCallback)&fsevents_callback, // callback
NULL, // context
@@ -114,11 +117,11 @@
if (streamRef) {
FSEventStreamScheduleWithRunLoop(streamRef,
CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
FSEventStreamStart(streamRef);
-
- [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleApplicationWillTerminateNotification:)
name:NSApplicationWillTerminateNotification object:NSApp];
- [scriptMenu setDelegate:self];
- menuNeedsUpdate = YES;
}
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleApplicationWillTerminateNotification:)
name:NSApplicationWillTerminateNotification object:NSApp];
+ [scriptMenu setDelegate:self];
+ menuNeedsUpdate = YES;
}
}
return self;
@@ -178,11 +181,9 @@
if (streamRef == NULL || menuNeedsUpdate == NO)
return;
- NSArray *scriptFolders = (NSArray
*)FSEventStreamCopyPathsBeingWatched(streamRef);
NSMutableArray *scripts = [NSMutableArray array];
for (NSString *folder in scriptFolders)
[scripts addObjectsFromArray:[self directoryContentsAtPath:folder
recursionDepth:0]];
- [scriptFolders release];
[scripts sortUsingDescriptors:sortDescriptors];
[self updateSubmenu:menu withScripts:scripts];
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