Skip to content

Commit

Permalink
fixed building
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegrosjean committed Sep 21, 2009
1 parent 2769fb9 commit 85a2ee8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 36 deletions.
68 changes: 33 additions & 35 deletions QCAppDelegate.m
Expand Up @@ -20,29 +20,6 @@ + (void)initialize {
nil]];
}

- (void)updateHotKeys {
PTHotKeyCenter *hotKeyCenter = [PTHotKeyCenter sharedCenter];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

for (PTHotKey *each in registeredHotKeys) {
[hotKeyCenter unregisterHotKey:each];
}

[registeredHotKeys removeAllObjects];

for (NSMenuItem *each in [self validatedEditorMenuItems:NULL]) {
id eachKeyComboPlist = [userDefaults objectForKey:[each representedObject]];
if (eachKeyComboPlist) {
PTKeyCombo *keyCombo = [[[PTKeyCombo alloc] initWithPlistRepresentation:eachKeyComboPlist] autorelease];
PTHotKey *hotKey = [[PTHotKey alloc] initWithIdentifier:[each representedObject] keyCombo:keyCombo];
[hotKey setTarget:self];
[hotKey setAction:@selector(beginQuickCursorEdit:)];
[hotKeyCenter registerHotKey:hotKey];
[registeredHotKeys addObject:hotKey];
}
}
}

- (NSArray *)validatedEditorMenuItems:(SEL)action {
static NSArray *cachedMenuItems = nil;

Expand Down Expand Up @@ -81,6 +58,29 @@ - (NSArray *)validatedEditorMenuItems:(SEL)action {
return results;
}

- (void)updateHotKeys {
PTHotKeyCenter *hotKeyCenter = [PTHotKeyCenter sharedCenter];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

for (PTHotKey *each in registeredHotKeys) {
[hotKeyCenter unregisterHotKey:each];
}

[registeredHotKeys removeAllObjects];

for (NSMenuItem *each in [self validatedEditorMenuItems:NULL]) {
id eachKeyComboPlist = [userDefaults objectForKey:[each representedObject]];
if (eachKeyComboPlist) {
PTKeyCombo *keyCombo = [[[PTKeyCombo alloc] initWithPlistRepresentation:eachKeyComboPlist] autorelease];
PTHotKey *hotKey = [[PTHotKey alloc] initWithIdentifier:[each representedObject] keyCombo:keyCombo];
[hotKey setTarget:self];
[hotKey setAction:@selector(beginQuickCursorEdit:)];
[hotKeyCenter registerHotKey:hotKey];
[registeredHotKeys addObject:hotKey];
}
}
}

- (BOOL)validateMenuItem:(NSMenuItem *)anItem {
if ([anItem action] == @selector(beginQuickCursorEdit:)) {
id keyComboPlist = [[NSUserDefaults standardUserDefaults] objectForKey:[anItem representedObject]];
Expand Down Expand Up @@ -119,8 +119,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
registeredHotKeys = [[NSMutableArray alloc] init];

if (!AXAPIEnabled()) {
NSString *message = BLocalizedString(@"QuickCursor requires that the Accessibility API be enabled. Would you like to launch System Preferences so that you can turn on \"Enable access for assistive devices\".", nil);
NSUInteger result = NSRunAlertPanel(message, @"", BLocalizedString(@"OK", nil), BLocalizedString(@"Quit QuickCursor", nil), BLocalizedString(@"Cancel", nil));
NSString *message = NSLocalizedString(@"QuickCursor requires that the Accessibility API be enabled. Would you like to launch System Preferences so that you can turn on \"Enable access for assistive devices\".", nil);
NSUInteger result = NSRunAlertPanel(message, @"", NSLocalizedString(@"OK", nil), NSLocalizedString(@"Quit QuickCursor", nil), NSLocalizedString(@"Cancel", nil));

switch (result) {
case NSAlertDefaultReturn:
Expand All @@ -137,35 +137,33 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSImage *image = [NSImage imageNamed:@"StatusItemIcon"];
[image setTemplate:YES];
[quickCursorStatusItem setImage:image];
[quickCursorStatusItem setTarget:self];
[quickCursorStatusItem setAction:@selector(beginQuickCursorEdit:)];
[quickCursorStatusItem setHighlightMode:YES];

NSMenu *quickCursorMenu = [[[NSMenu alloc] init] autorelease];

[quickCursorMenu addItemWithTitle:BLocalizedString(@"Edit In...", nil) action:NULL keyEquivalent:@""];
[quickCursorMenu addItemWithTitle:NSLocalizedString(@"Edit In...", nil) action:NULL keyEquivalent:@""];

for (NSMenuItem *each in [self validatedEditorMenuItems:@selector(beginQuickCursorEdit:)]) {
[quickCursorMenu addItem:each];
}

[quickCursorMenu addItem:[NSMenuItem separatorItem]];

NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"About", nil) action:@selector(showAbout:) keyEquivalent:@""] autorelease];
NSMenuItem *aboutMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"About", nil) action:@selector(showAbout:) keyEquivalent:@""] autorelease];
[aboutMenuItem setTarget:self];
[quickCursorMenu addItem:aboutMenuItem];

NSMenuItem *preferencesMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"Preferences...", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease];
NSMenuItem *preferencesMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Preferences...", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease];
[preferencesMenuItem setTarget:self];
[quickCursorMenu addItem:preferencesMenuItem];

NSMenuItem *helpMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"QuickCursor Help", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease];
NSMenuItem *helpMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"QuickCursor Help", nil) action:@selector(showPreferences:) keyEquivalent:@""] autorelease];
[helpMenuItem setTarget:self];
[quickCursorMenu addItem:helpMenuItem];

[quickCursorMenu addItem:[NSMenuItem separatorItem]];

NSMenuItem *quitMenuItem = [[[NSMenuItem alloc] initWithTitle:BLocalizedString(@"Quit", nil) action:@selector(terminate:) keyEquivalent:@""] autorelease];
NSMenuItem *quitMenuItem = [[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Quit", nil) action:@selector(terminate:) keyEquivalent:@""] autorelease];
[quitMenuItem setTarget:NSApp];
[quickCursorMenu addItem:quitMenuItem];

Expand Down Expand Up @@ -232,11 +230,11 @@ - (IBAction)beginQuickCursorEdit:(id)sender {
[[ODBEditor sharedODBEditor] setEditorBundleIdentifier:bundleID];
[[ODBEditor sharedODBEditor] editString:value options:[NSDictionary dictionaryWithObject:editorCustomPath forKey:ODBEditorCustomPathKey] forClient:self context:context];
} else {
[[NSAlert alertWithMessageText:BLocalizedString(@"Could not edit text", nil)
defaultButton:BLocalizedString(@"OK", nil)
[[NSAlert alertWithMessageText:NSLocalizedString(@"Could not edit text", nil)
defaultButton:NSLocalizedString(@"OK", nil)
alternateButton:nil
otherButton:nil
informativeTextWithFormat:BLocalizedString(@"QuickCursor could not find any text to edit. Make sure that a text view has keyboard focus, and then try again.", nil)] runModal];
informativeTextWithFormat:NSLocalizedString(@"QuickCursor could not find any text to edit. Make sure that a text view has keyboard focus, and then try again.", nil)] runModal];
}
}

Expand Down
1 change: 0 additions & 1 deletion QCUIElement.h
Expand Up @@ -7,7 +7,6 @@
//

#import <Cocoa/Cocoa.h>
#import <Blocks/Blocks.h>


@interface QCUIElement : NSObject {
Expand Down

0 comments on commit 85a2ee8

Please sign in to comment.