Changeset 330

Show
Ignore:
Timestamp:
08/ 6/07 7:01:05 PM (1 year ago)
Author:
nicholas
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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Cocoa/AntiRSI/AntiRSI.h

    r329 r330  
    4040        IBOutlet NSTextField *time; 
    4141        IBOutlet NSTextField *next_break; 
     42    IBOutlet NSTextField *session_time; 
    4243    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; 
    4449     
    4550        // dock icon image 
     
    6065        double work_break_taking_cached_t; 
    6166        double work_break_taking_cached_date; 
     67    double session_t; 
    6268        double date; 
    6369                 
     
    111117- (IBAction)breakNow:(id)sender; 
    112118 
     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 
    113125// one second ticks away ... 
    114126- (void)tick:(NSTimer *)timer; 
     
    126138- (void)endBreak; 
    127139 
    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; 
    133142 
    134143@end 
  • 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} 
  • trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj

    r329 r330  
    342342                        buildSettings = { 
    343343                                GCC_C_LANGUAGE_STANDARD = c99; 
     344                                PREBINDING = NO; 
    344345                        }; 
    345346                        name = Development; 
     
    353354                                ); 
    354355                                GCC_C_LANGUAGE_STANDARD = c99; 
     356                                PREBINDING = NO; 
    355357                        }; 
    356358                        name = Deployment; 
     
    360362                        buildSettings = { 
    361363                                GCC_C_LANGUAGE_STANDARD = c99; 
     364                                PREBINDING = NO; 
    362365                        }; 
    363366                        name = Default; 
  • trunk/Cocoa/AntiRSI/English.lproj/InfoPlist.strings

    r329 r330  
    22 
    33CFBundleName = "AntiRSI"; 
    4 CFBundleShortVersionString = "1.4"; 
    5 CFBundleGetInfoString = "AntiRSI version 1.4, Copyright 2004 Onne Gorter. http://tech.inhelsinki.nl/antirsi/"; 
     4CFBundleShortVersionString = "1.4njr1"; 
     5CFBundleGetInfoString = "AntiRSI version 1.4njr1, Copyright 2004 Onne Gorter. http://tech.inhelsinki.nl/antirsi/"; 
    66NSHumanReadableCopyright = "Copyright Onne Gorter.\nhttp://tech.inhelsinki.nl/antirsi/"; 
  • trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib

    r325 r330  
    22    IBClasses = ( 
    33        { 
    4             ACTIONS = {breakNow = id; postpone = id; };  
     4            ACTIONS = { 
     5                breakNow = id;  
     6                checkForUpdate = id;  
     7                gotoWebsite = id;  
     8                postpone = id;  
     9                resetSession = id;  
     10            };  
    511            CLASS = AntiRSI;  
    612            LANGUAGE = ObjC;  
    713            OUTLETS = { 
     14                "dock_menu" = NSMenu;  
    815                "next_break" = NSTextField;  
    916                postpone = NSButton;  
    1017                progress = NSLevelIndicator;  
     18                "session_time" = NSTextField;  
     19                "session_time_item" = NSMenuItem;  
    1120                status = NSTextField;  
    1221                time = NSTextField;  
     22                version = NSTextField;  
    1323                view = AntiRSIView;  
    1424            };  
  • trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib

    r329 r330  
    44<dict> 
    55        <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> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
    99                <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> 
    1111                <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> 
    1313                <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> 
    1515        </dict> 
    1616        <key>IBFramework Version</key> 
    17         <string>443.0</string> 
     17        <string>446.1</string> 
     18        <key>IBOldestOS</key> 
     19        <integer>4</integer> 
    1820        <key>IBOpenObjects</key> 
    1921        <array> 
    20                 <integer>343</integer> 
    21                 <integer>259</integer> 
    22                 <integer>29</integer> 
     22                <integer>21</integer> 
    2323        </array> 
    2424        <key>IBSystem Version</key> 
    25         <string>8G32</string> 
     25        <string>8R2232</string> 
    2626</dict> 
    2727</plist> 
  • trunk/Cocoa/AntiRSI/Info.plist

    r329 r330  
    1818        <string>ONNE</string> 
    1919        <key>CFBundleVersion</key> 
    20         <string>1.4</string> 
     20        <string>1.4njr1</string> 
    2121        <key>NSMainNibFile</key> 
    2222        <string>MainMenu</string>