Ignore:
Timestamp:
08/05/07 00:15:30 (17 years ago)
Author:
Nicholas Riley
Message:

AntiRSI changes for "something" called 1.4, with much of the code but not the same UI as Onne Gorter's released 1.4.

Info.plist, English.lproj/InfoPlist.strings: Updated for 1.4.

AntiRSI.[hm]: Some of Onne Gorter's changes, update checking, "go to Web site" and crediting idle time to work break, and "AntiRSI Help". Most of these are not hooked up in the UI as above. Default to smooth sampling.

AntiRSI.xcodeproj: Build fat (i386/ppc).

English.lproj/MainMenu.nib: Some changes...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/AntiRSI/AntiRSI.m

    r328 r329  
    139139        micro_pause_taking_t = 0;
    140140        work_break_taking_t = 0;
     141        work_break_taking_cached_t = 0;
     142        work_break_taking_cached_date = 0;
    141143       
    142144        // initialize dock image
     
    177179        [initial setObject:[NSNumber numberWithFloat:50] forKey:@"work_break_period"];
    178180        [initial setObject:[NSNumber numberWithFloat:8] forKey:@"work_break_duration"];
    179         [initial setObject:@"Normal" forKey:@"sample_interval"];
     181        [initial setObject:@"Smooth" forKey:@"sample_interval"];
    180182        [initial setObject:[NSNumber numberWithBool:YES] forKey:@"draw_dock_image"];
    181183        [initial setObject:[NSNumber numberWithBool:NO] forKey:@"lock_focus"];
     
    204206        // start the timer
    205207        [self installTimer:sample_interval];
     208       
     209        // about dialog
     210        [version setStringValue:[NSString stringWithFormat:@"Version %@", sVersion]];
    206211}
    207212
     
    228233        }
    229234       
     235        // just did a whole micropause beyond normal time
    230236        if (tick_time > micro_pause_duration && s_taking_work_break != state) {
    231237                // set micro_pause timers to 0
     
    274280                                work_break_t += tick_time;
    275281                                micro_pause_taking_t = 0;
     282                                if (work_break_taking_t > 0) {
     283                                        work_break_taking_cached_t = work_break_taking_t;
     284                                        work_break_taking_cached_date = date;
     285                                }
    276286                                work_break_taking_t = 0;
    277287                        } else if (micro_pause_t > 0) {
     
    294304                                micro_pause_t = 0;
    295305                                work_break_t = 0;
    296                                 //micro_pause_taking_t stays put
     306                                // micro_pause_taking_t stays put
    297307                                // work_break_taking_t stays put
    298308                        }
     
    495505{
    496506        work_break_taking_t = 0;
     507        // incase you were already having an implicit work break and clicked the take work break now button
     508        // not more then 20 seconds ago we took a natural break longer then 0.2 * normal work break duration
     509        if (date - work_break_taking_cached_date < 20 && work_break_taking_cached_t > work_break_duration * 0.2) {
     510                work_break_taking_t = work_break_taking_cached_t;
     511        }
    497512        [status setStringValue:@"Work Break"];
    498513        [progress setMaxValue:work_break_duration / 60];
     
    527542}
    528543
     544// goto website
     545- (IBAction)gotoWebsite:(id)sender
     546{
     547        [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:sURL]];
     548}
     549
     550// check for update
     551- (IBAction)checkForUpdate:(id)sender
     552{
     553        NSString *latest_version =
     554        [NSString stringWithContentsOfURL: [NSURL URLWithString:sLatestVersionURL]];
     555       
     556        if (latest_version == Nil) latest_version = @"";
     557        latest_version = [latest_version stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
     558       
     559        if ([latest_version length] == 0) {
     560                NSRunInformationalAlertPanel(
     561                        @"Unable to Determine",
     562                        @"Unable to determine the latest AntiRSI version number.",
     563                        @"Ok", nil, nil);
     564        } else if ([latest_version compare:sVersion] == NSOrderedDescending) {
     565                int r = NSRunInformationalAlertPanel(
     566                        @"New Version",
     567                        [NSString stringWithFormat:@"A new version (%@) of AntiRSI is available; would you like to go to the website now?", latest_version],
     568                        @"Goto Website", @"Cancel", nil);
     569                if (r == NSOKButton) {
     570                        [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:sURL]];
     571                }
     572    } else {
     573        NSRunInformationalAlertPanel(
     574                        @"No Update Available",
     575                        @"This is the latest version of AntiRSI.",
     576                        @"OK", nil, nil);
     577    }
     578}
     579
    529580// stop work break and postpone by 10 minutes
    530581- (IBAction)postpone:(id)sender
     
    534585                micro_pause_taking_t = 0;
    535586                work_break_taking_t = 0;
     587                work_break_taking_cached_t = 0;
    536588                work_break_t -= 10*60; // decrease with 10 minutes
    537589                if (work_break_t < 0) work_break_t = 0;
     
    553605       
    554606        if ([[anItem title] isEqualToString:@"Postpone Break"] && state == s_taking_work_break) {
     607                return YES;
     608        }
     609       
     610        if ([[anItem title] isEqualToString:@"AntiRSI Help"]) {
    555611                return YES;
    556612        }
Note: See TracChangeset for help on using the changeset viewer.