source: trunk/Cocoa/Pester/Source/PSDockBounceAlert.m @ 516

Last change on this file since 516 was 516, checked in by Nicholas Riley, 10 years ago

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

File size: 1.3 KB
Line 
1//
2//  PSDockBounceAlert.m
3//  Pester
4//
5//  Created by Nicholas Riley on Sat Oct 26 2002.
6//  Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import <AppKit/AppKit.h>
10#import "PSDockBounceAlert.h"
11#import "PSAlarmAlertController.h"
12
13#include <Carbon/Carbon.h>
14
15static PSDockBounceAlert *PSDockBounceAlertShared;
16static NMRec nmr;
17
18@implementation PSDockBounceAlert
19
20+ (PSAlert *)alert;
21{
22    if (PSDockBounceAlertShared == nil) {
23        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   
32    return PSDockBounceAlertShared;
33}
34
35- (void)_stopBouncing;
36{
37    if ((void *)nmr.nmRefCon != self)
38        return;
39   
40    nmr.nmRefCon = 0;
41    NMRemove(&nmr);
42}
43
44- (void)triggerForAlarm:(PSAlarm *)alarm;
45{
46    if (nmr.nmRefCon == 0) {
47        nmr.nmRefCon = (long)self;
48        NMInstall(&nmr);
49    }
50
51    [self completedForAlarm: alarm];
52}
53
54- (NSAttributedString *)actionDescription;
55{
56    return [@"Bounce Dock icon" small];
57}
58
59#pragma mark property list serialization (Pester 1.1)
60
61- (id)initWithPropertyList:(NSDictionary *)dict;
62{
63    [self release];
64    return [[PSDockBounceAlert alert] retain];
65}
66       
67@end
Note: See TracBrowser for help on using the repository browser.