Changeset 332
- Timestamp:
- 08/09/07 05:48:07 (17 years ago)
- Location:
- trunk/Cocoa/AntiRSI
- Files:
-
- 10 added
- 1 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI
-
Property svn:ignore
set to
build
-
Property svn:ignore
set to
-
trunk/Cocoa/AntiRSI/AUTHORS
r327 r332 1 Onne Gorter <o.gorter@student.utwente.nl> 1 Onne Gorter <o.gorter@gmail.com> 2 Nicholas Riley <antirsi@sabi.net> -
trunk/Cocoa/AntiRSI/AntiRSI.h
r331 r332 21 21 #import <Cocoa/Cocoa.h> 22 22 #import "AntiRSIView.h" 23 #import "CTBadge.h" 23 24 24 #define sLatestVersionURL @"http:// tech.inhelsinki.nl/antirsi/antirsi_version.txt"25 #define sURL @"http:// tech.inhelsinki.nl/antirsi/"26 #define sVersion @"1.4 "25 #define sLatestVersionURL @"http://web.sabi.net/nriley/software/AntiRSI-version.txt" 26 #define sURL @"http://web.sabi.net/nriley/software/#antirsi" 27 #define sVersion @"1.4njr2" 27 28 28 29 typedef enum _AntiRSIState { … … 43 44 IBOutlet NSTextField *status; 44 45 IBOutlet NSTextField *version; // XXX unused? 46 IBOutlet NSDatePicker *reset_session_time; 45 47 46 48 // dock menu … … 51 53 NSImage* dock_image; 52 54 NSImage* original_dock_image; 55 CTBadge* dock_badge; 53 56 54 57 // window to display the views in … … 67 70 double session_t; 68 71 double date; 72 double reset_session_date; 69 73 70 74 // various timing lengths … … 79 83 bool lock_focus; 80 84 bool draw_dock_image; 85 bool draw_dock_badge; 81 86 bool draw_dock_image_q; 87 bool reset_session_timer_daily; 88 bool reset_session_timer_after; 89 NSDate *reset_session_timer_time; 90 int reset_session_timer_after_hours; 82 91 83 92 // various colors -
trunk/Cocoa/AntiRSI/AntiRSI.m
r331 r332 102 102 [elapsed autorelease]; 103 103 elapsed=[c retain]; 104 [dock_badge setBadgeColor:elapsed]; 104 105 [self drawDockImage]; 105 106 } … … 152 153 original_dock_image = [NSImage imageNamed:@"AntiRSI"]; 153 154 draw_dock_image_q = YES; 155 dock_badge = [[CTBadge systemBadge] retain]; 156 [dock_badge setBadgeColor:elapsed]; 154 157 155 158 // setup main window that will show either micropause or workbreak … … 165 168 [main_window center]; 166 169 [main_window setContentView:view]; 170 NSTimeZone *utcZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; 171 [reset_session_time setTimeZone:utcZone]; 167 172 [progress setEnabled:NO]; 168 173 NSFont *myriad = [NSFont fontWithName: @"Myriad" size: 40]; … … 181 186 182 187 // create initial values 183 NSMutableDictionary* initial = [NSMutableDictionary dictionaryWithCapacity:10]; 184 [initial setObject:[NSNumber numberWithFloat:4] forKey:@"micro_pause_period"]; 185 [initial setObject:[NSNumber numberWithFloat:13] forKey:@"micro_pause_duration"]; 186 [initial setObject:[NSNumber numberWithFloat:50] forKey:@"work_break_period"]; 187 [initial setObject:[NSNumber numberWithFloat:8] forKey:@"work_break_duration"]; 188 [initial setObject:@"Smooth" forKey:@"sample_interval"]; 189 [initial setObject:[NSNumber numberWithBool:YES] forKey:@"draw_dock_image"]; 190 [initial setObject:[NSNumber numberWithBool:NO] forKey:@"lock_focus"]; 191 [initial setObject:[NSArchiver archivedDataWithRootObject:elapsed] forKey:@"elapsed"]; 192 [initial setObject:[NSArchiver archivedDataWithRootObject:taking] forKey:@"taking"]; 193 [initial setObject:[NSArchiver archivedDataWithRootObject:background] forKey:@"background"]; 194 [[NSUserDefaultsController sharedUserDefaultsController] setInitialValues:initial]; 188 NSUserDefaultsController *dc = [NSUserDefaultsController sharedUserDefaultsController]; 189 NSMutableDictionary* initial = [NSMutableDictionary dictionaryWithObjectsAndKeys: 190 [NSNumber numberWithFloat:4], @"micro_pause_period", 191 [NSNumber numberWithFloat:13], @"micro_pause_duration", 192 [NSNumber numberWithFloat:50], @"work_break_period", 193 [NSNumber numberWithFloat:8], @"work_break_duration", 194 @"Smooth", @"sample_interval", 195 [NSNumber numberWithBool:YES], @"draw_dock_image", 196 [NSNumber numberWithBool:YES], @"draw_dock_badge", 197 [NSNumber numberWithBool:NO], @"lock_focus", 198 [NSNumber numberWithBool:NO], @"reset_session_timer_daily", 199 [NSNumber numberWithBool:NO], @"reset_session_timer_after", 200 [NSCalendarDate dateWithYear:2000 month:1 day:1 hour:6 minute:0 second:0 timeZone:utcZone], @"reset_session_timer_time", 201 [NSNumber numberWithInt:8], @"reset_session_timer_after_hours", 202 [NSArchiver archivedDataWithRootObject:elapsed], @"elapsed", 203 [NSArchiver archivedDataWithRootObject:taking], @"taking", 204 [NSArchiver archivedDataWithRootObject:background], @"background", 205 nil]; 206 [[NSUserDefaults standardUserDefaults] registerDefaults:initial]; 207 [dc setInitialValues:initial]; 195 208 196 209 // bind to defauls controller 197 id dc = [NSUserDefaultsController sharedUserDefaultsController];198 210 [self bind:@"micro_pause_period" toObject:dc withKeyPath:@"values.micro_pause_period" options:nil]; 199 211 [self bind:@"micro_pause_duration" toObject:dc withKeyPath:@"values.micro_pause_duration" options:nil]; … … 202 214 [self bind:@"sample_interval" toObject:dc withKeyPath:@"values.sample_interval" options:nil]; 203 215 [self bind:@"draw_dock_image" toObject:dc withKeyPath:@"values.draw_dock_image" options:nil]; 216 [self bind:@"draw_dock_badge" toObject:dc withKeyPath:@"values.draw_dock_badge" options:nil]; 204 217 [self bind:@"lock_focus" toObject:dc withKeyPath:@"values.lock_focus" options:nil]; 218 [self bind:@"reset_session_timer_daily" toObject:dc withKeyPath:@"values.reset_session_timer_daily" options:nil]; 219 [self bind:@"reset_session_timer_after" toObject:dc withKeyPath:@"values.reset_session_timer_after" options:nil]; 220 [self bind:@"reset_session_timer_time" toObject:dc withKeyPath:@"values.reset_session_timer_time" options:nil]; 221 [self bind:@"reset_session_timer_after_hours" toObject:dc withKeyPath:@"values.reset_session_timer_after_hours" options:nil]; 205 222 NSDictionary* unarchive = [NSDictionary dictionaryWithObject:NSUnarchiveFromDataTransformerName forKey:@"NSValueTransformerName"]; 206 223 [self bind:@"elapsed" toObject:dc withKeyPath:@"values.elapsed" options:unarchive]; 207 224 [self bind:@"taking" toObject:dc withKeyPath:@"values.taking" options:unarchive]; 208 225 [self bind:@"background" toObject:dc withKeyPath:@"values.background" options:unarchive]; 209 226 227 // watch for timer changes 228 [dc addObserver:self forKeyPath:@"values.reset_session_timer_time" options:0 context:NULL]; 229 210 230 // alert every binding 211 [ [NSUserDefaultsController sharedUserDefaultsController]revert:self];231 [dc revert:self]; 212 232 213 233 // start the timer … … 218 238 } 219 239 240 - (void)computeResetSessionDate; 241 { 242 NSTimeZone *systemZone = [NSTimeZone systemTimeZone]; 243 NSCalendarDate *today = [NSCalendarDate calendarDate]; 244 NSCalendarDate *reset = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate:[reset_session_timer_time timeIntervalSinceReferenceDate]]; 245 [reset setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; 246 reset = [NSCalendarDate dateWithYear:[today yearOfCommonEra] 247 month:[today monthOfYear] 248 day:[today dayOfMonth] 249 hour:[reset hourOfDay] 250 minute:[reset minuteOfHour] 251 second:0 252 timeZone:systemZone]; 253 if ([today compare:reset] != NSOrderedAscending) 254 reset = [reset dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0]; 255 reset_session_date = [reset timeIntervalSinceReferenceDate]; 256 } 257 258 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; 259 { 260 if ([keyPath isEqualToString:@"values.reset_session_timer_time"]) 261 [self computeResetSessionDate]; 262 } 263 220 264 // tick every second and update status 221 265 - (void)tick:(NSTimer *)timer 222 266 { 223 267 // calculate time since last tick 224 doublenew_date = [NSDate timeIntervalSinceReferenceDate];225 doubletick_time = new_date - date;268 NSTimeInterval new_date = [NSDate timeIntervalSinceReferenceDate]; 269 NSTimeInterval tick_time = new_date - date; 226 270 date = new_date; 227 271 272 if (reset_session_timer_daily && date >= reset_session_date) { 273 [self resetSession:nil]; 274 [self computeResetSessionDate]; 275 return; 276 } 277 228 278 // check if we are still on track of normal time, otherwise we might have slept or something 229 279 if (tick_time > work_break_duration) { … … 268 318 } 269 319 // NSLog(@"CGEventSource %.2f, CGS %.2f", idle_time, cgs_idle_time); 320 321 if (reset_session_timer_after && idle_time > reset_session_timer_after_hours * 3600) { 322 [self resetSession:nil]; 323 return; 324 } 270 325 271 326 // calculate slack, this gives a sort of 3 history filtered idea. … … 476 531 [p stroke]; 477 532 533 // draw session time 534 if (draw_dock_badge) { 535 static NSImage *badge = nil; 536 static int badge_session_minutes = -1; 537 int session_minutes = (int)session_t / 60; 538 if (badge_session_minutes != session_minutes) { 539 if (badge != nil) [badge release]; 540 badge = [[dock_badge badgeOverlayImageForString: [NSString stringWithFormat:@"%d:%02d", session_minutes / 60, session_minutes % 60] insetX: 3 y: 3] retain]; 541 badge_session_minutes = session_minutes; 542 } 543 [badge compositeToPoint:NSZeroPoint operation:NSCompositeSourceOver]; 544 } 545 478 546 [dock_image unlockFocus]; 479 547 -
trunk/Cocoa/AntiRSI/AntiRSI.xcodeproj/project.pbxproj
r330 r332 8 8 9 9 /* Begin PBXBuildFile section */ 10 464D9ADE0C6A622B005A0582 /* CTBadge.h in Headers */ = {isa = PBXBuildFile; fileRef = 464D9ADA0C6A622B005A0582 /* CTBadge.h */; }; 11 464D9ADF0C6A622B005A0582 /* CTBadge.m in Sources */ = {isa = PBXBuildFile; fileRef = 464D9ADB0C6A622B005A0582 /* CTBadge.m */; }; 12 464D9AE00C6A622B005A0582 /* CTGradient.h in Headers */ = {isa = PBXBuildFile; fileRef = 464D9ADC0C6A622B005A0582 /* CTGradient.h */; }; 13 464D9AE10C6A622B005A0582 /* CTGradient.m in Sources */ = {isa = PBXBuildFile; fileRef = 464D9ADD0C6A622B005A0582 /* CTGradient.m */; }; 14 464D9B790C6A760B005A0582 /* CTBadge_1.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 464D9B750C6A760B005A0582 /* CTBadge_1.pdf */; }; 15 464D9B7A0C6A760B005A0582 /* CTBadge_3.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 464D9B760C6A760B005A0582 /* CTBadge_3.pdf */; }; 16 464D9B7B0C6A760B005A0582 /* CTBadge_4.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 464D9B770C6A760B005A0582 /* CTBadge_4.pdf */; }; 17 464D9B7C0C6A760B005A0582 /* CTBadge_5.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 464D9B780C6A760B005A0582 /* CTBadge_5.pdf */; }; 10 18 4DB6164E061B59EA002EF355 /* AntiRSI.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DB6164C061B59EA002EF355 /* AntiRSI.h */; }; 11 19 4DB6164F061B59EA002EF355 /* AntiRSI.m in Sources */ = {isa = PBXBuildFile; fileRef = 4DB6164D061B59EA002EF355 /* AntiRSI.m */; }; … … 31 39 29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; 32 40 32CA4F630368D1EE00C91783 /* AntiRSI_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AntiRSI_Prefix.pch; sourceTree = "<group>"; }; 41 464D9ADA0C6A622B005A0582 /* CTBadge.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CTBadge.h; path = CTBadge/CTBadge.h; sourceTree = "<group>"; }; 42 464D9ADB0C6A622B005A0582 /* CTBadge.m */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; name = CTBadge.m; path = CTBadge/CTBadge.m; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; }; 43 464D9ADC0C6A622B005A0582 /* CTGradient.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CTGradient.h; path = CTBadge/CTGradient.h; sourceTree = "<group>"; }; 44 464D9ADD0C6A622B005A0582 /* CTGradient.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = CTGradient.m; path = CTBadge/CTGradient.m; sourceTree = "<group>"; }; 45 464D9B750C6A760B005A0582 /* CTBadge_1.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_1.pdf; sourceTree = "<group>"; }; 46 464D9B760C6A760B005A0582 /* CTBadge_3.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_3.pdf; sourceTree = "<group>"; }; 47 464D9B770C6A760B005A0582 /* CTBadge_4.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_4.pdf; sourceTree = "<group>"; }; 48 464D9B780C6A760B005A0582 /* CTBadge_5.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = CTBadge_5.pdf; sourceTree = "<group>"; }; 33 49 4DB6164C061B59EA002EF355 /* AntiRSI.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AntiRSI.h; sourceTree = "<group>"; }; 34 50 4DB6164D061B59EA002EF355 /* AntiRSI.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = AntiRSI.m; sourceTree = "<group>"; wrapsLines = 1; }; … … 99 115 children = ( 100 116 080E96DDFE201D6D7F000001 /* Classes */, 117 464D9AE40C6A622F005A0582 /* CTBadge */, 101 118 29B97315FDCFA39411CA2CEA /* Other Sources */, 102 119 29B97317FDCFA39411CA2CEA /* Resources */, … … 134 151 ); 135 152 name = Frameworks; 153 sourceTree = "<group>"; 154 }; 155 464D9AE40C6A622F005A0582 /* CTBadge */ = { 156 isa = PBXGroup; 157 children = ( 158 464D9B740C6A760B005A0582 /* badges */, 159 464D9ADA0C6A622B005A0582 /* CTBadge.h */, 160 464D9ADB0C6A622B005A0582 /* CTBadge.m */, 161 464D9ADC0C6A622B005A0582 /* CTGradient.h */, 162 464D9ADD0C6A622B005A0582 /* CTGradient.m */, 163 ); 164 name = CTBadge; 165 sourceTree = "<group>"; 166 }; 167 464D9B740C6A760B005A0582 /* badges */ = { 168 isa = PBXGroup; 169 children = ( 170 464D9B750C6A760B005A0582 /* CTBadge_1.pdf */, 171 464D9B760C6A760B005A0582 /* CTBadge_3.pdf */, 172 464D9B770C6A760B005A0582 /* CTBadge_4.pdf */, 173 464D9B780C6A760B005A0582 /* CTBadge_5.pdf */, 174 ); 175 name = badges; 176 path = CTBadge/badges; 136 177 sourceTree = "<group>"; 137 178 }; … … 147 188 4DF73F68061E136200B0D9C9 /* AntiRSIView.h in Headers */, 148 189 E1F60362098592D800806C3B /* AntiRSILevelIndicator.h in Headers */, 190 464D9ADE0C6A622B005A0582 /* CTBadge.h in Headers */, 191 464D9AE00C6A622B005A0582 /* CTGradient.h in Headers */, 149 192 ); 150 193 runOnlyForDeploymentPostprocessing = 0; … … 202 245 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, 203 246 4DF73F86061E155C00B0D9C9 /* AntiRSI.icns in Resources */, 247 464D9B790C6A760B005A0582 /* CTBadge_1.pdf in Resources */, 248 464D9B7A0C6A760B005A0582 /* CTBadge_3.pdf in Resources */, 249 464D9B7B0C6A760B005A0582 /* CTBadge_4.pdf in Resources */, 250 464D9B7C0C6A760B005A0582 /* CTBadge_5.pdf in Resources */, 204 251 ); 205 252 runOnlyForDeploymentPostprocessing = 0; … … 216 263 4DF73F67061E136200B0D9C9 /* AntiRSIView.m in Sources */, 217 264 E1F60361098592D800806C3B /* AntiRSILevelIndicator.m in Sources */, 265 464D9ADF0C6A622B005A0582 /* CTBadge.m in Sources */, 266 464D9AE10C6A622B005A0582 /* CTGradient.m in Sources */, 218 267 ); 219 268 runOnlyForDeploymentPostprocessing = 0; -
trunk/Cocoa/AntiRSI/English.lproj
-
Property svn:ignore
set to
*~*
-
Property svn:ignore
set to
-
trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/classes.nib
r330 r332 16 16 postpone = NSButton; 17 17 progress = NSLevelIndicator; 18 "reset_session_time" = NSDatePicker; 18 19 "session_time" = NSTextField; 19 20 "session_time_item" = NSMenuItem; … … 32 33 {CLASS = AntiRSIView; LANGUAGE = ObjC; SUPERCLASS = NSView; }, 33 34 {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 35 {CLASS = NSDatePicker; LANGUAGE = ObjC; SUPERCLASS = NSControl; }, 34 36 {CLASS = NSLevelIndicator; LANGUAGE = ObjC; SUPERCLASS = NSControl; } 35 37 ); -
trunk/Cocoa/AntiRSI/English.lproj/MainMenu.nib/info.nib
r331 r332 8 8 <dict> 9 9 <key>259</key> 10 <string>6 88 524 300 322 0 0 1680 1028 </string>10 <string>668 524 300 322 0 0 1680 1028 </string> 11 11 <key>29</key> 12 12 <string>276 845 249 44 0 0 1680 1028 </string> … … 20 20 <key>IBOpenObjects</key> 21 21 <array> 22 <integer>21</integer>23 22 <integer>259</integer> 24 23 </array> -
trunk/Cocoa/AntiRSI/Info.plist
r330 r332 18 18 <string>ONNE</string> 19 19 <key>CFBundleVersion</key> 20 <string>1.4njr 1</string>20 <string>1.4njr2</string> 21 21 <key>NSMainNibFile</key> 22 22 <string>MainMenu</string>
Note:
See TracChangeset
for help on using the changeset viewer.