Changeset 329 for trunk/Cocoa/AntiRSI/AntiRSI.m
- Timestamp:
- 08/05/07 00:15:30 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI/AntiRSI.m
r328 r329 139 139 micro_pause_taking_t = 0; 140 140 work_break_taking_t = 0; 141 work_break_taking_cached_t = 0; 142 work_break_taking_cached_date = 0; 141 143 142 144 // initialize dock image … … 177 179 [initial setObject:[NSNumber numberWithFloat:50] forKey:@"work_break_period"]; 178 180 [initial setObject:[NSNumber numberWithFloat:8] forKey:@"work_break_duration"]; 179 [initial setObject:@" Normal" forKey:@"sample_interval"];181 [initial setObject:@"Smooth" forKey:@"sample_interval"]; 180 182 [initial setObject:[NSNumber numberWithBool:YES] forKey:@"draw_dock_image"]; 181 183 [initial setObject:[NSNumber numberWithBool:NO] forKey:@"lock_focus"]; … … 204 206 // start the timer 205 207 [self installTimer:sample_interval]; 208 209 // about dialog 210 [version setStringValue:[NSString stringWithFormat:@"Version %@", sVersion]]; 206 211 } 207 212 … … 228 233 } 229 234 235 // just did a whole micropause beyond normal time 230 236 if (tick_time > micro_pause_duration && s_taking_work_break != state) { 231 237 // set micro_pause timers to 0 … … 274 280 work_break_t += tick_time; 275 281 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 } 276 286 work_break_taking_t = 0; 277 287 } else if (micro_pause_t > 0) { … … 294 304 micro_pause_t = 0; 295 305 work_break_t = 0; 296 // micro_pause_taking_t stays put306 // micro_pause_taking_t stays put 297 307 // work_break_taking_t stays put 298 308 } … … 495 505 { 496 506 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 } 497 512 [status setStringValue:@"Work Break"]; 498 513 [progress setMaxValue:work_break_duration / 60]; … … 527 542 } 528 543 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 529 580 // stop work break and postpone by 10 minutes 530 581 - (IBAction)postpone:(id)sender … … 534 585 micro_pause_taking_t = 0; 535 586 work_break_taking_t = 0; 587 work_break_taking_cached_t = 0; 536 588 work_break_t -= 10*60; // decrease with 10 minutes 537 589 if (work_break_t < 0) work_break_t = 0; … … 553 605 554 606 if ([[anItem title] isEqualToString:@"Postpone Break"] && state == s_taking_work_break) { 607 return YES; 608 } 609 610 if ([[anItem title] isEqualToString:@"AntiRSI Help"]) { 555 611 return YES; 556 612 }
Note:
See TracChangeset
for help on using the changeset viewer.