Ignore:
Timestamp:
10/29/02 22:20:58 (20 years ago)
Author:
Nicholas Riley
Message:

Changes for Pester 1.1d1.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/PSAlarmSetController.m

    r28 r34  
    88
    99#import "PSAlarmSetController.h"
    10 #import "PSAlarmNotifierController.h"
     10#import "PSAlarmAlertController.h"
    1111#import "NJRDateFormatter.h"
     12#import "NJRFSObjectSelector.h"
     13#import "NJRSoundPopUpButton.h"
     14#import "NJRVoicePopUpButton.h"
     15#import <Carbon/Carbon.h>
     16
     17#import "PSDockBounceAlert.h"
     18#import "PSScriptAlert.h"
     19#import "PSNotifierAlert.h"
     20#import "PSBeepAlert.h"
     21#import "PSMovieAlert.h"
     22#import "PSSpeechAlert.h"
    1223
    1324/* Bugs to file:
     
    4859    [[self window] center];
    4960    [self inAtChanged: nil];
     61    [self playSoundChanged: nil];
     62    [self doScriptChanged: nil];
     63    [self doSpeakChanged: nil];
     64    [script setFileTypes: [NSArray arrayWithObjects: @"applescript", @"script", NSFileTypeForHFSTypeCode(kOSAFileType), NSFileTypeForHFSTypeCode('TEXT'), nil]];
     65    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(silence:) name: PSAlarmAlertStopNotification object: nil];
     66    [voice setDelegate: self];
    5067    [[self window] makeKeyAndOrderFront: nil];
    5168}
     
    131148    [timeInterval setEnabled: isInterval];
    132149    [timeIntervalUnits setEnabled: isInterval];
     150    [timeIntervalRepeats setEnabled: isInterval];
    133151    [timeOfDay setEnabled: !isInterval];
    134152    [timeDate setEnabled: !isInterval];
     
    140158}
    141159
     160- (IBAction)playSoundChanged:(id)sender;
     161{
     162    BOOL playSoundSelected = [playSound intValue];
     163    [sound setEnabled: playSoundSelected];
     164    [soundRepetitions setEnabled: playSoundSelected];
     165    [soundRepetitionStepper setEnabled: playSoundSelected];
     166    [soundRepetitionsLabel setTextColor: playSoundSelected ? [NSColor controlTextColor] : [NSColor disabledControlTextColor]];
     167    if (playSoundSelected && sender != nil)
     168        [[self window] makeFirstResponder: sound];
     169}
     170
     171// XXX should check the 'Do script:' button when someone drops a script on the button
     172
     173- (IBAction)doScriptChanged:(id)sender;
     174{
     175    BOOL doScriptSelected = [doScript intValue];
     176    [script setEnabled: doScriptSelected];
     177    [scriptSelectButton setEnabled: doScriptSelected];
     178    if (doScriptSelected && sender != nil)
     179        [[self window] makeFirstResponder: scriptSelectButton];
     180}
     181
     182- (IBAction)doSpeakChanged:(id)sender;
     183{
     184    BOOL doSpeakSelected = [doSpeak intValue];
     185    [voice setEnabled: doSpeakSelected];
     186    if (doSpeakSelected && sender != nil)
     187        [[self window] makeFirstResponder: voice];
     188}
     189
    142190- (IBAction)dateCompleted:(NSPopUpButton *)sender;
    143191{
     
    159207- (IBAction)setAlarm:(NSButton *)sender;
    160208{
    161     PSAlarmNotifierController *notifier = [PSAlarmNotifierController alloc];
    162     if (notifier == nil) {
    163         [self setStatus: @"Unable to set alarm."];
    164         return;
    165     }
     209    // set alarm
    166210    [self setAlarmDateAndInterval: sender];
    167211    [alarm setMessage: [messageField stringValue]];
     
    170214        return;
    171215    }
     216
     217    [alarm removeAlerts];
     218    // dock bounce alert
     219    if ([bounceDockIcon state] == NSOnState)
     220        [alarm addAlert: [PSDockBounceAlert alert]];
     221    // script alert
     222    if ([doScript intValue]) {
     223        BDAlias *scriptFileAlias = [script alias];
     224        if (scriptFileAlias == nil) {
     225            [self setStatus: @"Unable to set script alert (no script specified?)"];
     226            return;
     227        }
     228        [alarm addAlert: [PSScriptAlert alertWithScriptFileAlias: scriptFileAlias]];
     229    }
     230    // notifier alert
     231    if ([displayMessage intValue])
     232        [alarm addAlert: [PSNotifierAlert alert]];
     233    // sound alerts
     234    if ([playSound intValue]) {
     235        BDAlias *soundAlias = [sound selectedAlias];
     236        unsigned short numReps = [soundRepetitions intValue];
     237        if (soundAlias == nil) // beep alert
     238            [alarm addAlert: [PSBeepAlert alertWithRepetitions: numReps]];
     239        else // movie alert
     240            [alarm addAlert: [PSMovieAlert alertWithMovieFileAlias: soundAlias repetitions: numReps]];
     241    }
     242    // speech alert
     243    if ([doSpeak intValue])
     244        [alarm addAlert: [PSSpeechAlert alertWithVoice: [voice titleOfSelectedItem]]];
     245   
    172246    [self setStatus: [[alarm date] descriptionWithCalendarFormat: @"Alarm set for %x at %X" timeZone: nil locale: nil]];
    173247    [[self window] close];
    174248    [alarm release];
    175249    alarm = [[PSAlarm alloc] init];
     250}
     251
     252- (IBAction)silence:(id)sender;
     253{
     254    [sound stopSoundPreview: self];
     255    [voice stopVoicePreview: self];
    176256}
    177257
     
    206286{
    207287    // NSLog(@"stopping update timer");
     288    [self silence: nil];
    208289    [self _stopUpdateTimer];
    209290}
     
    222303
    223304@end
     305
     306@implementation PSAlarmSetController (NJRVoicePopUpButtonDelegate)
     307
     308- (NSString *)voicePopUpButton:(NJRVoicePopUpButton *)sender previewStringForVoice:(NSString *)voice;
     309{
     310    return [messageField stringValue];
     311}
     312
     313@end
Note: See TracChangeset for help on using the changeset viewer.