adium 3059:7e6ad9edf243: Replace PTHotKeys with SGHotKeysLib. F...
commits at adium.im
commits at adium.im
Tue Dec 22 21:21:14 UTC 2009
details: http://hg.adium.im/adium/rev/7e6ad9edf243
revision: 3059:7e6ad9edf243
author: Stephen Holt <sholt at adium.im>
date: Tue Dec 22 16:21:10 2009 -0500
Replace PTHotKeys with SGHotKeysLib. Fixes #13467.
diffs (truncated from 1820 to 1000 lines):
diff -r cd626ae329ae -r 7e6ad9edf243 Adium.xcodeproj/project.pbxproj
--- a/Adium.xcodeproj/project.pbxproj Tue Dec 22 15:45:14 2009 -0500
+++ b/Adium.xcodeproj/project.pbxproj Tue Dec 22 16:21:10 2009 -0500
@@ -313,9 +313,9 @@
342F88C00A2A74D50001DB29 /* SRRecorderControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88B40A2A74D40001DB29 /* SRRecorderControl.m */; };
342F88C20A2A74D50001DB29 /* SRCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88B60A2A74D40001DB29 /* SRCommon.m */; };
342F88C40A2A74D50001DB29 /* SRRecorderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88B80A2A74D40001DB29 /* SRRecorderCell.m */; };
- 342F88CF0A2A74EB0001DB29 /* PTKeyCombo.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88C90A2A74EA0001DB29 /* PTKeyCombo.m */; };
- 342F88D10A2A74EB0001DB29 /* PTHotKeyCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88CB0A2A74EA0001DB29 /* PTHotKeyCenter.m */; };
- 342F88D30A2A74EB0001DB29 /* PTHotKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88CD0A2A74EB0001DB29 /* PTHotKey.m */; };
+ 342F88CF0A2A74EB0001DB29 /* SGKeyCombo.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88C90A2A74EA0001DB29 /* SGKeyCombo.m */; };
+ 342F88D10A2A74EB0001DB29 /* SGHotKeyCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88CB0A2A74EA0001DB29 /* SGHotKeyCenter.m */; };
+ 342F88D30A2A74EB0001DB29 /* SGHotKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 342F88CD0A2A74EB0001DB29 /* SGHotKey.m */; };
3430222A0AB4766E0082CF7C /* AINulRemovalPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 343022280AB4766E0082CF7C /* AINulRemovalPlugin.m */; };
343700A70A9C1E170028604E /* AIAdvancedPreferencePane.h in Headers */ = {isa = PBXBuildFile; fileRef = 343700A50A9C1E170028604E /* AIAdvancedPreferencePane.h */; settings = {ATTRIBUTES = (Public, ); }; };
343700A80A9C1E170028604E /* AIAdvancedPreferencePane.m in Sources */ = {isa = PBXBuildFile; fileRef = 343700A60A9C1E170028604E /* AIAdvancedPreferencePane.m */; };
@@ -1176,7 +1176,7 @@
6329EF000F9D333B00112489 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6329EEFF0F9D333B00112489 /* CoreFoundation.framework */; };
6329EF040F9D334D00112489 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6329EF030F9D334D00112489 /* Foundation.framework */; };
6329EF080F9D335800112489 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6329EF070F9D335800112489 /* CoreServices.framework */; };
- 632ADC150E9EDDCA00AB6817 /* PTKeyCodeTranslator.m in Sources */ = {isa = PBXBuildFile; fileRef = 632ADC130E9EDDCA00AB6817 /* PTKeyCodeTranslator.m */; };
+ 632ADC150E9EDDCA00AB6817 /* SGKeyCodeTranslator.m in Sources */ = {isa = PBXBuildFile; fileRef = 632ADC130E9EDDCA00AB6817 /* SGKeyCodeTranslator.m */; };
632D60C1094B81AB003A9786 /* AIDockIconPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 632D60BF094B81AB003A9786 /* AIDockIconPreviewController.m */; };
632D801708E7E0A40032C187 /* XtrasManager.nib in Resources */ = {isa = PBXBuildFile; fileRef = 632D801608E7E0A40032C187 /* XtrasManager.nib */; };
632D859E0DB70FC800040EC7 /* AIMentionEventPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 632D859D0DB70FC800040EC7 /* AIMentionEventPlugin.m */; };
@@ -2467,12 +2467,12 @@
342F88B70A2A74D40001DB29 /* SRKeyCodeTransformer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SRKeyCodeTransformer.h; path = Frameworks/ShortcutRecorder/Source/SRKeyCodeTransformer.h; sourceTree = "<group>"; };
342F88B80A2A74D40001DB29 /* SRRecorderCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SRRecorderCell.m; path = Frameworks/ShortcutRecorder/Source/SRRecorderCell.m; sourceTree = "<group>"; };
342F88B90A2A74D40001DB29 /* SRRecorderCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SRRecorderCell.h; path = Frameworks/ShortcutRecorder/Source/SRRecorderCell.h; sourceTree = "<group>"; };
- 342F88C90A2A74EA0001DB29 /* PTKeyCombo.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PTKeyCombo.m; path = Source/PTKeyCombo.m; sourceTree = "<group>"; };
- 342F88CA0A2A74EA0001DB29 /* PTKeyCombo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTKeyCombo.h; path = Source/PTKeyCombo.h; sourceTree = "<group>"; };
- 342F88CB0A2A74EA0001DB29 /* PTHotKeyCenter.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PTHotKeyCenter.m; path = Source/PTHotKeyCenter.m; sourceTree = "<group>"; };
- 342F88CC0A2A74EA0001DB29 /* PTHotKeyCenter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTHotKeyCenter.h; path = Source/PTHotKeyCenter.h; sourceTree = "<group>"; };
- 342F88CD0A2A74EB0001DB29 /* PTHotKey.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PTHotKey.m; path = Source/PTHotKey.m; sourceTree = "<group>"; };
- 342F88CE0A2A74EB0001DB29 /* PTHotKey.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTHotKey.h; path = Source/PTHotKey.h; sourceTree = "<group>"; };
+ 342F88C90A2A74EA0001DB29 /* SGKeyCombo.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SGKeyCombo.m; path = Source/SGKeyCombo.m; sourceTree = "<group>"; };
+ 342F88CA0A2A74EA0001DB29 /* SGKeyCombo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SGKeyCombo.h; path = Source/SGKeyCombo.h; sourceTree = "<group>"; };
+ 342F88CB0A2A74EA0001DB29 /* SGHotKeyCenter.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SGHotKeyCenter.m; path = Source/SGHotKeyCenter.m; sourceTree = "<group>"; };
+ 342F88CC0A2A74EA0001DB29 /* SGHotKeyCenter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SGHotKeyCenter.h; path = Source/SGHotKeyCenter.h; sourceTree = "<group>"; };
+ 342F88CD0A2A74EB0001DB29 /* SGHotKey.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = SGHotKey.m; path = Source/SGHotKey.m; sourceTree = "<group>"; };
+ 342F88CE0A2A74EB0001DB29 /* SGHotKey.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = SGHotKey.h; path = Source/SGHotKey.h; sourceTree = "<group>"; };
342F9E520B552627000D5FC2 /* fi */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = fi; path = "Plugins/WebKit Message View/fi.lproj/WebKitPreferencesView.nib"; sourceTree = "<group>"; };
342F9E530B552627000D5FC2 /* fi */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = fi; path = Resources/fi.lproj/StatusSortConfiguration.nib; sourceTree = "<group>"; };
342F9E540B552627000D5FC2 /* fi */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = fi; path = Resources/fi.lproj/StatusPreferences.nib; sourceTree = "<group>"; };
@@ -4219,8 +4219,8 @@
6329EEFF0F9D333B00112489 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
6329EF030F9D334D00112489 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
6329EF070F9D335800112489 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
- 632ADC130E9EDDCA00AB6817 /* PTKeyCodeTranslator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PTKeyCodeTranslator.m; path = Source/PTKeyCodeTranslator.m; sourceTree = "<group>"; };
- 632ADC140E9EDDCA00AB6817 /* PTKeyCodeTranslator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PTKeyCodeTranslator.h; path = Source/PTKeyCodeTranslator.h; sourceTree = "<group>"; };
+ 632ADC130E9EDDCA00AB6817 /* SGKeyCodeTranslator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SGKeyCodeTranslator.m; path = Source/SGKeyCodeTranslator.m; sourceTree = "<group>"; };
+ 632ADC140E9EDDCA00AB6817 /* SGKeyCodeTranslator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SGKeyCodeTranslator.h; path = Source/SGKeyCodeTranslator.h; sourceTree = "<group>"; };
632D608D094B7EEB003A9786 /* AIXtraPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AIXtraPreviewController.h; path = Source/AIXtraPreviewController.h; sourceTree = "<group>"; };
632D60BE094B81AB003A9786 /* AIDockIconPreviewController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AIDockIconPreviewController.h; path = Source/AIDockIconPreviewController.h; sourceTree = "<group>"; };
632D60BF094B81AB003A9786 /* AIDockIconPreviewController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = AIDockIconPreviewController.m; path = Source/AIDockIconPreviewController.m; sourceTree = "<group>"; };
@@ -8348,14 +8348,14 @@
83B920F809E70778008D8436 /* Hot Key */ = {
isa = PBXGroup;
children = (
- 342F88CE0A2A74EB0001DB29 /* PTHotKey.h */,
- 342F88CD0A2A74EB0001DB29 /* PTHotKey.m */,
- 342F88CC0A2A74EA0001DB29 /* PTHotKeyCenter.h */,
- 342F88CB0A2A74EA0001DB29 /* PTHotKeyCenter.m */,
- 342F88CA0A2A74EA0001DB29 /* PTKeyCombo.h */,
- 342F88C90A2A74EA0001DB29 /* PTKeyCombo.m */,
- 632ADC130E9EDDCA00AB6817 /* PTKeyCodeTranslator.m */,
- 632ADC140E9EDDCA00AB6817 /* PTKeyCodeTranslator.h */,
+ 342F88CE0A2A74EB0001DB29 /* SGHotKey.h */,
+ 342F88CD0A2A74EB0001DB29 /* SGHotKey.m */,
+ 342F88CC0A2A74EA0001DB29 /* SGHotKeyCenter.h */,
+ 342F88CB0A2A74EA0001DB29 /* SGHotKeyCenter.m */,
+ 342F88CA0A2A74EA0001DB29 /* SGKeyCombo.h */,
+ 342F88C90A2A74EA0001DB29 /* SGKeyCombo.m */,
+ 632ADC140E9EDDCA00AB6817 /* SGKeyCodeTranslator.h */,
+ 632ADC130E9EDDCA00AB6817 /* SGKeyCodeTranslator.m */,
342F88B30A2A74D40001DB29 /* SRCommon.h */,
342F88B60A2A74D40001DB29 /* SRCommon.m */,
347374BB0AA9206B00AD18E3 /* ShortcutRecorder.strings */,
@@ -10483,9 +10483,9 @@
342F88C00A2A74D50001DB29 /* SRRecorderControl.m in Sources */,
342F88C20A2A74D50001DB29 /* SRCommon.m in Sources */,
342F88C40A2A74D50001DB29 /* SRRecorderCell.m in Sources */,
- 342F88CF0A2A74EB0001DB29 /* PTKeyCombo.m in Sources */,
- 342F88D10A2A74EB0001DB29 /* PTHotKeyCenter.m in Sources */,
- 342F88D30A2A74EB0001DB29 /* PTHotKey.m in Sources */,
+ 342F88CF0A2A74EB0001DB29 /* SGKeyCombo.m in Sources */,
+ 342F88D10A2A74EB0001DB29 /* SGHotKeyCenter.m in Sources */,
+ 342F88D30A2A74EB0001DB29 /* SGHotKey.m in Sources */,
3456231C0A3771D800E7FC97 /* ESRankingCell.m in Sources */,
345623200A3771E100E7FC97 /* AIChatLog.m in Sources */,
3456232A0A3771F400E7FC97 /* AILogToGroup.m in Sources */,
@@ -10593,7 +10593,7 @@
34A1AB6C0DFC531000AC78CF /* AIXMLChatlogConverter.m in Sources */,
34A1B2C30DFDBA1200AC78CF /* AIStringDebug.m in Sources */,
111DDF3A0E8E7D2F00114FCA /* AIAutomaticStatus.m in Sources */,
- 632ADC150E9EDDCA00AB6817 /* PTKeyCodeTranslator.m in Sources */,
+ 632ADC150E9EDDCA00AB6817 /* SGKeyCodeTranslator.m in Sources */,
5A1781860EC1215D00BA1E04 /* AIAutoScrollTextView.m in Sources */,
11F738F20F58D12200B3285B /* AITwitterAccount.m in Sources */,
11F738F90F58D18700B3285B /* AITwitterService.m in Sources */,
diff -r cd626ae329ae -r 7e6ad9edf243 Frameworks/ShortcutRecorder/Source/SRKeyCodeTransformer.m
--- a/Frameworks/ShortcutRecorder/Source/SRKeyCodeTransformer.m Tue Dec 22 15:45:14 2009 -0500
+++ b/Frameworks/ShortcutRecorder/Source/SRKeyCodeTransformer.m Tue Dec 22 16:21:10 2009 -0500
@@ -13,7 +13,7 @@
#import "SRKeyCodeTransformer.h"
#import "SRCommon.h"
-#import "PTKeyCodeTranslator.h"
+#import "SGKeyCodeTranslator.h"
static NSMutableDictionary *stringToKeyCodeDict = nil;
static NSDictionary *keyCodeToStringDict = nil;
@@ -132,7 +132,7 @@
NSString *unmappedString = [keyCodeToStringDict objectForKey: SRInt( keyCode )];
if ( unmappedString != nil ) return unmappedString;
- return [[PTKeyCodeTranslator currentTranslator] translateKeyCode:keyCode];
+ return [[SGKeyCodeTranslator currentTranslator] translateKeyCode:keyCode];
}
//----------------------------------------------------------
diff -r cd626ae329ae -r 7e6ad9edf243 Frameworks/ShortcutRecorder/Source/SRRecorderCell.m
--- a/Frameworks/ShortcutRecorder/Source/SRRecorderCell.m Tue Dec 22 15:45:14 2009 -0500
+++ b/Frameworks/ShortcutRecorder/Source/SRRecorderCell.m Tue Dec 22 16:21:10 2009 -0500
@@ -1195,7 +1195,7 @@
NSDictionary *defaultsValue = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithShort: keyCombo.code], @"keyCode",
[NSNumber numberWithUnsignedInt: keyCombo.flags], @"modifierFlags", // cocoa
- [NSNumber numberWithUnsignedInt: SRCocoaToCarbonFlags(keyCombo.flags)], @"modifiers", // carbon, for compatibility with PTKeyCombo
+ [NSNumber numberWithUnsignedInt: SRCocoaToCarbonFlags(keyCombo.flags)], @"modifiers", // carbon, for compatibility with SGKeyCombo
nil];
if (hasKeyChars) {
@@ -1222,7 +1222,7 @@
signed short keyCode = [[savedCombo valueForKey: @"keyCode"] shortValue];
unsigned int flags;
- if ((nil == [savedCombo valueForKey:@"modifierFlags"]) && (nil != [savedCombo valueForKey:@"modifiers"])) { // carbon, for compatibility with PTKeyCombo
+ if ((nil == [savedCombo valueForKey:@"modifierFlags"]) && (nil != [savedCombo valueForKey:@"modifiers"])) { // carbon, for compatibility with SGKeyCombo
flags = SRCarbonToCocoaFlags([[savedCombo valueForKey: @"modifiers"] unsignedIntValue]);
} else { // cocoa
flags = [[savedCombo valueForKey: @"modifierFlags"] unsignedIntValue];
diff -r cd626ae329ae -r 7e6ad9edf243 Plugins/General Preferences/ESGeneralPreferences.m
--- a/Plugins/General Preferences/ESGeneralPreferences.m Tue Dec 22 15:45:14 2009 -0500
+++ b/Plugins/General Preferences/ESGeneralPreferences.m Tue Dec 22 16:21:10 2009 -0500
@@ -19,10 +19,10 @@
#import "AISoundController.h"
#import "ESGeneralPreferences.h"
#import "ESGeneralPreferencesPlugin.h"
-#import "PTHotKeyCenter.h"
-#import "PTHotKey.h"
+#import "SGHotKeyCenter.h"
+#import "SGHotKey.h"
#import "SRRecorderControl.h"
-#import "PTHotKey.h"
+#import "SGHotKey.h"
#import "AIMessageHistoryPreferencesWindowController.h"
#import "AIMessageWindowController.h"
#import <Adium/AIServiceIcons.h>
@@ -115,7 +115,7 @@
TISInputSourceRef currentLayout = TISCopyCurrentKeyboardLayoutInputSource();
if (TISGetInputSourceProperty(currentLayout, kTISPropertyUnicodeKeyLayoutData)) {
- PTKeyCombo *keyCombo = [[[PTKeyCombo alloc] initWithPlistRepresentation:[adium.preferenceController preferenceForKey:KEY_GENERAL_HOTKEY
+ SGKeyCombo *keyCombo = [[[SGKeyCombo alloc] initWithPlistRepresentation:[adium.preferenceController preferenceForKey:KEY_GENERAL_HOTKEY
group:PREF_GROUP_GENERAL]] autorelease];
[shortcutRecorder setKeyCombo:SRMakeKeyCombo([keyCombo keyCode], [shortcutRecorder carbonToCocoaFlags:[keyCombo modifiers]])];
[shortcutRecorder setAnimates:YES];
@@ -231,7 +231,7 @@
- (void)shortcutRecorder:(SRRecorderControl *)aRecorder keyComboDidChange:(KeyCombo)newKeyCombo
{
if (aRecorder == shortcutRecorder) {
- PTKeyCombo *keyCombo = [PTKeyCombo keyComboWithKeyCode:[shortcutRecorder keyCombo].code
+ SGKeyCombo *keyCombo = [SGKeyCombo keyComboWithKeyCode:[shortcutRecorder keyCombo].code
modifiers:[shortcutRecorder cocoaToCarbonFlags:[shortcutRecorder keyCombo].flags]];
[adium.preferenceController setPreference:[keyCombo plistRepresentation]
forKey:KEY_GENERAL_HOTKEY
diff -r cd626ae329ae -r 7e6ad9edf243 Plugins/General Preferences/ESGeneralPreferencesPlugin.h
--- a/Plugins/General Preferences/ESGeneralPreferencesPlugin.h Tue Dec 22 15:45:14 2009 -0500
+++ b/Plugins/General Preferences/ESGeneralPreferencesPlugin.h Tue Dec 22 16:21:10 2009 -0500
@@ -45,12 +45,12 @@
#define KEY_GENERAL_HOTKEY @"General Hot Key"
- at class PTHotKey;
+ at class SGHotKey;
@interface ESGeneralPreferencesPlugin : AIPlugin {
ESGeneralPreferences *preferences;
- PTHotKey *globalHotKey;
+ SGHotKey *globalHotKey;
}
@end
diff -r cd626ae329ae -r 7e6ad9edf243 Plugins/General Preferences/ESGeneralPreferencesPlugin.m
--- a/Plugins/General Preferences/ESGeneralPreferencesPlugin.m Tue Dec 22 15:45:14 2009 -0500
+++ b/Plugins/General Preferences/ESGeneralPreferencesPlugin.m Tue Dec 22 16:21:10 2009 -0500
@@ -37,8 +37,8 @@
#import <Adium/AIServiceIcons.h>
#import <Adium/AIStatusIcons.h>
-#import "PTHotKey.h"
-#import "PTHotKeyCenter.h"
+#import "SGHotKey.h"
+#import "SGHotKeyCenter.h"
#define TAB_DEFAULT_PREFS @"TabDefaults"
@@ -74,7 +74,7 @@
}
-- (void)hitHotKey:(PTHotKey *)hotKey
+- (void)hitHotKey:(SGHotKey *)hotKey
{
if (![NSApp isActive]) {
[NSApp activateIgnoringOtherApps:YES];
@@ -93,20 +93,20 @@
if (firstTime || [key isEqualToString:KEY_GENERAL_HOTKEY]) {
if (globalHotKey) {
//Unregister the old global hot key if it exists
- [[PTHotKeyCenter sharedCenter] unregisterHotKey:globalHotKey];
+ [[SGHotKeyCenter sharedCenter] unregisterHotKey:globalHotKey];
[globalHotKey release]; globalHotKey = nil;
}
id plistRepresentation = [prefDict objectForKey:KEY_GENERAL_HOTKEY];
if (plistRepresentation) {
//Register a new one if we want one
- globalHotKey = [[PTHotKey alloc] initWithIdentifier:KEY_GENERAL_HOTKEY
- keyCombo:[[[PTKeyCombo alloc] initWithPlistRepresentation:plistRepresentation] autorelease]];
+ globalHotKey = [[SGHotKey alloc] initWithIdentifier:KEY_GENERAL_HOTKEY
+ keyCombo:[[[SGKeyCombo alloc] initWithPlistRepresentation:plistRepresentation] autorelease]];
[globalHotKey setTarget:self];
[globalHotKey setAction:@selector(hitHotKey:)];
- [[PTHotKeyCenter sharedCenter] registerHotKey:globalHotKey];
+ [[SGHotKeyCenter sharedCenter] registerHotKey:globalHotKey];
}
}
}
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTHotKey.h
--- a/Source/PTHotKey.h Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-//
-// PTHotKey.h
-// Protein
-//
-// Created by Quentin Carnicelli on Sat Aug 02 2003.
-// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-#import "PTKeyCombo.h"
-
- at interface PTHotKey : NSObject
-{
- NSString* mIdentifier;
- NSString* mName;
- PTKeyCombo* mKeyCombo;
- id mTarget;
- SEL mAction;
-}
-
-- (id)initWithIdentifier: (id)identifier keyCombo: (PTKeyCombo*)combo;
-- (id)init;
-
-- (void)setIdentifier: (id)ident;
-- (id)identifier;
-
-- (void)setName: (NSString*)name;
-- (NSString*)name;
-
-- (void)setKeyCombo: (PTKeyCombo*)combo;
-- (PTKeyCombo*)keyCombo;
-
-- (void)setTarget: (id)target;
-- (id)target;
-- (void)setAction: (SEL)action;
-- (SEL)action;
-
-- (void)invoke;
-
- at end
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTHotKey.m
--- a/Source/PTHotKey.m Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-//
-// PTHotKey.m
-// Protein
-//
-// Created by Quentin Carnicelli on Sat Aug 02 2003.
-// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
-//
-
-#import "PTHotKey.h"
-
-#import "PTHotKeyCenter.h"
-#import "PTKeyCombo.h"
-
- at implementation PTHotKey
-
-- (id)init
-{
- return [self initWithIdentifier: nil keyCombo: nil];
-}
-
-
-- (id)initWithIdentifier: (id)identifier keyCombo: (PTKeyCombo*)combo
-{
- self = [super init];
-
- if( self )
- {
- [self setIdentifier: identifier];
- [self setKeyCombo: combo];
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [mIdentifier release];
- [mName release];
- [mKeyCombo release];
-
- [super dealloc];
-}
-
-- (NSString*)description
-{
- return [NSString stringWithFormat: @"<%@: %@, %@>", NSStringFromClass( [self class] ), [self identifier], [self keyCombo]];
-}
-
-#pragma mark -
-
-- (void)setIdentifier: (id)ident
-{
- [ident retain];
- [mIdentifier release];
- mIdentifier = ident;
-}
-
-- (id)identifier
-{
- return mIdentifier;
-}
-
-- (void)setKeyCombo: (PTKeyCombo*)combo
-{
- if( combo == nil )
- combo = [PTKeyCombo clearKeyCombo];
-
- [combo retain];
- [mKeyCombo release];
- mKeyCombo = combo;
-}
-
-- (PTKeyCombo*)keyCombo
-{
- return mKeyCombo;
-}
-
-- (void)setName: (NSString*)name
-{
- [name retain];
- [mName release];
- mName = name;
-}
-
-- (NSString*)name
-{
- return mName;
-}
-
-- (void)setTarget: (id)target
-{
- mTarget = target;
-}
-
-- (id)target
-{
- return mTarget;
-}
-
-- (void)setAction: (SEL)action
-{
- mAction = action;
-}
-
-- (SEL)action
-{
- return mAction;
-}
-
-- (void)invoke
-{
- [mTarget performSelector: mAction withObject: self];
-}
-
- at end
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTHotKeyCenter.h
--- a/Source/PTHotKeyCenter.h Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-//
-// PTHotKeyCenter.h
-// Protein
-//
-// Created by Quentin Carnicelli on Sat Aug 02 2003.
-// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
-//
-// Contributers:
-// Quentin D. Carnicelli
-// Finlay Dobbie
-// Vincent Pottier
-
- at class PTHotKey;
-
- at interface PTHotKeyCenter : NSObject
-{
- NSMutableDictionary* mHotKeys; //Keys are NSValue of EventHotKeyRef
- BOOL mEventHandlerInstalled;
-}
-
-+ (PTHotKeyCenter*)sharedCenter;
-
-- (BOOL)registerHotKey: (PTHotKey*)hotKey;
-- (void)unregisterHotKey: (PTHotKey*)hotKey;
-
-- (NSArray*)allHotKeys;
-- (PTHotKey*)hotKeyWithIdentifier: (id)ident;
-
- at end
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTHotKeyCenter.m
--- a/Source/PTHotKeyCenter.m Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-//
-// PTHotKeyCenter.m
-// Protein
-//
-// Created by Quentin Carnicelli on Sat Aug 02 2003.
-// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
-//
-
-#import "PTHotKeyCenter.h"
-#import "PTHotKey.h"
-#import "PTKeyCombo.h"
-#import <Carbon/Carbon.h>
-
-#if __PROTEIN__
-#import "PTNSObjectAdditions.h"
-#endif
-
- at interface PTHotKeyCenter ()
-- (PTHotKey*)_hotKeyForCarbonHotKey: (EventHotKeyRef)carbonHotKey;
-- (EventHotKeyRef)_carbonHotKeyForHotKey: (PTHotKey*)hotKey;
-
-- (void)_updateEventHandler;
-- (void)_hotKeyDown: (PTHotKey*)hotKey;
-- (void)_hotKeyUp: (PTHotKey*)hotKey;
-static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void* refCon );
- at end
-
- at implementation PTHotKeyCenter
-
-static PTHotKeyCenter* _sharedHotKeyCenter = nil;
-
-+ (PTHotKeyCenter*)sharedCenter
-{
- if( _sharedHotKeyCenter == nil )
- {
- _sharedHotKeyCenter = [[self alloc] init];
- #if __PROTEIN__
- [_sharedHotKeyCenter releaseOnTerminate];
- #endif
- }
-
- return _sharedHotKeyCenter;
-}
-
-- (id)init
-{
- self = [super init];
-
- if( self )
- {
- mHotKeys = [[NSMutableDictionary alloc] init];
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- [mHotKeys release];
- [super dealloc];
-}
-
-#pragma mark -
-
-- (BOOL)registerHotKey: (PTHotKey*)hotKey
-{
- OSStatus err;
- EventHotKeyID hotKeyID;
- EventHotKeyRef carbonHotKey;
- NSValue* key;
-
- if( [[self allHotKeys] containsObject: hotKey] == YES )
- [self unregisterHotKey: hotKey];
-
- if( [[hotKey keyCombo] isValidHotKeyCombo] == NO )
- return YES;
-
- hotKeyID.signature = 'PTHk';
- hotKeyID.id = (long)hotKey;
-
- err = RegisterEventHotKey( [[hotKey keyCombo] keyCode],
- [[hotKey keyCombo] modifiers],
- hotKeyID,
- GetEventDispatcherTarget(),
- 0,
- &carbonHotKey );
-
- if( err )
- return NO;
-
- key = [NSValue valueWithPointer: carbonHotKey];
- if( hotKey && key )
- [mHotKeys setObject: hotKey forKey: key];
-
- [self _updateEventHandler];
-
- return YES;
-}
-
-- (void)unregisterHotKey: (PTHotKey*)hotKey
-{
- OSStatus err;
- EventHotKeyRef carbonHotKey;
- NSValue* key;
-
- if( [[self allHotKeys] containsObject: hotKey] == NO )
- return;
-
- carbonHotKey = [self _carbonHotKeyForHotKey: hotKey];
- NSAssert( carbonHotKey != nil, @"" );
-
- err = UnregisterEventHotKey( carbonHotKey );
- //Watch as we ignore 'err':
-
- key = [NSValue valueWithPointer: carbonHotKey];
- [mHotKeys removeObjectForKey: key];
-
- [self _updateEventHandler];
-
- //See that? Completely ignored
-}
-
-- (NSArray*)allHotKeys
-{
- return [mHotKeys allValues];
-}
-
-- (PTHotKey*)hotKeyWithIdentifier: (id)ident
-{
- NSEnumerator* hotKeysEnum = [[self allHotKeys] objectEnumerator];
- PTHotKey* hotKey;
-
- if( !ident )
- return nil;
-
- while( (hotKey = [hotKeysEnum nextObject]) != nil )
- {
- if( [[hotKey identifier] isEqual: ident] )
- return hotKey;
- }
-
- return nil;
-}
-
-#pragma mark -
-
-- (PTHotKey*)_hotKeyForCarbonHotKey: (EventHotKeyRef)carbonHotKey
-{
- NSValue* key = [NSValue valueWithPointer: carbonHotKey];
- return [mHotKeys objectForKey: key];
-}
-
-- (EventHotKeyRef)_carbonHotKeyForHotKey: (PTHotKey*)hotKey
-{
- NSArray* values;
- NSValue* value;
-
- values = [mHotKeys allKeysForObject: hotKey];
- NSAssert( [values count] == 1, @"Failed to find Carbon Hotkey for PTHotKey" );
-
- value = [values lastObject];
-
- return (EventHotKeyRef)[value pointerValue];
-}
-
-- (void)_updateEventHandler
-{
- if( [mHotKeys count] && mEventHandlerInstalled == NO )
- {
- EventTypeSpec eventSpec[2] = {
- { kEventClassKeyboard, kEventHotKeyPressed },
- { kEventClassKeyboard, kEventHotKeyReleased }
- };
-
- InstallEventHandler( GetEventDispatcherTarget(),
- (EventHandlerProcPtr)hotKeyEventHandler,
- 2, eventSpec, nil, nil);
-
- mEventHandlerInstalled = YES;
- }
-}
-
-- (void)_hotKeyDown: (PTHotKey*)hotKey
-{
- [hotKey invoke];
-}
-
-- (void)_hotKeyUp: (PTHotKey*)hotKey
-{
-}
-
-- (OSStatus)sendCarbonEvent: (EventRef)event
-{
- OSStatus err;
- EventHotKeyID hotKeyID;
- PTHotKey* hotKey;
-
- NSAssert( GetEventClass( event ) == kEventClassKeyboard, @"Unknown event class" );
-
- err = GetEventParameter( event,
- kEventParamDirectObject,
- typeEventHotKeyID,
- nil,
- sizeof(EventHotKeyID),
- nil,
- &hotKeyID );
- if( err )
- return err;
-
-
- NSAssert( hotKeyID.signature == 'PTHk', @"Invalid hot key id" );
- NSAssert( hotKeyID.id != 0, @"Invalid hot key id" );
-
- hotKey = (PTHotKey*)hotKeyID.id;
-
- switch( GetEventKind( event ) )
- {
- case kEventHotKeyPressed:
- [self _hotKeyDown: hotKey];
- break;
-
- case kEventHotKeyReleased:
- [self _hotKeyUp: hotKey];
- break;
-
- default:
- NSAssert( 0, @"Unknown event kind" );
- break;
- }
-
- return noErr;
-}
-
-static OSStatus hotKeyEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void* refCon )
-{
- return [[PTHotKeyCenter sharedCenter] sendCarbonEvent: inEvent];
-}
-
- at end
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTKeyCodeTranslator.h
--- a/Source/PTKeyCodeTranslator.h Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-//
-// PTKeyCodeTranslator.h
-// Chercher
-//
-// Created by Finlay Dobbie on Sat Oct 11 2003.
-// Copyright (c) 2003 Cliché Software. All rights reserved.
-//
-
-#import <Carbon/Carbon.h>
-
- at interface PTKeyCodeTranslator : NSObject
-{
- TISInputSourceRef keyboardLayout;
- const UCKeyboardLayout *uchrData;
- UInt32 keyTranslateState;
- UInt32 deadKeyState;
-}
-
-+ (id)currentTranslator;
-
-- (id)initWithKeyboardLayout:(TISInputSourceRef)aLayout;
-- (NSString *)translateKeyCode:(short)keyCode;
-
-- (TISInputSourceRef)keyboardLayout;
-
- at end
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTKeyCodeTranslator.m
--- a/Source/PTKeyCodeTranslator.m Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-//
-// PTKeyCodeTranslator.m
-// Chercher
-//
-// Created by Finlay Dobbie on Sat Oct 11 2003.
-// Copyright (c) 2003 Cliché Software. All rights reserved.
-//
-
-#import "PTKeyCodeTranslator.h"
-
-
- at implementation PTKeyCodeTranslator
-
-+ (id)currentTranslator
-{
- static PTKeyCodeTranslator *current = nil;
- TISInputSourceRef currentLayout = TISCopyCurrentKeyboardLayoutInputSource();
-
- if (current == nil) {
- current = [[PTKeyCodeTranslator alloc] initWithKeyboardLayout:currentLayout];
- } else if ([current keyboardLayout] != currentLayout) {
- [current release];
- current = [[PTKeyCodeTranslator alloc] initWithKeyboardLayout:currentLayout];
- }
-
- CFRelease(currentLayout);
-
- return current;
-}
-
-- (id)initWithKeyboardLayout:(TISInputSourceRef)aLayout
-{
- if ((self = [super init]) != nil) {
- keyboardLayout = aLayout;
-
- CFRetain(keyboardLayout);
-
- CFDataRef uchr = TISGetInputSourceProperty( keyboardLayout , kTISPropertyUnicodeKeyLayoutData );
- uchrData = ( const UCKeyboardLayout* )CFDataGetBytePtr(uchr);
- }
-
- return self;
-}
-
-- (void)dealloc
-{
- CFRelease(keyboardLayout);
-
- [super dealloc];
-}
-
-- (NSString *)translateKeyCode:(short)keyCode {
- UniCharCount maxStringLength = 4, actualStringLength;
- UniChar unicodeString[4];
- OSStatus err;
- err = UCKeyTranslate( uchrData, keyCode, kUCKeyActionDisplay, 0, LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, maxStringLength, &actualStringLength, unicodeString );
- return [NSString stringWithCharacters:unicodeString length:1];
-}
-
-- (TISInputSourceRef)keyboardLayout {
- return keyboardLayout;
-}
-
-- (NSString *)description {
- NSString *kind;
- kind = @"uchr";
-
- NSString *layoutName;
- layoutName = TISGetInputSourceProperty( keyboardLayout, kTISPropertyLocalizedName );
- return [NSString stringWithFormat:@"PTKeyCodeTranslator layout=%@ (%@)", layoutName, kind];
-}
-
- at end
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTKeyCombo.h
--- a/Source/PTKeyCombo.h Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-//
-// PTKeyCombo.h
-// Protein
-//
-// Created by Quentin Carnicelli on Sat Aug 02 2003.
-// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-#if __PROTEIN__
-#else
-#define _PTLocalizedString NSLocalizedString
-#endif
-
- at interface PTKeyCombo : NSObject <NSCopying>
-{
- int mKeyCode;
- int mModifiers;
-}
-
-+ (id)clearKeyCombo;
-+ (id)keyComboWithKeyCode: (int)keyCode modifiers: (int)modifiers;
-- (id)initWithKeyCode: (int)keyCode modifiers: (int)modifiers;
-
-- (id)initWithPlistRepresentation: (id)plist;
-- (id)plistRepresentation;
-
-- (BOOL)isEqual: (PTKeyCombo*)combo;
-
-- (int)keyCode;
-- (int)modifiers;
-
-- (BOOL)isClearCombo;
-- (BOOL)isValidHotKeyCombo;
-
- at end
-
- at interface PTKeyCombo (UserDisplayAdditions)
-
-- (NSString*)description;
-- (NSString*)keyCodeString;
-- (NSUInteger)modifierMask;
-
- at end
diff -r cd626ae329ae -r 7e6ad9edf243 Source/PTKeyCombo.m
--- a/Source/PTKeyCombo.m Tue Dec 22 15:45:14 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
-//
-// PTKeyCombo.m
-// Protein
-//
-// Created by Quentin Carnicelli on Sat Aug 02 2003.
-// Copyright (c) 2003 Quentin D. Carnicelli. All rights reserved.
-//
-
-#import "PTKeyCombo.h"
-#import "PTKeyCodeTranslator.h"
-
- at implementation PTKeyCombo
-
-+ (id)clearKeyCombo
-{
- return [self keyComboWithKeyCode: -1 modifiers: -1];
-}
-
-+ (id)keyComboWithKeyCode: (int)keyCode modifiers: (int)modifiers
-{
- return [[[self alloc] initWithKeyCode: keyCode modifiers: modifiers] autorelease];
-}
-
-- (id)initWithKeyCode: (int)keyCode modifiers: (int)modifiers
-{
- self = [super init];
-
- if( self )
- {
- mKeyCode = keyCode;
- mModifiers = modifiers;
- }
-
- return self;
-}
-
-- (id)initWithPlistRepresentation: (id)plist
-{
- int keyCode, modifiers;
-
- if( !plist || ![plist count] )
- {
- keyCode = -1;
- modifiers = -1;
- }
- else
- {
- keyCode = [[plist objectForKey: @"keyCode"] intValue];
- if( keyCode < 0 ) keyCode = -1;
-
- modifiers = [[plist objectForKey: @"modifiers"] intValue];
- if( modifiers <= 0 ) modifiers = -1;
- }
-
- return [self initWithKeyCode: keyCode modifiers: modifiers];
-}
-
-- (id)plistRepresentation
-{
- return [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt: [self keyCode]], @"keyCode",
- [NSNumber numberWithInt: [self modifiers]], @"modifiers",
- nil];
-}
-
-- (id)copyWithZone:(NSZone*)zone;
-{
- return [self retain];
-}
-
-- (BOOL)isEqual: (PTKeyCombo*)combo
-{
- return [self keyCode] == [combo keyCode] &&
- [self modifiers] == [combo modifiers];
-}
-
-#pragma mark -
-
-- (int)keyCode
-{
- return mKeyCode;
-}
-
-- (int)modifiers
-{
- return mModifiers;
-}
-
-- (BOOL)isValidHotKeyCombo
-{
- return mKeyCode >= 0 && mModifiers > 0;
-}
-
-- (BOOL)isClearCombo
-{
- return mKeyCode == -1 && mModifiers == -1;
-}
-
- at end
-
-#pragma mark -
-
- at implementation PTKeyCombo (UserDisplayAdditions)
-
-+ (NSString*)_stringForModifiers: (long)modifiers
-{
- static unichar modToChar[4][2] =
- {
- { cmdKey, kCommandUnicode },
- { optionKey, kOptionUnicode },
- { controlKey, kControlUnicode },
- { shiftKey, kShiftUnicode }
- };
-
- NSString* str = [NSString string];
- long i;
-
- for( i = 0; i < 4; i++ )
- {
- if( modifiers & modToChar[i][0] )
- str = [str stringByAppendingString: [NSString stringWithCharacters: &modToChar[i][1] length: 1]];
- }
-
- return str;
-}
-
-+ (NSDictionary*)_keyCodesDictionary
-{
- static NSDictionary* keyCodes = nil;
-
- if( keyCodes == nil )
- {
- NSURL *url = [NSURL fileURLWithPath:[[NSBundle bundleForClass: self] pathForResource: @"PTKeyCodes" ofType: @"plist"]];
- NSString *contents = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:NULL];
- keyCodes = [[contents propertyList] retain];
- }
-
- return keyCodes;
-}
-
-+ (NSString*)_stringForKeyCode: (short)keyCode legacyKeyCodeMap: (NSDictionary*)dict
-{
- id key;
- NSString* str;
-
- key = [NSString stringWithFormat: @"%d", keyCode];
- str = [dict objectForKey: key];
-
- if( !str )
- str = [NSString stringWithFormat: @"%X", keyCode];
-
- return str;
-}
-
-+ (NSString*)_stringForKeyCode: (short)keyCode newKeyCodeMap: (NSDictionary*)dict
-{
- NSString* result;
More information about the commits
mailing list