Changeset 53 for trunk/Cocoa/Pester/Source/PSSpeechAlert.m
- Timestamp:
- 01/02/03 05:30:03 (21 years ago)
- Location:
- trunk/Cocoa/Pester/Source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source
- Property svn:ignore
-
old new 1 1 build 2 .gdb_history
-
- Property svn:ignore
-
trunk/Cocoa/Pester/Source/PSSpeechAlert.m
r34 r53 4 4 // 5 5 // Created by Nicholas Riley on Sat Oct 26 2002. 6 // Copyright (c) 2002 __MyCompanyName__. All rights reserved.6 // Copyright (c) 2002 Nicholas Riley. All rights reserved. 7 7 // 8 8 9 9 #import "PSSpeechAlert.h" 10 10 #import "PSAlarmAlertController.h" 11 #import "NSDictionary-NJRExtensions.h" 12 #import "SUSpeaker.h" 13 14 // property list keys 15 static NSString * const PLAlertVoice = @"voice"; // NSString 11 16 12 17 @implementation PSSpeechAlert … … 20 25 { 21 26 if ( (self = [super init]) != nil) { 22 voice = aVoice;27 voice = [aVoice retain]; 23 28 } 24 29 return self; … … 33 38 } 34 39 40 - (NSString *)voice; 41 { 42 return voice; 43 } 44 35 45 - (void)_stopSpeaking:(NSNotification *)notification; 36 46 { 37 [speaker stopSpeaking]; 38 // don't release here, we'll still get the didFinishSpeaking: message as a delegate 47 [speaker stopSpeaking]; // triggers didFinishSpeaking: 39 48 } 40 49 41 - (void)triggerForAlarm:(PSAlarm *)a larm;50 - (void)triggerForAlarm:(PSAlarm *)anAlarm; 42 51 { 43 52 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_stopSpeaking:) name: PSAlarmAlertStopNotification object: nil]; 44 53 45 54 if ( (speaker = [[SUSpeaker alloc] init]) == nil) return; 55 alarm = anAlarm; 46 56 [speaker setDelegate: self]; 47 57 [speaker setVoice: [[SUSpeaker voiceNames] indexOfObject: voice] + 1]; 48 58 [speaker speakText: [alarm message]]; 49 50 [self retain]; 59 } 60 61 - (NSAttributedString *)actionDescription; 62 { 63 NSMutableAttributedString *string = [[@"Speak message with voice " small] mutableCopy]; 64 [string appendAttributedString: [voice underlined]]; 65 return [string autorelease]; 66 } 67 68 #pragma mark property list serialization (Pester 1.1) 69 70 - (NSDictionary *)propertyListRepresentation; 71 { 72 NSMutableDictionary *plAlert = [[super propertyListRepresentation] mutableCopy]; 73 [plAlert setObject: voice forKey: PLAlertVoice]; 74 return [plAlert autorelease]; 75 } 76 77 - (id)initWithPropertyList:(NSDictionary *)dict; 78 { 79 if ( (self = [self init]) != nil) { 80 voice = [dict objectForRequiredKey: PLAlertVoice]; 81 } 82 return self; 51 83 } 52 84 … … 55 87 @implementation PSSpeechAlert (SUSpeakerDelegate) 56 88 57 - (void)didFinishSpeaking:(SUSpeaker *)speaker;89 - (void)didFinishSpeaking:(SUSpeaker *)aSpeaker; 58 90 { 59 [self release]; 91 [self completedForAlarm: alarm]; 92 [speaker release]; speaker = nil; 60 93 } 61 94
Note:
See TracChangeset
for help on using the changeset viewer.