Adium

Changeset 15676

Show
Ignore:
Timestamp:
04/07/2006 06:05:33 PM (3 years ago)
Author:
tick
Message:

It seems the joscar plugin is broken, or I'd be able to test this.
- Adding a global hot key. This will work only when Adium is running, and uses the Shortcut Recorder from Waffle Software. http://wafflesoftware.net/shortcut/ for more info and http://wafflesoftware.net/shortcut/demovideo/ for a demo.
- Copied what we do when we get a clickback from Growl to happen when someone hits the hotkey. It seemed appropriate.
- This maybe my second legitimate addition in three years, could someone take a look at my code, I am almost positive there are problems that I'm just not familiar with.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Adium.xcodeproj/project.pbxproj

    r15660 r15676  
    12991299                7E824CEA06387FAF00813072 /* SHLinkManagementPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E824CDB06387FAF00813072 /* SHLinkManagementPlugin.h */; }; 
    13001300                7E824CEB06387FAF00813072 /* SHLinkManagementPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E824CDC06387FAF00813072 /* SHLinkManagementPlugin.m */; }; 
     1301                83B9216009E709AF008D8436 /* CTGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9215209E709AE008D8436 /* CTGradient.h */; }; 
     1302                83B9216109E709AF008D8436 /* CTGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B9215309E709AE008D8436 /* CTGradient.m */; }; 
     1303                83B9216209E709AF008D8436 /* NSBezierPathAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9215409E709AE008D8436 /* NSBezierPathAdditions.h */; }; 
     1304                83B9216309E709AF008D8436 /* NSBezierPathAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B9215509E709AE008D8436 /* NSBezierPathAdditions.m */; }; 
     1305                83B9216409E709AF008D8436 /* PTHotKey.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9215609E709AE008D8436 /* PTHotKey.h */; }; 
     1306                83B9216509E709AF008D8436 /* PTHotKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B9215709E709AE008D8436 /* PTHotKey.m */; }; 
     1307                83B9216609E709AF008D8436 /* PTHotKeyCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9215809E709AE008D8436 /* PTHotKeyCenter.h */; }; 
     1308                83B9216709E709AF008D8436 /* PTHotKeyCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B9215909E709AE008D8436 /* PTHotKeyCenter.m */; }; 
     1309                83B9216809E709AF008D8436 /* PTKeyCombo.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9215A09E709AE008D8436 /* PTKeyCombo.h */; }; 
     1310                83B9216909E709AF008D8436 /* PTKeyCombo.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B9215B09E709AE008D8436 /* PTKeyCombo.m */; }; 
     1311                83B9216A09E709AF008D8436 /* ShortcutRecorder.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9215C09E709AE008D8436 /* ShortcutRecorder.h */; }; 
     1312                83B9216B09E709AF008D8436 /* ShortcutRecorder.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B9215D09E709AF008D8436 /* ShortcutRecorder.m */; }; 
     1313                83B9216C09E709AF008D8436 /* ShortcutRecorderCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 83B9215E09E709AF008D8436 /* ShortcutRecorderCell.h */; }; 
     1314                83B9216D09E709AF008D8436 /* ShortcutRecorderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 83B9215F09E709AF008D8436 /* ShortcutRecorderCell.m */; }; 
    13011315                9E124DEB07D34C7300AA91C5 /* CBGrowlAlertDetailPane.h in Headers */ = {isa = PBXBuildFile; fileRef = 9E124DE707D34C7300AA91C5 /* CBGrowlAlertDetailPane.h */; }; 
    13021316                9E124DEC07D34C7300AA91C5 /* CBGrowlAlertDetailPane.m in Sources */ = {isa = PBXBuildFile; fileRef = 9E124DE807D34C7300AA91C5 /* CBGrowlAlertDetailPane.m */; }; 
     
    27582772                34BD0DB308D31479000BE2C0 /* AdiumChatEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AdiumChatEvents.h; path = Source/AdiumChatEvents.h; sourceTree = "<group>"; }; 
    27592773                34BD0DB408D31479000BE2C0 /* AdiumChatEvents.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AdiumChatEvents.m; path = Source/AdiumChatEvents.m; sourceTree = "<group>"; }; 
    2760                 34BD9DA9053146CC000AB133 /* Adium.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Adium.app; sourceTree = BUILT_PRODUCTS_DIR; }; 
     2774                34BD9DA9053146CC000AB133 /* Adium.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = Adium.app; sourceTree = BUILT_PRODUCTS_DIR; }; 
    27612775                34BD9DE105314751000AB133 /* Adium.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Adium.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 
    27622776                34BD9EF10531476E000AB133 /* Stress Test.AdiumPlugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Stress Test.AdiumPlugin"; sourceTree = BUILT_PRODUCTS_DIR; }; 
     
    34263440                7E824CDB06387FAF00813072 /* SHLinkManagementPlugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SHLinkManagementPlugin.h; sourceTree = "<group>"; }; 
    34273441                7E824CDC06387FAF00813072 /* SHLinkManagementPlugin.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SHLinkManagementPlugin.m; sourceTree = "<group>"; }; 
     3442                83B9215209E709AE008D8436 /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CTGradient.h; path = "Plugins/Hot Key/CTGradient.h"; sourceTree = "<group>"; }; 
     3443                83B9215309E709AE008D8436 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = CTGradient.m; path = "Plugins/Hot Key/CTGradient.m"; sourceTree = "<group>"; }; 
     3444                83B9215409E709AE008D8436 /* NSBezierPathAdditions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = NSBezierPathAdditions.h; path = "Plugins/Hot Key/NSBezierPathAdditions.h"; sourceTree = "<group>"; }; 
     3445                83B9215509E709AE008D8436 /* NSBezierPathAdditions.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = NSBezierPathAdditions.m; path = "Plugins/Hot Key/NSBezierPathAdditions.m"; sourceTree = "<group>"; }; 
     3446                83B9215609E709AE008D8436 /* PTHotKey.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTHotKey.h; path = "Plugins/Hot Key/PTHotKey.h"; sourceTree = "<group>"; }; 
     3447                83B9215709E709AE008D8436 /* PTHotKey.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PTHotKey.m; path = "Plugins/Hot Key/PTHotKey.m"; sourceTree = "<group>"; }; 
     3448                83B9215809E709AE008D8436 /* PTHotKeyCenter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTHotKeyCenter.h; path = "Plugins/Hot Key/PTHotKeyCenter.h"; sourceTree = "<group>"; }; 
     3449                83B9215909E709AE008D8436 /* PTHotKeyCenter.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PTHotKeyCenter.m; path = "Plugins/Hot Key/PTHotKeyCenter.m"; sourceTree = "<group>"; }; 
     3450                83B9215A09E709AE008D8436 /* PTKeyCombo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PTKeyCombo.h; path = "Plugins/Hot Key/PTKeyCombo.h"; sourceTree = "<group>"; }; 
     3451                83B9215B09E709AE008D8436 /* PTKeyCombo.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = PTKeyCombo.m; path = "Plugins/Hot Key/PTKeyCombo.m"; sourceTree = "<group>"; }; 
     3452                83B9215C09E709AE008D8436 /* ShortcutRecorder.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ShortcutRecorder.h; path = "Plugins/Hot Key/ShortcutRecorder.h"; sourceTree = "<group>"; }; 
     3453                83B9215D09E709AF008D8436 /* ShortcutRecorder.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ShortcutRecorder.m; path = "Plugins/Hot Key/ShortcutRecorder.m"; sourceTree = "<group>"; }; 
     3454                83B9215E09E709AF008D8436 /* ShortcutRecorderCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ShortcutRecorderCell.h; path = "Plugins/Hot Key/ShortcutRecorderCell.h"; sourceTree = "<group>"; }; 
     3455                83B9215F09E709AF008D8436 /* ShortcutRecorderCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ShortcutRecorderCell.m; path = "Plugins/Hot Key/ShortcutRecorderCell.m"; sourceTree = "<group>"; }; 
    34283456                9C103FAE057127A500F3C158 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = /System/Library/Frameworks/WebKit.framework; sourceTree = "<absolute>"; }; 
    34293457                9C8C7FA403CBA21B00267226 /* AILoggerPlugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AILoggerPlugin.h; path = Plugins/Logger/AILoggerPlugin.h; sourceTree = "<group>"; }; 
     
    48684896                        isa = PBXGroup; 
    48694897                        children = ( 
     4898                                83B920F809E70778008D8436 /* Hot Key */, 
    48704899                                4B2E560406A33D85008866CF /* Chat Cycling */, 
    48714900                                34C68B230778FA1300EB423C /* ESGeneralPreferencesPlugin.h */, 
     
    61476176                        name = "Link Management"; 
    61486177                        path = "Plugins/Link Management"; 
     6178                        sourceTree = "<group>"; 
     6179                }; 
     6180                83B920F809E70778008D8436 /* Hot Key */ = { 
     6181                        isa = PBXGroup; 
     6182                        children = ( 
     6183                                83B9215209E709AE008D8436 /* CTGradient.h */, 
     6184                                83B9215309E709AE008D8436 /* CTGradient.m */, 
     6185                                83B9215409E709AE008D8436 /* NSBezierPathAdditions.h */, 
     6186                                83B9215509E709AE008D8436 /* NSBezierPathAdditions.m */, 
     6187                                83B9215609E709AE008D8436 /* PTHotKey.h */, 
     6188                                83B9215709E709AE008D8436 /* PTHotKey.m */, 
     6189                                83B9215809E709AE008D8436 /* PTHotKeyCenter.h */, 
     6190                                83B9215909E709AE008D8436 /* PTHotKeyCenter.m */, 
     6191                                83B9215A09E709AE008D8436 /* PTKeyCombo.h */, 
     6192                                83B9215B09E709AE008D8436 /* PTKeyCombo.m */, 
     6193                                83B9215C09E709AE008D8436 /* ShortcutRecorder.h */, 
     6194                                83B9215D09E709AF008D8436 /* ShortcutRecorder.m */, 
     6195                                83B9215E09E709AF008D8436 /* ShortcutRecorderCell.h */, 
     6196                                83B9215F09E709AF008D8436 /* ShortcutRecorderCell.m */, 
     6197                        ); 
     6198                        name = "Hot Key"; 
    61496199                        sourceTree = "<group>"; 
    61506200                }; 
     
    71077157                                34AE249D09BCCFA900A35B51 /* AIWindowDraggingView.h in Headers */, 
    71087158                                342353D609D45726009FF634 /* AIAbstractLogViewerWindowController.h in Headers */, 
     7159                                83B9216009E709AF008D8436 /* CTGradient.h in Headers */, 
     7160                                83B9216209E709AF008D8436 /* NSBezierPathAdditions.h in Headers */, 
     7161                                83B9216409E709AF008D8436 /* PTHotKey.h in Headers */, 
     7162                                83B9216609E709AF008D8436 /* PTHotKeyCenter.h in Headers */, 
     7163                                83B9216809E709AF008D8436 /* PTKeyCombo.h in Headers */, 
     7164                                83B9216A09E709AF008D8436 /* ShortcutRecorder.h in Headers */, 
     7165                                83B9216C09E709AF008D8436 /* ShortcutRecorderCell.h in Headers */, 
    71097166                        ); 
    71107167                        runOnlyForDeploymentPostprocessing = 0; 
     
    90769133                                342353D709D45726009FF634 /* AIAbstractLogViewerWindowController.m in Sources */, 
    90779134                                C962831709DEE5B4004235A9 /* AdiumFileTransferQuitConfirmation.m in Sources */, 
     9135                                83B9216109E709AF008D8436 /* CTGradient.m in Sources */, 
     9136                                83B9216309E709AF008D8436 /* NSBezierPathAdditions.m in Sources */, 
     9137                                83B9216509E709AF008D8436 /* PTHotKey.m in Sources */, 
     9138                                83B9216709E709AF008D8436 /* PTHotKeyCenter.m in Sources */, 
     9139                                83B9216909E709AF008D8436 /* PTKeyCombo.m in Sources */, 
     9140                                83B9216B09E709AF008D8436 /* ShortcutRecorder.m in Sources */, 
     9141                                83B9216D09E709AF008D8436 /* ShortcutRecorderCell.m in Sources */, 
    90789142                        ); 
    90799143                        runOnlyForDeploymentPostprocessing = 0; 
  • trunk/Plugins/General Preferences/ESGeneralPreferences.h

    r14818 r15676  
    1616 
    1717#import <Adium/AIPreferencePane.h> 
     18#import "ShortcutRecorder.h" 
     19#define SYNCHRONIZE_ADIUM_HOTKEY_PREFS() CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication) 
     20 
     21 
     22@class PTHotKey; 
    1823 
    1924@class AIColorSelectionPopUpButton, AIFontSelectionPopUpButton; 
     
    3540        IBOutlet        NSTextField             *label_menuItem; 
    3641        IBOutlet        NSTextField             *label_switchTabsWith;   
     42 
     43    IBOutlet    ShortcutRecorder        *shortcutRecorder; 
     44                 
     45        PTHotKey        *globalHotKey; 
     46 
    3747} 
    3848 
  • trunk/Plugins/General Preferences/ESGeneralPreferences.m

    r15644 r15676  
    2020#import "ESGeneralPreferences.h" 
    2121#import "ESGeneralPreferencesPlugin.h" 
     22#import "PTHotKeyCenter.h" 
     23#import "PTHotKey.h" 
     24#import "ShortcutRecorderCell.h" 
    2225#import <AIUtilities/AIColorAdditions.h> 
    2326#import <AIUtilities/AIFontAdditions.h> 
     
    2730#import <Adium/AIStatusIcons.h> 
    2831 
     32 
    2933@interface ESGeneralPreferences (PRIVATE) 
    3034- (NSMenu *)tabKeysMenu; 
     
    3842 
    3943@implementation ESGeneralPreferences 
     44 
     45#warning XXX in order to use shortcutrecorder you need a pallette 
     46// grab to http://brok3n.org/shortcutrecorder/ShortcutRecorder-pre-dist.zip and the updated http://brok3n.org/shortcutrecorder/ShortCutRecorderCell.m in order for this to work for you. Compile the pallette and install. 
     47// This comes from http://wafflesoftware.net/shortcut/ 
     48 
     49- (void) awakeFromNib { 
     50         
     51        //Grab the default       
     52         
     53        NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; 
     54        NSString *awakePrefHotKey = nil; 
     55         
     56        if (standardUserDefaults)  
     57                awakePrefHotKey = [standardUserDefaults objectForKey:@"ShortcutRecorder prefHotKey"]; 
     58         
     59        NSLog(@"omg awakePrefHotKey is %@", awakePrefHotKey); 
     60         
     61        //Set the globalHotKey if there is a hotkey from above 
     62         
     63        globalHotKey = [[PTHotKey alloc] initWithIdentifier:@"SRTest" 
     64                                                                                           keyCombo:[PTKeyCombo keyComboWithKeyCode:[shortcutRecorder keyCombo].code 
     65                                                                                                                                                          modifiers:[shortcutRecorder cocoaToCarbonFlags: [shortcutRecorder keyCombo].flags]]]; 
     66         
     67        [globalHotKey setTarget: self]; 
     68        [globalHotKey setAction: @selector(hitHotKey:)]; 
     69         
     70        [[PTHotKeyCenter sharedCenter] registerHotKey: globalHotKey]; 
     71         
     72} 
     73 
     74 
     75 
    4076 
    4177//Preference pane properties 
     
    176212} 
    177213 
     214 
     215 
     216 
     217 
     218 
     219- (BOOL)shortcutRecorder:(ShortcutRecorder *)aRecorder isKeyCode:(signed short)keyCode andFlagsTaken:(unsigned int)flags reason:(NSString **)aReason 
     220{ 
     221        if (aRecorder == shortcutRecorder) 
     222        { 
     223                BOOL isTaken = NO; 
     224                 
     225                return isTaken; 
     226        } 
     227         
     228        return NO; 
     229} 
     230 
     231- (void)shortcutRecorder:(ShortcutRecorder *)aRecorder keyComboDidChange:(KeyCombo)newKeyCombo 
     232{ 
     233        if (aRecorder == shortcutRecorder) 
     234        { 
     235                 
     236                [self toggleGlobalHotKey: aRecorder]; 
     237                NSLog(@"%@", aRecorder); 
     238                NSLog(@"got to shortcutrecorder keycombodidchange:(keycombo)newcombo"); 
     239        } 
     240} 
     241 
     242 
     243 
     244- (void)toggleGlobalHotKey:(id)sender 
     245{ 
     246        //if (globalHotKey != nil) 
     247        //{ 
     248        //      [[PTHotKeyCenter sharedCenter] unregisterHotKey: globalHotKey]; 
     249        //      [globalHotKey release]; 
     250        //      globalHotKey = nil; 
     251        //} 
     252                 
     253        //      if (![globalHotKeyCheckBox state]) return; 
     254         
     255        globalHotKey = [[PTHotKey alloc] initWithIdentifier:@"SRTest" 
     256                                                                                           keyCombo:[PTKeyCombo keyComboWithKeyCode:[shortcutRecorder keyCombo].code 
     257                                                                                                                                                          modifiers:[shortcutRecorder cocoaToCarbonFlags: [shortcutRecorder keyCombo].flags]]]; 
     258         
     259        [globalHotKey setTarget: self]; 
     260        [globalHotKey setAction: @selector(hitHotKey:)]; 
     261         
     262        [[PTHotKeyCenter sharedCenter] registerHotKey: globalHotKey]; 
     263        [self savePref]; 
     264} 
     265 
     266 
     267 
     268- (void)hitHotKey:(PTHotKey *)hotKey 
     269{ 
     270        NSString                *internalObjectID, *uniqueChatID; 
     271        AIListObject    *listObject; 
     272        AIChat                  *chat = nil; 
     273         
     274        if ((internalObjectID = [clickContext objectForKey:@"internalObjectID"])) { 
     275                 
     276                if ((listObject = [[adium contactController] existingListObjectWithUniqueID:internalObjectID]) && 
     277                        ([listObject isKindOfClass:[AIListContact class]])) { 
     278                         
     279                        //First look for an existing chat to avoid changing anything 
     280                        if (!(chat = [[adium chatController] existingChatWithContact:(AIListContact *)listObject])) { 
     281                                //If we don't find one, create one 
     282                                chat = [[adium chatController] openChatWithContact:(AIListContact *)listObject]; 
     283                        } 
     284                } 
     285        } else if ((uniqueChatID = [clickContext objectForKey:@"uniqueChatID"])) { 
     286                chat = [[adium chatController] existingChatWithUniqueChatID:uniqueChatID]; 
     287                 
     288                //If we didn't find a chat, it may have closed since the notification was posted. 
     289                //If we have an appropriate existing list object, we can create a new chat. 
     290                if ((!chat) && 
     291                        (listObject = [[adium contactController] existingListObjectWithUniqueID:uniqueChatID]) && 
     292                        ([listObject isKindOfClass:[AIListContact class]])) { 
     293                         
     294                        //If the uniqueChatID led us to an existing contact, create a chat with it 
     295                        chat = [[adium chatController] openChatWithContact:(AIListContact *)listObject]; 
     296                }        
     297        } 
     298         
     299        if (chat) { 
     300                //Make the chat active 
     301                [[adium interfaceController] setActiveChat:chat]; 
     302                 
     303                //And make Adium active (needed if, for example, our notification was clicked with another app active) 
     304                [NSApp activateIgnoringOtherApps:YES]; 
     305        } 
     306         
     307         
     308} 
     309 
     310- (void) savePref{ 
     311         
     312        //Grab that pref and send it to the dungeon of the plist. Hurray for NSUD not being about to write to the domain of another app :( 
     313         
     314        CFPreferencesSetAppValue(CFSTR("ShortcutRecorder prefHotKey"), [[globalHotKey keyCombo] plistRepresentation], kCFPreferencesCurrentApplication); 
     315         
     316        //CFSTR("com.google.GmailNotifier")); 
     317         
     318         
     319        //Sync it, just sync it 
     320         
     321        SYNCHRONIZE_ADIUM_HOTKEY_PREFS(); 
     322         
     323         
     324} 
     325 
     326 
     327 
     328 
     329 
     330 
     331 
     332 
    178333/*! 
    179334 * @brief Construct our menu by hand for easy localization 
  • trunk/Resources/English.lproj/GeneralPreferences.nib/classes.nib

    r13497 r15676  
    6868                "popUp_sendKeys" = NSPopUpButton;  
    6969                "popUp_tabKeys" = NSPopUpButton;  
     70                shortcutRecorder = ShortcutRecorder;  
    7071                "slider_volume" = NSSlider;  
    7172            };