source: releases/Pester/1.1b6/Source/PSAlerts.m@ 511

Last change on this file since 511 was 364, checked in by Nicholas Riley, 17 years ago

English.lproj/Alarms.nib: Specify alternating row coloring in the nib,
now we're 10.4+.

English.lproj/InfoPlist.strings: Updated for 1.1b6.

English.lproj/Localizable.strings: Quote alarm message in pretty
description (used in tooltip). Change voice error now it no longer
incorporates OSStatus.

English.lproj/MainMenu.nib: Add speech prefs again; turn repetitions
field into a NJRValidatingField and hook up its delegate.

Info-Pester.plist: Updated for 1.1b6.

NJRHotKey.m: Switch to new Objective-C exception style.

NJRIntervalField.[hm]: Now a subclass of NJRValidatingField.

NJRTableDelegate.m: Get rid of our own tooltip support as NSTableView
now supports them (though with a minor visual glitch on the first
tooltip).

NJRTableView.[hm]: Remove tooltip support. Remove alternating row
coloring support.

NJRValidatingField.[hm]: Contains validation sheet stuff from
NJRIntervalField.

NJRVoicePopUpButton.[hm]: Switch to NSSpeechSynthesizer.

PSAlarm.m: Quote alarm message in pretty description (used in
tooltip). Fix repeating alarms not restoring as repeating if they
didn't expire while Pester was not running. No longer set timer on
Pester 1.0 alarm import, to help make importing atomic.

PSAlarmSetController.[hm]: Use NJRValidatingField for repetitions
field. Switch to new Objective-C exception style. Fix validation
issues on in/at changing. Temporary changes to restore speech support
and allow the sound popup to be removed entirely from the nib (rather
than being dragged out of the visible area, as it was in 1.1b5).
Changes for NSSpeechSynthesizer, which uses different voice names.

PSAlarms.m: Switch to new Objective-C exception style. Fix
duplication and error handling in Pester 1.0 alarm import, making
atomic.

PSAlarmsController.m: Use new tooltip support (since it's implemented
in the delegate rather than the data source, we have to proxy it).

PSAlerts.m: Wrap initialization in exception block so we don't leak.

PSApplication.m: Switch to new Objective-C exception style.

PSMediaAlert.m: Clamp repetitions at 1..99 so the user can't type an
invalid value, then quit and have it saved.

PSSpeechAlert.[hm]: Switch to NSSpeechSynthesizer. Throw an
intelligible exception if the voice is unavailable.

PSTimer.m: Switch to new Objective-C exception style.

Pester.xcodeproj: Remove VERSION generation; rename targets to be more
understandable.

Read Me.rtfd: Updated for 1.1b6.

SUSpeaker.[hm]: Gone in switch to NSSpeechSynthesizer.

VERSION: Gone - we use agvtool for everything now.

Updates/release-notes.html: Updated for 1.1b6.

Updates/updates.xml: Updated for 1.1b6.

package-Pester.sh: Use agvtool to get version. Atomically update
file on Web server to avoid partial downloads.

File size: 3.9 KB
Line 
1//
2// PSAlerts.m
3// Pester
4//
5// Created by Nicholas Riley on Sat Dec 21 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "PSAlerts.h"
10#import "PSAlert.h"
11#import "PSDockBounceAlert.h"
12#import "PSNotifierAlert.h"
13#import "PSBeepAlert.h"
14
15// property list keys
16static NSString * const PLAlerts = @"alerts"; // NSString
17
18@implementation PSAlerts
19
20#pragma mark initialize-release
21
22- (id)init;
23{
24 if ( (self = [super init]) != nil) {
25 alerts = [[NSMutableArray alloc] initWithCapacity: 4];
26 }
27 return self;
28}
29
30- (id)initWithPesterVersion1Alerts;
31{
32 if ( (self = [self init]) != nil) {
33 [self addAlert: [PSDockBounceAlert alert]];
34 [self addAlert: [PSNotifierAlert alert]];
35 [self addAlert: [PSBeepAlert alertWithRepetitions: 1]];
36 }
37 return self;
38}
39
40- (void)dealloc;
41{
42 [alerts release]; alerts = nil;
43 [super dealloc];
44}
45
46#pragma mark accessing
47
48- (void)addAlert:(PSAlert *)alert;
49{
50 [alerts addObject: alert];
51 if ([alert requiresPesterFrontmost])
52 requirePesterFrontmost = YES;
53}
54
55- (void)removeAlerts;
56{
57 [alerts removeAllObjects];
58 requirePesterFrontmost = NO;
59}
60
61- (NSEnumerator *)alertEnumerator;
62{
63 return [alerts objectEnumerator];
64}
65
66- (NSArray *)allAlerts;
67{
68 return [[alerts copy] autorelease];
69}
70
71- (BOOL)requirePesterFrontmost;
72{
73 return requirePesterFrontmost;
74}
75
76#pragma mark actions
77
78- (void)prepareForAlarm:(PSAlarm *)alarm;
79{
80 [alerts makeObjectsPerformSelector: @selector(prepareForAlarm:) withObject: alarm];
81}
82
83- (void)triggerForAlarm:(PSAlarm *)alarm;
84{
85 [alerts makeObjectsPerformSelector: @selector(triggerForAlarm:) withObject: alarm];
86}
87
88#pragma mark printing
89
90- (NSAttributedString *)prettyList;
91{
92 NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
93 NSEnumerator *e = [self alertEnumerator];
94 PSAlert *alert;
95 unsigned int length;
96 while ( (alert = [e nextObject]) != nil) {
97 if ([alert isKindOfClass: [PSDockBounceAlert class]]) // XXX temporary for 1.1b5
98 continue;
99 [string appendAttributedString: [NSLocalizedString(@"* ", "Unordered list label (usually a bullet followed by a space)") small]];
100 [string appendAttributedString: [alert actionDescription]];
101 [string appendAttributedString: [@"\n" small]];
102 }
103 if ( (length = [string length]) == 0) {
104 [string release];
105 return nil;
106 } else {
107 NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
108 [string deleteCharactersInRange: NSMakeRange(length - 1, 1)]; // remove trailing newline
109 [paraStyle setHeadIndent: [[string attribute: NSFontAttributeName atIndex: 0 effectiveRange: NULL] widthOfString: NSLocalizedString(@"* ", "Unordered list label (usually a bullet followed by a space)")]];
110 [string addAttribute: NSParagraphStyleAttributeName value: paraStyle range: NSMakeRange(0, length - 1)];
111 [paraStyle release]; paraStyle = nil;
112 return [string autorelease];
113 }
114}
115
116#pragma mark property list serialization (Pester 1.1)
117
118- (NSDictionary *)propertyListRepresentation;
119{
120 NSMutableArray *plAlerts = [[NSMutableArray alloc] initWithCapacity: [alerts count]];
121 NSEnumerator *e = [self alertEnumerator];
122 PSAlert *alert;
123 while ( (alert = [e nextObject]) != nil) {
124 [plAlerts addObject: [alert propertyListRepresentation]];
125 }
126 NSDictionary *dict = [NSDictionary dictionaryWithObject: plAlerts forKey: PLAlerts];
127 [plAlerts release];
128 return dict;
129}
130
131- (id)initWithPropertyList:(NSDictionary *)dict;
132{
133 if ( (self = [self init]) != nil) {
134 @try {
135 NSArray *plAlerts = [dict objectForKey: PLAlerts];
136 NSEnumerator *e = [plAlerts objectEnumerator];
137 NSDictionary *alertDict;
138 while ( (alertDict = [e nextObject]) != nil) {
139 [self addAlert: [[PSAlert alloc] initWithPropertyList: alertDict]];
140 }
141 } @catch (NSException *e) {
142 [self release];
143 @throw;
144 }
145 }
146 return self;
147}
148
149@end
Note: See TracBrowser for help on using the repository browser.