Skip to content

Commit

Permalink
Show the bundle name instead of the bundle file name in the triggers …
Browse files Browse the repository at this point in the history
…scope view

Fixes #1531
Plus: Add a menu to the token to show the represented object
  • Loading branch information
pjrobertson committed Dec 5, 2013
1 parent 193b0b1 commit 9650340
Show file tree
Hide file tree
Showing 3 changed files with 584 additions and 3,078 deletions.
15 changes: 12 additions & 3 deletions Quicksilver/Code-App/QSTriggersPrefPane.m
Expand Up @@ -653,13 +653,13 @@ - (void)setTriggerSets:(NSMutableArray *)newTriggerSets {

- (NSString *)tokenField:(NSTokenField *)tokenField editingStringForRepresentedObject:(id)representedObject {
NSString *path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:representedObject];
return [[path lastPathComponent] stringByDeletingPathExtension];
return [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleName"];
}

// The method called when the token field (e.g. the 'scope' field completes/creates a new token
- (NSString *)tokenField:(NSTokenField *)tokenField displayStringForRepresentedObject:(id)representedObject {
NSString *path = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:representedObject];
return [[path lastPathComponent] stringByDeletingPathExtension];
return [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:@"CFBundleName"];
}

// The method called to find a representation for the entered string in the token field
Expand All @@ -675,7 +675,16 @@ - (NSTokenStyle) tokenField:(NSTokenField *)tokenField styleForRepresentedObject
}

- (BOOL)tokenField:(NSTokenField *)tokenField hasMenuForRepresentedObject:(id)representedObject {
return NO;
return YES;
}

- (NSMenu *)tokenField:(NSTokenField *)tokenField menuForRepresentedObject:(id)representedObject {
NSMenu *menu = [[NSMenu alloc] initWithTitle:representedObject];
NSMenuItem *menuItem = [NSMenuItem new];
menuItem.title = representedObject;
[menu addItem:menuItem];
return menu;
}


@end
11 changes: 2 additions & 9 deletions Quicksilver/Code-QuickStepCore/QSTrigger.m
Expand Up @@ -127,9 +127,9 @@ - (void)initializeTrigger {

// On app change, checks all triggers to see if they should be enabled/disabled based on scope in prefs
- (void)rescope:(NSString *)ident {
// If the trigger's disabled there's no point rescoping **fix p_j_r 24/04/2011
// If the trigger's disabled there's no point rescoping
if([info objectForKey:@"enabled"] && ![[info objectForKey:@"enabled"] boolValue]) return;
// Scoped is 0 for unscoped triggers, -1 for 'disabled in xxx' and +1 for 'enabled in xxx'
// Scoped is 0 for unscoped triggers, -1 for 'disabled in application xxx' and +1 for 'enabled in application xxx'
NSInteger scoped = [[info objectForKey:@"applicationScopeType"] integerValue];
if (!scoped) return;
NSArray *apps = [info objectForKey:@"applicationScope"];
Expand Down Expand Up @@ -229,13 +229,6 @@ - (void)reactivate {
activated = [self enabled];
}

// Fix issue 57, http://github.com/tiennou/blacktree-alchemy/issues/#issue/57
// issue 61, http://github.com/tiennou/blacktree-alchemy/issuesearch?state=open&q=trigger#issue/61
// Added variable activated to QSTrigger object to handle trigger "scope".
// Prior to fix QSTrigger's enabled flag was being dual purposed, one as a
// the primary trigger enabler and the other as an application scope trigger
// enabler, and caused issue 57.
// Giving each state its own flag eliminates the problem completely.
- (BOOL)activated {
return activated;
}
Expand Down

0 comments on commit 9650340

Please sign in to comment.