Ignore:
Timestamp:
01/02/03 05:30:03 (20 years ago)
Author:
Nicholas Riley
Message:

Updated for Pester 1.1a5 (very limited release).

Pester 1.1a4 was never released.

Location:
trunk/Cocoa/Pester/Source
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source

    • Property svn:ignore
      •  

        old new  
        11build
         2.gdb_history
  • trunk/Cocoa/Pester/Source/PSSpeechAlert.m

    r34 r53  
    44//
    55//  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.
    77//
    88
    99#import "PSSpeechAlert.h"
    1010#import "PSAlarmAlertController.h"
     11#import "NSDictionary-NJRExtensions.h"
     12#import "SUSpeaker.h"
     13
     14// property list keys
     15static NSString * const PLAlertVoice = @"voice"; // NSString
    1116
    1217@implementation PSSpeechAlert
     
    2025{
    2126    if ( (self = [super init]) != nil) {
    22         voice = aVoice;
     27        voice = [aVoice retain];
    2328    }
    2429    return self;
     
    3338}
    3439
     40- (NSString *)voice;
     41{
     42    return voice;
     43}
     44
    3545- (void)_stopSpeaking:(NSNotification *)notification;
    3646{
    37     [speaker stopSpeaking];
    38     // don't release here, we'll still get the didFinishSpeaking: message as a delegate
     47    [speaker stopSpeaking]; // triggers didFinishSpeaking:
    3948}
    4049
    41 - (void)triggerForAlarm:(PSAlarm *)alarm;
     50- (void)triggerForAlarm:(PSAlarm *)anAlarm;
    4251{
    4352    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_stopSpeaking:) name: PSAlarmAlertStopNotification object: nil];
    4453   
    4554    if ( (speaker = [[SUSpeaker alloc] init]) == nil) return;
     55    alarm = anAlarm;
    4656    [speaker setDelegate: self];
    4757    [speaker setVoice: [[SUSpeaker voiceNames] indexOfObject: voice] + 1];
    4858    [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;
    5183}
    5284
     
    5587@implementation PSSpeechAlert (SUSpeakerDelegate)
    5688
    57 - (void)didFinishSpeaking:(SUSpeaker*)speaker;
     89- (void)didFinishSpeaking:(SUSpeaker *)aSpeaker;
    5890{
    59     [self release];
     91    [self completedForAlarm: alarm];
     92    [speaker release]; speaker = nil;
    6093}
    6194
Note: See TracChangeset for help on using the changeset viewer.