Adium

Changeset 14765

Show
Ignore:
Timestamp:
01/05/2006 02:40:54 PM (3 years ago)
Author:
evands
Message:

If a message event triggers the dock bouncing multiple times, stop the dock from bouncing:

  • immediately if the chat is already active (only bounce once)
  • when the chat becomes active or is closed

Fixes #205

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/AIDockBehaviorPlugin.m

    r12821 r14765  
    1919#import "ESContactAlertsController.h" 
    2020#import "ESDockAlertDetailPane.h" 
     21#import "AIInterfaceController.h" 
     22#import <Adium/AIChat.h> 
    2123#import <AIUtilities/AIImageAdditions.h> 
    2224 
     
    2527 
    2628@interface AIDockBehaviorPlugin (PRIVATE) 
    27 - (void)preferencesChanged:(NSNotification *)notification; 
    28 - (void)eventNotification:(NSNotification *)notification; 
    29 - (BOOL)_upgradeCustomDockBehavior; 
     29- (void)observeToStopBouncingForChat:(AIChat *)chat; 
     30- (void)stopBouncing:(NSNotification *)inNotification; 
    3031@end 
    3132 
     
    9495- (void)performActionID:(NSString *)actionID forListObject:(AIListObject *)listObject withDetails:(NSDictionary *)details triggeringEventID:(NSString *)eventID userInfo:(id)userInfo 
    9596{ 
    96         [[adium dockController] performBehavior:[[details objectForKey:KEY_DOCK_BEHAVIOR_TYPE] intValue]]; 
     97        if ([[adium dockController] performBehavior:[[details objectForKey:KEY_DOCK_BEHAVIOR_TYPE] intValue]]) { 
     98                //The behavior will continue into the future 
     99                if ([[adium contactAlertsController] isMessageEvent:eventID]) { 
     100                        AIChat *chat = [userInfo objectForKey:@"AIChat"]; 
     101                         
     102                        if (chat == [[adium interfaceController] activeChat]) { 
     103                                //If this is the active chat, stop the bouncing immediately 
     104                                [self stopBouncing:nil]; 
     105         
     106                        } else { 
     107                                [self observeToStopBouncingForChat:chat]; 
     108                        } 
     109                } 
     110        } 
     111
     112 
     113/* 
     114 * @brief Begin watching for this chat to close or become active so we'll know to stop bouncing 
     115 */ 
     116- (void)observeToStopBouncingForChat:(AIChat *)chat 
     117
     118        [[adium notificationCenter] addObserver:self 
     119                                                                   selector:@selector(stopBouncing:) 
     120                                                                           name:Chat_WillClose 
     121                                                                         object:chat]; 
     122 
     123        [[adium notificationCenter] addObserver:self 
     124                                                                   selector:@selector(stopBouncing:) 
     125                                                                           name:Chat_BecameActive 
     126                                                                         object:chat]; 
     127
     128 
     129/* 
     130 * @brief Remove our observers and stop bouncing 
     131 * 
     132 * We remove all observers because no matter how many chats we were watching, we will stop bouncing; subsequently, stopping a bounce 
     133 * would be inappropriate as it would not be associated with the chat or event which triggered a later bounce. 
     134 */ 
     135- (void)stopBouncing:(NSNotification *)inNotification 
     136
     137        [[adium notificationCenter] removeObserver:self 
     138                                                                                  name:Chat_WillClose 
     139                                                                                object:nil]; 
     140        [[adium notificationCenter] removeObserver:self 
     141                                                                                  name:Chat_BecameActive 
     142                                                                                object:nil]; 
     143 
     144        [[adium dockController] performBehavior:BOUNCE_NONE]; 
    97145} 
    98146