Changeset 330 for trunk/Cocoa
- Timestamp:
- 08/06/07 19:01:05 (17 years ago)
- Location:
- trunk/Cocoa/AntiRSI
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI/AntiRSI.h
r329 r330 40 40 IBOutlet NSTextField *time; 41 41 IBOutlet NSTextField *next_break; 42 IBOutlet NSTextField *session_time; 42 43 IBOutlet NSTextField *status; 43 IBOutlet NSTextField *version; 44 IBOutlet NSTextField *version; // XXX unused? 45 46 // dock menu 47 IBOutlet NSMenu *dock_menu; 48 IBOutlet NSMenuItem *session_time_item; 44 49 45 50 // dock icon image … … 60 65 double work_break_taking_cached_t; 61 66 double work_break_taking_cached_date; 67 double session_t; 62 68 double date; 63 69 … … 111 117 - (IBAction)breakNow:(id)sender; 112 118 119 // reset session time menu item 120 - (IBAction)resetSession:(id)sender; 121 122 // returns string of the form "Session: 12:34:56" 123 - (NSString *)sessionTimeString; 124 113 125 // one second ticks away ... 114 126 - (void)tick:(NSTimer *)timer; … … 126 138 - (void)endBreak; 127 139 128 // time left string 129 - (void)drawTimeLeft:(double)seconds; 130 131 // time to next break string 132 - (void)drawNextBreak:(int)seconds; 140 // update window 141 - (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak; 133 142 134 143 @end -
trunk/Cocoa/AntiRSI/AntiRSI.m
r329 r330 279 279 micro_pause_t += tick_time; 280 280 work_break_t += tick_time; 281 if (idle_time < 1) { 282 session_t += tick_time; 283 } 281 284 micro_pause_taking_t = 0; 282 285 if (work_break_taking_t > 0) { … … 338 341 if (idle_time < 1 && !slack) { 339 342 micro_pause_taking_t = 0; 343 session_t += tick_time; 340 344 } 341 345 342 346 // update window 343 [progress setDoubleValue:micro_pause_taking_t]; 344 [self drawTimeLeft:micro_pause_duration - micro_pause_taking_t]; 345 [self drawNextBreak:work_break_period - work_break_t]; 346 347 // if user likes to be interrupted 348 if (lock_focus) { 349 [NSApp activateIgnoringOtherApps:YES]; 350 [main_window makeKeyAndOrderFront:self]; 351 } 352 347 [self updateBreakWindowDuration:micro_pause_duration progress:micro_pause_taking_t 348 nextBreak:work_break_period - work_break_t]; 349 353 350 // check if we done enough 354 351 if (micro_pause_taking_t > micro_pause_duration) { … … 375 372 if (idle_time >= 2 || work_break_taking_t < 3) { 376 373 work_break_taking_t += tick_time; 377 } 374 } else if (idle_time < 1) { 375 session_t += tick_time; 376 } 378 377 379 378 // draw window 380 [progress setDoubleValue:work_break_taking_t / 60 - 0.5]; 381 [self drawTimeLeft:work_break_duration - work_break_taking_t]; 382 [self drawNextBreak:work_break_period + work_break_duration - work_break_taking_t]; 383 384 // if user likes to be interrupted 385 if (lock_focus) { 386 [NSApp activateIgnoringOtherApps:YES]; 387 [main_window makeKeyAndOrderFront:self]; 388 } 379 [self updateBreakWindowDuration:work_break_duration progress:work_break_taking_t 380 nextBreak:work_break_period + work_break_duration - work_break_taking_t]; 389 381 390 382 // and check if we done enough … … 404 396 // draw dock image 405 397 if (draw_dock_image) [self drawDockImage]; 398 } 399 400 // dock image 401 - (NSMenu *)applicationDockMenu:(NSApplication *)sender; 402 { 403 [session_time_item setTitle:[self sessionTimeString]]; 404 return dock_menu; 406 405 } 407 406 … … 522 521 } 523 522 524 // diplays time left 525 - (void)drawTimeLeft:(double)seconds 526 { 527 [time setStringValue:[NSString stringWithFormat:@"%d:%02d", lrint(seconds) / 60, lrint(seconds) % 60]]; 528 } 529 530 // displays next break 531 - (void)drawNextBreak:(int)seconds 532 { 533 int minutes = round(seconds / 60.0) ; 523 - (NSString *)sessionTimeString; 524 { 525 return [NSString stringWithFormat:@"Session: %d:%02d:%02d", (int)session_t / 3600, (int)session_t / 60, lrint(session_t) % 60]; 526 } 527 528 - (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak; 529 { 530 // progress 531 [progress setDoubleValue:duration >= 60 ? (progress_t / 60 - 0.5) : progress_t]; 532 533 // time left 534 double timeLeft = duration - progress_t; 535 [time setStringValue:[NSString stringWithFormat:@"%d:%02d", (int)timeLeft / 60, lrint(timeLeft) % 60]]; 536 537 // cumulative typing time in this session (e.g. today) 538 [session_time setStringValue:[self sessionTimeString]]; 539 540 // next break 541 int minutes = round(nextBreak / 60.0); 534 542 535 543 // nice hours, minutes ... … … 540 548 [next_break setStringValue:[NSString stringWithFormat:@"next break in %d minutes", minutes]]; 541 549 } 550 551 // if user likes to be interrupted 552 if (lock_focus) { 553 [NSApp activateIgnoringOtherApps:YES]; 554 [main_window makeKeyAndOrderFront:self]; 555 } 542 556 } 543 557 … … 597 611 } 598 612 613 - (IBAction)resetSession:(id)sender; 614 { 615 if (s_normal != state) { 616 [self endBreak]; 617 } 618 session_t = 0; 619 } 620 599 621 // validate menu items 600 622 - (BOOL)validateMenuItem:(NSMenuItem *)anItem 601 623 { 602 if ([ [anItem title] isEqualToString:@"Take Break Now"] && state == s_normal) {624 if ([anItem action] == @selector(breakNow:) && state == s_normal) 603 625 return YES; 604 } 605 606 if ([[anItem title] isEqualToString:@"Postpone Break"] && state == s_taking_work_break) { 626 627 if ([anItem action] == @selector(postpone:) && state == s_taking_work_break) 607 628 return YES; 608 } 609 610 if ([[anItem title] isEqualToString:@"AntiRSI Help"]) { 629 630 if ([anItem action] == @selector(resetSession:)) 611 631 return YES; 612 } 613 632 633 if ([anItem action] == @selector(gotoWebsite:)) 634 return YES; 635 636 if ([anItem action] == @selector(checkForUpdate:)) 637 return YES; 638 614 639 return NO; 615 640 } -
trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj
r329 r330 342 342 buildSettings = { 343 343 GCC_C_LANGUAGE_STANDARD = c99; 344 PREBINDING = NO; 344 345 }; 345 346 name = Development; … … 353 354 ); 354 355 GCC_C_LANGUAGE_STANDARD = c99; 356 PREBINDING = NO; 355 357 }; 356 358 name = Deployment; … … 360 362 buildSettings = { 361 363 GCC_C_LANGUAGE_STANDARD = c99; 364 PREBINDING = NO; 362 365 }; 363 366 name = Default; -
trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib
r325 r330 2 2 IBClasses = ( 3 3 { 4 ACTIONS = {breakNow = id; postpone = id; }; 4 ACTIONS = { 5 breakNow = id; 6 checkForUpdate = id; 7 gotoWebsite = id; 8 postpone = id; 9 resetSession = id; 10 }; 5 11 CLASS = AntiRSI; 6 12 LANGUAGE = ObjC; 7 13 OUTLETS = { 14 "dock_menu" = NSMenu; 8 15 "next_break" = NSTextField; 9 16 postpone = NSButton; 10 17 progress = NSLevelIndicator; 18 "session_time" = NSTextField; 19 "session_time_item" = NSMenuItem; 11 20 status = NSTextField; 12 21 time = NSTextField; 22 version = NSTextField; 13 23 view = AntiRSIView; 14 24 }; -
trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib
r329 r330 4 4 <dict> 5 5 <key>IBDocumentLocation</key> 6 <string> 35 23 441 309 0 0 1024 746</string>6 <string>70 16 441 309 0 0 1680 1028 </string> 7 7 <key>IBEditorPositions</key> 8 8 <dict> 9 9 <key>259</key> 10 <string> 490 507 300 322 0 0 1280 1002</string>10 <string>688 524 300 322 0 0 1680 1028 </string> 11 11 <key>29</key> 12 <string> 194 823 330 44 0 0 1280 1002</string>12 <string>276 845 249 44 0 0 1680 1028 </string> 13 13 <key>343</key> 14 <string> 84 540 189 68 0 0 1280 1002</string>14 <string>241 262 145 99 0 0 1680 1028 </string> 15 15 </dict> 16 16 <key>IBFramework Version</key> 17 <string>443.0</string> 17 <string>446.1</string> 18 <key>IBOldestOS</key> 19 <integer>4</integer> 18 20 <key>IBOpenObjects</key> 19 21 <array> 20 <integer>343</integer> 21 <integer>259</integer> 22 <integer>29</integer> 22 <integer>21</integer> 23 23 </array> 24 24 <key>IBSystem Version</key> 25 <string>8 G32</string>25 <string>8R2232</string> 26 26 </dict> 27 27 </plist> -
trunk/Cocoa/AntiRSI/Info.plist
r329 r330 18 18 <string>ONNE</string> 19 19 <key>CFBundleVersion</key> 20 <string>1.4 </string>20 <string>1.4njr1</string> 21 21 <key>NSMainNibFile</key> 22 22 <string>MainMenu</string>
Note:
See TracChangeset
for help on using the changeset viewer.