Index: trunk/Cocoa/AntiRSI/AntiRSI.h
===================================================================
--- trunk/Cocoa/AntiRSI/AntiRSI.h (revision 329)
+++ trunk/Cocoa/AntiRSI/AntiRSI.h (revision 330)
@@ -40,6 +40,11 @@
IBOutlet NSTextField *time;
IBOutlet NSTextField *next_break;
+ IBOutlet NSTextField *session_time;
IBOutlet NSTextField *status;
- IBOutlet NSTextField *version;
+ IBOutlet NSTextField *version; // XXX unused?
+
+ // dock menu
+ IBOutlet NSMenu *dock_menu;
+ IBOutlet NSMenuItem *session_time_item;
// dock icon image
@@ -60,4 +65,5 @@
double work_break_taking_cached_t;
double work_break_taking_cached_date;
+ double session_t;
double date;
@@ -111,4 +117,10 @@
- (IBAction)breakNow:(id)sender;
+// reset session time menu item
+- (IBAction)resetSession:(id)sender;
+
+// returns string of the form "Session: 12:34:56"
+- (NSString *)sessionTimeString;
+
// one second ticks away ...
- (void)tick:(NSTimer *)timer;
@@ -126,9 +138,6 @@
- (void)endBreak;
-// time left string
-- (void)drawTimeLeft:(double)seconds;
-
-// time to next break string
-- (void)drawNextBreak:(int)seconds;
+// update window
+- (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak;
@end
Index: trunk/Cocoa/AntiRSI/AntiRSI.m
===================================================================
--- trunk/Cocoa/AntiRSI/AntiRSI.m (revision 329)
+++ trunk/Cocoa/AntiRSI/AntiRSI.m (revision 330)
@@ -279,4 +279,7 @@
micro_pause_t += tick_time;
work_break_t += tick_time;
+ if (idle_time < 1) {
+ session_t += tick_time;
+ }
micro_pause_taking_t = 0;
if (work_break_taking_t > 0) {
@@ -338,17 +341,11 @@
if (idle_time < 1 && !slack) {
micro_pause_taking_t = 0;
+ session_t += tick_time;
}
// update window
- [progress setDoubleValue:micro_pause_taking_t];
- [self drawTimeLeft:micro_pause_duration - micro_pause_taking_t];
- [self drawNextBreak:work_break_period - work_break_t];
-
- // if user likes to be interrupted
- if (lock_focus) {
- [NSApp activateIgnoringOtherApps:YES];
- [main_window makeKeyAndOrderFront:self];
- }
-
+ [self updateBreakWindowDuration:micro_pause_duration progress:micro_pause_taking_t
+ nextBreak:work_break_period - work_break_t];
+
// check if we done enough
if (micro_pause_taking_t > micro_pause_duration) {
@@ -375,16 +372,11 @@
if (idle_time >= 2 || work_break_taking_t < 3) {
work_break_taking_t += tick_time;
- }
+ } else if (idle_time < 1) {
+ session_t += tick_time;
+ }
// draw window
- [progress setDoubleValue:work_break_taking_t / 60 - 0.5];
- [self drawTimeLeft:work_break_duration - work_break_taking_t];
- [self drawNextBreak:work_break_period + work_break_duration - work_break_taking_t];
-
- // if user likes to be interrupted
- if (lock_focus) {
- [NSApp activateIgnoringOtherApps:YES];
- [main_window makeKeyAndOrderFront:self];
- }
+ [self updateBreakWindowDuration:work_break_duration progress:work_break_taking_t
+ nextBreak:work_break_period + work_break_duration - work_break_taking_t];
// and check if we done enough
@@ -404,4 +396,11 @@
// draw dock image
if (draw_dock_image) [self drawDockImage];
+}
+
+// dock image
+- (NSMenu *)applicationDockMenu:(NSApplication *)sender;
+{
+ [session_time_item setTitle:[self sessionTimeString]];
+ return dock_menu;
}
@@ -522,14 +521,23 @@
}
-// diplays time left
-- (void)drawTimeLeft:(double)seconds
-{
- [time setStringValue:[NSString stringWithFormat:@"%d:%02d", lrint(seconds) / 60, lrint(seconds) % 60]];
-}
-
-// displays next break
-- (void)drawNextBreak:(int)seconds
-{
- int minutes = round(seconds / 60.0) ;
+- (NSString *)sessionTimeString;
+{
+ return [NSString stringWithFormat:@"Session: %d:%02d:%02d", (int)session_t / 3600, (int)session_t / 60, lrint(session_t) % 60];
+}
+
+- (void)updateBreakWindowDuration:(double)duration progress:(double)progress_t nextBreak:(double)nextBreak;
+{
+ // progress
+ [progress setDoubleValue:duration >= 60 ? (progress_t / 60 - 0.5) : progress_t];
+
+ // time left
+ double timeLeft = duration - progress_t;
+ [time setStringValue:[NSString stringWithFormat:@"%d:%02d", (int)timeLeft / 60, lrint(timeLeft) % 60]];
+
+ // cumulative typing time in this session (e.g. today)
+ [session_time setStringValue:[self sessionTimeString]];
+
+ // next break
+ int minutes = round(nextBreak / 60.0);
// nice hours, minutes ...
@@ -540,4 +548,10 @@
[next_break setStringValue:[NSString stringWithFormat:@"next break in %d minutes", minutes]];
}
+
+ // if user likes to be interrupted
+ if (lock_focus) {
+ [NSApp activateIgnoringOtherApps:YES];
+ [main_window makeKeyAndOrderFront:self];
+ }
}
@@ -597,19 +611,30 @@
}
+- (IBAction)resetSession:(id)sender;
+{
+ if (s_normal != state) {
+ [self endBreak];
+ }
+ session_t = 0;
+}
+
// validate menu items
- (BOOL)validateMenuItem:(NSMenuItem *)anItem
{
- if ([[anItem title] isEqualToString:@"Take Break Now"] && state == s_normal) {
+ if ([anItem action] == @selector(breakNow:) && state == s_normal)
return YES;
- }
-
- if ([[anItem title] isEqualToString:@"Postpone Break"] && state == s_taking_work_break) {
+
+ if ([anItem action] == @selector(postpone:) && state == s_taking_work_break)
return YES;
- }
-
- if ([[anItem title] isEqualToString:@"AntiRSI Help"]) {
+
+ if ([anItem action] == @selector(resetSession:))
return YES;
- }
-
+
+ if ([anItem action] == @selector(gotoWebsite:))
+ return YES;
+
+ if ([anItem action] == @selector(checkForUpdate:))
+ return YES;
+
return NO;
}
Index: trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj
===================================================================
--- trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj (revision 329)
+++ trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj (revision 330)
@@ -342,4 +342,5 @@
buildSettings = {
GCC_C_LANGUAGE_STANDARD = c99;
+ PREBINDING = NO;
};
name = Development;
@@ -353,4 +354,5 @@
);
GCC_C_LANGUAGE_STANDARD = c99;
+ PREBINDING = NO;
};
name = Deployment;
@@ -360,4 +362,5 @@
buildSettings = {
GCC_C_LANGUAGE_STANDARD = c99;
+ PREBINDING = NO;
};
name = Default;
Index: trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib
===================================================================
--- trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib (revision 329)
+++ trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib (revision 330)
@@ -2,13 +2,23 @@
IBClasses = (
{
- ACTIONS = {breakNow = id; postpone = id; };
+ ACTIONS = {
+ breakNow = id;
+ checkForUpdate = id;
+ gotoWebsite = id;
+ postpone = id;
+ resetSession = id;
+ };
CLASS = AntiRSI;
LANGUAGE = ObjC;
OUTLETS = {
+ "dock_menu" = NSMenu;
"next_break" = NSTextField;
postpone = NSButton;
progress = NSLevelIndicator;
+ "session_time" = NSTextField;
+ "session_time_item" = NSMenuItem;
status = NSTextField;
time = NSTextField;
+ version = NSTextField;
view = AntiRSIView;
};
Index: trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib
===================================================================
--- trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib (revision 329)
+++ trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib (revision 330)
@@ -4,24 +4,24 @@
IBDocumentLocation
- 35 23 441 309 0 0 1024 746
+ 70 16 441 309 0 0 1680 1028
IBEditorPositions
259
- 490 507 300 322 0 0 1280 1002
+ 688 524 300 322 0 0 1680 1028
29
- 194 823 330 44 0 0 1280 1002
+ 276 845 249 44 0 0 1680 1028
343
- 84 540 189 68 0 0 1280 1002
+ 241 262 145 99 0 0 1680 1028
IBFramework Version
- 443.0
+ 446.1
+ IBOldestOS
+ 4
IBOpenObjects
- 343
- 259
- 29
+ 21
IBSystem Version
- 8G32
+ 8R2232
Index: trunk/Cocoa/AntiRSI/Info.plist
===================================================================
--- trunk/Cocoa/AntiRSI/Info.plist (revision 329)
+++ trunk/Cocoa/AntiRSI/Info.plist (revision 330)
@@ -18,5 +18,5 @@
ONNE
CFBundleVersion
- 1.4
+ 1.4njr1
NSMainNibFile
MainMenu