Changeset 34


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

Changes for Pester 1.1d1.

Location:
trunk/Cocoa/Pester/Source
Files:
35 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/NSTableView-NJRExtensions.h

    r26 r34  
    11//
    22//  NSTableView-NJRExtensions.h
    3 //  HostLauncher
     3//  Pester
    44//
    5 //  Created by Nicholas Riley on Mon Apr 22 2002.
     5//  Created by Nicholas Riley on Sun Oct 27 2002.
    66//  Copyright (c) 2002 Nicholas Riley. All rights reserved.
    77//
    88
    9 #import <Cocoa/Cocoa.h>
     9#import <AppKit/AppKit.h>
    1010
    1111
    1212@interface NSTableView (NJRExtensions)
    1313
     14+ (NSImage *)ascendingSortIndicator;
     15+ (NSImage *)descendingSortIndicator;
     16
    1417- (float)cellHeight;
    1518
     19- (NSArray *)selectedRowIndices;
     20
    1621@end
  • trunk/Cocoa/Pester/Source/NSTableView-NJRExtensions.m

    r26 r34  
    11//
    22//  NSTableView-NJRExtensions.m
    3 //  HostLauncher
     3//  Pester
    44//
    5 //  Created by Nicholas Riley on Mon Apr 22 2002.
     5//  Created by Nicholas Riley on Sun Oct 27 2002.
    66//  Copyright (c) 2002 Nicholas Riley. All rights reserved.
    77//
     
    1010
    1111
     12@interface NSTableView (PumaPrivate)
     13// Declarations of 10.1 private methods, just to make the compiler happy.
     14+ (id) _defaultTableHeaderReverseSortImage;
     15+ (id) _defaultTableHeaderSortImage;
     16@end
     17
    1218@implementation NSTableView (NJRExtensions)
     19
     20+ (NSImage *)ascendingSortIndicator;
     21{
     22    NSImage *result = [NSImage imageNamed: @"NSAscendingSortIndicator"];
     23    if (result == nil && [[NSTableView class] respondsToSelector: @selector(_defaultTableHeaderSortImage)])
     24        result = [NSTableView _defaultTableHeaderSortImage];
     25    return result;
     26}
     27
     28+ (NSImage *)descendingSortIndicator;
     29{
     30    NSImage *result = [NSImage imageNamed:@"NSDescendingSortIndicator"];
     31    if (result == nil && [[NSTableView class] respondsToSelector:@selector(_defaultTableHeaderReverseSortImage)])
     32        result = [NSTableView _defaultTableHeaderReverseSortImage];
     33    return result;
     34}
     35
     36- (NSArray *)selectedRowIndices;
     37{
     38    NSEnumerator *theEnum = [self selectedRowEnumerator];
     39    NSNumber *rowNumber;
     40    NSMutableArray *rowNumberArray = [NSMutableArray arrayWithCapacity: [self numberOfSelectedRows]];
     41
     42    while (nil != (rowNumber = [theEnum nextObject]) )
     43        [rowNumberArray addObject: rowNumber];
     44
     45    return rowNumberArray;
     46}
    1347
    1448- (float)cellHeight;
  • trunk/Cocoa/Pester/Source/PSAlarm.h

    r28 r34  
    1616extern NSString * const PSAlarmTimerExpiredNotification;
    1717
     18// XXX figure out how to support reading old alarms
     19
     20@class PSAlert;
     21
    1822@interface PSAlarm : NSObject <NSCoding> {
    1923    PSAlarmType alarmType;
     
    2327    NSString *invalidMessage;
    2428    NSTimer *timer;
     29    NSMutableArray *alerts;
    2530}
    2631
     
    2934- (void)setForDate:(NSDate *)date atTime:(NSDate *)time;
    3035- (void)setMessage:(NSString *)aMessage;
     36- (void)addAlert:(PSAlert *)alert;
     37- (void)removeAlerts;
    3138
    3239- (NSCalendarDate *)date;
    3340- (NSTimeInterval)interval;
    3441- (NSString *)message;
     42- (NSArray *)alerts;
    3543
    3644- (NSString *)shortDateString;
  • trunk/Cocoa/Pester/Source/PSAlarm.m

    r28 r34  
    88
    99#import "PSAlarm.h"
     10#import "PSAlert.h"
    1011
    1112NSString * const PSAlarmTimerSetNotification = @"PSAlarmTimerSetNotification";
    1213NSString * const PSAlarmTimerExpiredNotification = @"PSAlarmTimerExpiredNotification";
     14
     15// XXX need to reset pending alarms after sleep, they "freeze" and never expire.
    1316
    1417@implementation PSAlarm
     
    2225    [invalidMessage release]; invalidMessage = nil;
    2326    [timer invalidate]; [timer release]; timer = nil;
     27    [alerts release]; alerts = nil;
    2428    [super dealloc];
    2529}
     
    224228{
    225229    return [[self date] compare: [otherAlarm date]];
     230}
     231
     232- (void)addAlert:(PSAlert *)alert;
     233{
     234    if (alerts == nil) alerts = [[NSMutableArray alloc] initWithCapacity: 4];
     235    [alerts addObject: alert];
     236}
     237
     238- (void)removeAlerts;
     239{
     240    [alerts removeAllObjects];
     241}
     242
     243- (NSArray *)alerts;
     244{
     245    return [[alerts copy] autorelease];
    226246}
    227247
  • trunk/Cocoa/Pester/Source/PSAlarmNotifierController.h

    r26 r34  
    1616}
    1717
    18 + (PSAlarmNotifierController *)controllerWithTimerExpiredNotification:(NSNotification *)notification;
    19 
    2018- (id)initWithAlarm:(PSAlarm *)alarm;
    2119
  • trunk/Cocoa/Pester/Source/PSAlarmNotifierController.m

    r28 r34  
    88
    99#import "PSAlarmNotifierController.h"
     10#import "PSAlarmAlertController.h"
    1011#import "PSAlarm.h"
    1112
     
    1314
    1415// XXX should use NSNonactivatingPanelMask on 10.2
    15 
    16 + (PSAlarmNotifierController *)controllerWithTimerExpiredNotification:(NSNotification *)notification;
    17 {
    18     return [[self alloc] initWithAlarm: [notification object]];
    19 }
    2016
    2117- (id)initWithAlarm:(PSAlarm *)alarm;
     
    2521        [messageField setStringValue: [alarm message]];
    2622        [dateField setObjectValue: [alarm date]];
    27         [NSApp requestUserAttention: NSInformationalRequest];
    28         [NSApp activateIgnoringOtherApps: YES];
    2923        [[self window] makeKeyAndOrderFront: nil];
    3024        [[self window] orderFrontRegardless];
    31         [NSApp cancelUserAttentionRequest: NSInformationalRequest];
    32         NSBeep();
    3325    }
    3426    return self;
     
    3729- (IBAction)close:(id)sender;
    3830{
     31    [PSAlarmAlertController stopAlerts: sender];
    3932    [self close];
    4033}
  • trunk/Cocoa/Pester/Source/PSAlarmSetController.h

    r26 r34  
    1010#import "PSAlarm.h"
    1111
     12@class NJRFSObjectSelector;
     13@class NJRSoundPopUpButton;
     14@class NJRVoicePopUpButton;
     15
    1216@interface PSAlarmSetController : NSWindowController {
    1317    IBOutlet NSTextField *messageField;
     
    1519    IBOutlet NSTextField *timeInterval;
    1620    IBOutlet NSPopUpButton *timeIntervalUnits;
     21    IBOutlet NSButton *timeIntervalRepeats;
    1722    IBOutlet NSTextField *timeOfDay;
    1823    IBOutlet NSTextField *timeDate;
    1924    IBOutlet NSPopUpButton *timeDateCompletions; // XXX should go away when bug preventing both formatters and popup menus from existing is fixed
     25    IBOutlet NSButtonCell *displayMessage;
     26    IBOutlet NSButton *bounceDockIcon;
     27    IBOutlet NSButtonCell *playSound;
     28    IBOutlet NJRSoundPopUpButton *sound;
     29    IBOutlet NSTextField *soundRepetitions;
     30    IBOutlet NSStepper *soundRepetitionStepper;
     31    IBOutlet NSTextField *soundRepetitionsLabel;
     32    IBOutlet NSButtonCell *doScript;
     33    IBOutlet NJRFSObjectSelector *script;
     34    IBOutlet NSButtonCell *doSpeak;
     35    IBOutlet NJRVoicePopUpButton *voice;
     36    IBOutlet NSButton *scriptSelectButton;
    2037    IBOutlet NSTextField *timeSummary;
    2138    IBOutlet NSButton *setButton;
     
    2946- (IBAction)dateCompleted:(NSPopUpButton *)sender;
    3047- (IBAction)inAtChanged:(id)sender;
     48- (IBAction)playSoundChanged:(id)sender;
     49- (IBAction)doScriptChanged:(id)sender;
     50- (IBAction)doSpeakChanged:(id)sender;
    3151- (IBAction)setAlarm:(NSButton *)sender;
    3252
     53- (IBAction)silence:(id)sender;
     54
    3355@end
  • 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
  • trunk/Cocoa/Pester/Source/PSAlarms.h

    r28 r34  
    44//
    55//  Created by Nicholas Riley on Fri Oct 11 2002.
    6 //  Copyright (c) 2002 __MyCompanyName__. All rights reserved.
     6//  Copyright (c) 2002 Nicholas Riley. All rights reserved.
    77//
    88
  • trunk/Cocoa/Pester/Source/PSAlarmsController.m

    r28 r34  
    122122
    123123@end
    124 
  • trunk/Cocoa/Pester/Source/PSApplication.h

    r28 r34  
    2222- (IBAction)orderFrontSetAlarmPanel:(id)sender;
    2323- (IBAction)orderFrontAlarmsPanel:(id)sender;
     24- (IBAction)stopAlerts:(id)sender;
    2425
    2526@end
  • trunk/Cocoa/Pester/Source/PSApplication.m

    r28 r34  
    99#import "PSApplication.h"
    1010#import "PSAlarmSetController.h"
    11 #import "PSAlarmNotifierController.h"
     11#import "PSAlarmAlertController.h"
    1212#import "PSAlarmsController.h"
    1313#import "PSAlarm.h"
     
    1919{
    2020    appIconImage = [[NSImage imageNamed: @"NSApplicationIcon"] retain];
    21     [[NSNotificationCenter defaultCenter] addObserver: [PSAlarmNotifierController class] selector: @selector(controllerWithTimerExpiredNotification:) name: PSAlarmTimerExpiredNotification object: nil];
     21    [[NSNotificationCenter defaultCenter] addObserver: [PSAlarmAlertController class] selector: @selector(controllerWithTimerExpiredNotification:) name: PSAlarmTimerExpiredNotification object: nil];
    2222    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(nextAlarmDidChange:) name: PSAlarmsNextAlarmDidChangeNotification object: nil];
    2323    [PSAlarms setUp];
     
    3030    [[NSWorkspace sharedWorkspace] openFile: [[NSBundle mainBundle] pathForResource: @"Read Me" ofType: @"rtfd"]];
    3131}
     32
     33- (IBAction)stopAlerts:(id)sender;
     34{
     35    [PSAlarmAlertController stopAlerts: sender];
     36}       
    3237
    3338- (IBAction)orderFrontSetAlarmPanel:(id)sender;
Note: See TracChangeset for help on using the changeset viewer.