Ignore:
Timestamp:
01/02/03 05:30:03 (21 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/PSApplication.m

    r34 r53  
    2121    [[NSNotificationCenter defaultCenter] addObserver: [PSAlarmAlertController class] selector: @selector(controllerWithTimerExpiredNotification:) name: PSAlarmTimerExpiredNotification object: nil];
    2222    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(nextAlarmDidChange:) name: PSAlarmsNextAlarmDidChangeNotification object: nil];
     23    // XXX exception handling
    2324    [PSAlarms setUp];
    2425    [self setDelegate: self];
     
    7172{
    7273    PSAlarm *alarm = [timer userInfo];
    73     NSTimeInterval alarmInterval;
     74    NSTimeInterval timeRemaining;
    7475    NSString *tileString;
    7576    if (timer == nil) alarm = [[PSAlarms allAlarms] nextAlarm];
    7677    if (alarm == nil) return;
    7778    tileString = [alarm timeRemainingString];
     79    timeRemaining = [alarm timeRemaining]; // want to err on the side of timeRemaining being smaller, otherwise ÇexpiredÈ can appear
    7880    {
    7981        NSMutableDictionary *atts = [NSMutableDictionary dictionary];
     
    117119        [tile release];
    118120    }
    119     alarmInterval = [alarm interval];
    120     // NSLog(@"_updateDockTile > time remaining %@ (%.0lf), last time interval %.0lf", tileString, alarmInterval, dockUpdateInterval);
    121     if (alarmInterval > 61) {
    122         NSTimeInterval nextUpdate = ((unsigned long long)alarmInterval) % 60;
     121    // NSLog(@"_updateDockTile > time remaining %@ (%.6lf), last time interval %.6lf", tileString, timeRemaining, dockUpdateInterval);
     122    if (timeRemaining > 61) {
     123        NSTimeInterval nextUpdate = ((unsigned long long)timeRemaining) % 60;
    123124        if (nextUpdate <= 1) nextUpdate = 60;
    124125        [self _resetUpdateTimer];
     
    126127        // NSLog(@"_updateDockTile > set timer for %.0lf seconds", nextUpdate);
    127128    } else if (timer == nil || dockUpdateInterval > 1) {
    128         [self _resetUpdateTimer];
     129        [self _resetUpdateTimer]; 
    129130        [self _setUpdateTimerForInterval: 1 alarm: alarm repeats: YES];
    130131        // NSLog(@"_updateDockTile > set timer for 1 second");
    131     } else if (alarmInterval < 2) {
     132    } else if (timeRemaining <= 1) {
    132133        [self _resetUpdateTimer];
    133134    }
     
    182183@implementation PSApplication (NSApplicationNotifications)
    183184
     185- (void)applicationDidFinishLaunching:(NSNotification *)notification;
     186{
     187    // XXX import panel will not be frontmost window if you switch to another app while Pester is launching; Mac OS X bug?
     188    PSAlarms *allAlarms = [PSAlarms allAlarms];
     189    unsigned version1AlarmCount = [allAlarms countOfVersion1Alarms];
     190    if (version1AlarmCount > 0) {
     191        int answer = NSRunAlertPanel(@"Import alarms from older Pester version?", @"Pester found %u alarm%@ created with an older version. These alarms must be converted for use with this version of Pester, and will be unavailable in previous versions after conversion. New alarms created with this version of Pester will not appear in Pester version 1.1a3 or earlier.",
     192                                     @"Import", @"Discard", @"DonÕt Import",
     193                                     version1AlarmCount, version1AlarmCount == 1 ? @"" : @"s");
     194        switch (answer) {
     195            case NSAlertDefaultReturn:
     196                NS_DURING
     197                    [allAlarms importVersion1Alarms];
     198                NS_HANDLER
     199                    NSRunAlertPanel(@"Error occurred importing alarms", @"Pester was unable to convert some alarms created with an older version. Those alarms which could be read have been converted. The previous-format alarms have been retained; try using an older version of Pester to read them.\n\n%@", nil, nil, nil, [localException reason]);
     200                    NS_VOIDRETURN;
     201                NS_ENDHANDLER
     202            case NSAlertAlternateReturn:
     203                NSLog(@"discard");
     204                // [allAlarms discardVersion1Alarms];
     205                break;
     206            case NSAlertOtherReturn:
     207                NSLog(@"donÕt import");
     208                break;
     209        }
     210    }
     211}
     212
    184213- (void)applicationWillTerminate:(NSNotification *)notification;
    185214{
Note: See TracChangeset for help on using the changeset viewer.