Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow 'current context' to work in AppleScript when multiple contexts are enabled #328

Merged
merged 1 commit into from Jul 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/AppleScript.m
Expand Up @@ -14,7 +14,7 @@ @implementation NSApplication (AppleScript)
// current context property // current context property


- (NSString *) currentContext { - (NSString *) currentContext {
return [[NSApp delegate] currentContextPath]; return [[NSApp delegate] currentContextAsString];
} }


- (void) setCurrentContext: (NSString*) newContext { - (void) setCurrentContext: (NSString*) newContext {
Expand Down
2 changes: 2 additions & 0 deletions Source/CPController.h
Expand Up @@ -41,6 +41,8 @@
- (void)resumeRegularUpdates; - (void)resumeRegularUpdates;
- (void)resumeRegularUpdatesWithDelay:(int64_t)nanoseconds; - (void)resumeRegularUpdatesWithDelay:(int64_t)nanoseconds;
- (void)forceUpdate; - (void)forceUpdate;

- (NSString*)currentContextAsString;
+ (NSSet *) sharedActiveContexts; + (NSSet *) sharedActiveContexts;


@end @end
16 changes: 13 additions & 3 deletions Source/CPController.m
Expand Up @@ -773,9 +773,7 @@ - (void)updateMenuBarAndContextMenu {
[_joinedContextPaths appendString:context.name]; //[contextsDataSource pathFromRootTo:context.uuid]]; [_joinedContextPaths appendString:context.name]; //[contextsDataSource pathFromRootTo:context.uuid]];
} }
self.currentContextPath=_joinedContextPaths;*/ self.currentContextPath=_joinedContextPaths;*/
NSSortDescriptor *sortKey=[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:TRUE]; self.currentContextPath=[self currentContextAsString];
NSArray *keyArray=[NSArray arrayWithObject:sortKey];
self.currentContextPath=[[self.activeContexts sortedArrayUsingDescriptors:keyArray] componentsJoinedByString:@" + "]; // sans context-paths, to conserve space. perhaps we'll add a pref to switch it on (above).
} }
[self setStatusTitle:[self currentContextPath]]; [self setStatusTitle:[self currentContextPath]];
} }
Expand Down Expand Up @@ -1968,4 +1966,16 @@ - (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(
break; break;
} }
} }

- (NSString*) currentContextAsString {
if ([self useMultipleActiveContexts]) {
NSSortDescriptor *sortKey=[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:TRUE];
NSArray *keyArray=[NSArray arrayWithObject:sortKey];
NSArray* aca = [self.activeContexts sortedArrayUsingDescriptors:keyArray];
NSString* acas = [aca componentsJoinedByString:@" + "];
return acas;
} else {
return self.currentContextPath;
}
}
@end @end