source: releases/Pester/1.1b7/Source/PSMediaAlert.m@ 405

Last change on this file since 405 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: 1.8 KB
Line 
1//
2// PSMediaAlert.m
3// Pester
4//
5// Created by Nicholas Riley on Tue Apr 08 2003.
6// Copyright (c) 2003 Nicholas Riley. All rights reserved.
7//
8
9#import "PSMediaAlert.h"
10#import "NSDictionary-NJRExtensions.h"
11#import "NJRSoundManager.h"
12#import <QuickTime/Movies.h>
13
14// property list keys
15static NSString * const PLAlertRepetitions = @"times"; // NSString
16static NSString * const PLAlertOutputVolume = @"volume"; // NSNumber
17
18@implementation PSMediaAlert
19
20#pragma mark initialize-release
21
22- (id)initWithRepetitions:(unsigned short)numReps;
23{
24 if ( (self = [super init]) != nil) {
25 // XXX not DRY, but can't think of a more sensible way
26 if (numReps < 1)
27 numReps = 1;
28 else if (numReps > 99)
29 numReps = 99;
30 repetitions = numReps;
31 }
32 return self;
33}
34
35#pragma mark accessing
36
37- (unsigned short)repetitions;
38{
39 return repetitions;
40}
41
42- (float)outputVolume;
43{
44 return outputVolume;
45}
46
47- (void)setOutputVolume:(float)volume;
48{
49 if ([NJRSoundManager volumeIsNotMutedOrInvalid: volume])
50 outputVolume = volume;
51 else
52 outputVolume = kNoVolume;
53}
54
55#pragma mark property list serialization (Pester 1.1)
56
57- (NSDictionary *)propertyListRepresentation;
58{
59 NSMutableDictionary *plAlert = [[super propertyListRepresentation] mutableCopy];
60 [plAlert setObject: [NSNumber numberWithUnsignedShort: repetitions] forKey: PLAlertRepetitions];
61 if (outputVolume != kNoVolume) {
62 [plAlert setObject: [NSNumber numberWithFloat: outputVolume] forKey: PLAlertOutputVolume];
63 }
64 return [plAlert autorelease];
65}
66
67- (id)initWithPropertyList:(NSDictionary *)dict;
68{
69 if ( (self = [self initWithRepetitions: [[dict objectForRequiredKey: PLAlertRepetitions] unsignedShortValue]]) != nil) {
70 [self setOutputVolume: [[dict objectForKey: PLAlertOutputVolume] floatValue]];
71 }
72 return self;
73}
74
75@end
Note: See TracBrowser for help on using the repository browser.