Ignore:
Timestamp:
08/06/07 19:01:05 (17 years ago)
Author:
Nicholas Riley
Message:

Info.plist: Updated for 1.4njr1.

AntiRSI.xcodeproj: Disable prebinding.

AntiRSI.[hm]: Added session time support; consolidated break window update drawing; fixed -[AntiRSI validateMenuItem:] so it compares selectors rather than titles.

English.lproj/MainMenu.nib: Redid preferences window, menu bar, dock menu, etc.

File:
1 edited

Legend:

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

    r329 r330  
    279279                                micro_pause_t += tick_time;
    280280                                work_break_t += tick_time;
     281                if (idle_time < 1) {
     282                    session_t += tick_time;
     283                }
    281284                                micro_pause_taking_t = 0;
    282285                                if (work_break_taking_t > 0) {
     
    338341                        if (idle_time < 1 && !slack) {
    339342                                micro_pause_taking_t = 0;
     343                session_t += tick_time;
    340344                        }
    341345                               
    342346                        // 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
    353350                        // check if we done enough
    354351                        if (micro_pause_taking_t > micro_pause_duration) {
     
    375372                        if (idle_time >= 2 || work_break_taking_t < 3) {
    376373                                work_break_taking_t += tick_time;
    377                         }
     374                        } else if (idle_time < 1) {
     375                session_t += tick_time;
     376            }
    378377                       
    379378                        // 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];
    389381
    390382                        // and check if we done enough
     
    404396        // draw dock image
    405397        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;
    406405}
    407406
     
    522521}
    523522
    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);
    534542       
    535543        // nice hours, minutes ...
     
    540548                [next_break setStringValue:[NSString stringWithFormat:@"next break in %d minutes", minutes]];
    541549        }
     550
     551    // if user likes to be interrupted
     552    if (lock_focus) {
     553        [NSApp activateIgnoringOtherApps:YES];
     554        [main_window makeKeyAndOrderFront:self];
     555    }
    542556}
    543557
     
    597611}
    598612
     613- (IBAction)resetSession:(id)sender;
     614{
     615    if (s_normal != state) {
     616        [self endBreak];
     617    }
     618    session_t = 0;
     619}
     620
    599621// validate menu items
    600622- (BOOL)validateMenuItem:(NSMenuItem *)anItem
    601623{
    602         if ([[anItem title] isEqualToString:@"Take Break Now"] && state == s_normal) {
     624        if ([anItem action] == @selector(breakNow:) && state == s_normal)
    603625                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)
    607628                return YES;
    608         }
    609        
    610         if ([[anItem title] isEqualToString:@"AntiRSI Help"]) {
     629
     630    if ([anItem action] == @selector(resetSession:))
    611631                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
    614639        return NO;
    615640}
Note: See TracChangeset for help on using the changeset viewer.