Ignore:
Timestamp:
05/25/09 02:40:34 (15 years ago)
Author:
Nicholas Riley
Message:

Restore Dock bouncing using Notification Manager; should be more reliable now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/PSDockBounceAlert.m

    r53 r516  
    99#import <AppKit/AppKit.h>
    1010#import "PSDockBounceAlert.h"
     11#import "PSAlarmAlertController.h"
     12
     13#include <Carbon/Carbon.h>
    1114
    1215static PSDockBounceAlert *PSDockBounceAlertShared;
     16static NMRec nmr;
    1317
    1418@implementation PSDockBounceAlert
     
    1620+ (PSAlert *)alert;
    1721{
    18     if (PSDockBounceAlertShared == nil)
     22    if (PSDockBounceAlertShared == nil) {
    1923        PSDockBounceAlertShared = [[PSDockBounceAlert alloc] init];
     24       
     25        [[NSNotificationCenter defaultCenter] addObserver: PSDockBounceAlertShared selector: @selector(_stopBouncing) name: PSAlarmAlertStopNotification object: nil];
     26       
     27        bzero(&nmr, sizeof(nmr));
     28        nmr.nmMark = 1;
     29        nmr.qType = nmType;
     30    }
     31   
    2032    return PSDockBounceAlertShared;
    2133}
    2234
    23 + (void)stopBouncing;
     35- (void)_stopBouncing;
    2436{
    25     [NSApp cancelUserAttentionRequest: NSInformationalRequest];
     37    if ((void *)nmr.nmRefCon != self)
     38        return;
     39   
     40    nmr.nmRefCon = 0;
     41    NMRemove(&nmr);
    2642}
    2743
    2844- (void)triggerForAlarm:(PSAlarm *)alarm;
    2945{
    30     [NSApp requestUserAttention: NSInformationalRequest];
    31     [[self class] performSelector: @selector(stopBouncing) withObject: nil afterDelay: 1 inModes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
     46    if (nmr.nmRefCon == 0) {
     47        nmr.nmRefCon = (long)self;
     48        NMInstall(&nmr);
     49    }
     50
    3251    [self completedForAlarm: alarm];
    3352}
     
    3554- (NSAttributedString *)actionDescription;
    3655{
    37     return [@"Bounce dock icon" small];
     56    return [@"Bounce Dock icon" small];
    3857}
    3958
Note: See TracChangeset for help on using the changeset viewer.