Changeset 333 for trunk/Cocoa/AntiRSI
- Timestamp:
- 08/09/07 09:03:58 (17 years ago)
- Location:
- trunk/Cocoa/AntiRSI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/AntiRSI/AntiRSI.h
r332 r333 87 87 bool reset_session_timer_daily; 88 88 bool reset_session_timer_after; 89 NS Date *reset_session_timer_time;89 NSCalendarDate *reset_session_timer_time; 90 90 int reset_session_timer_after_hours; 91 91 -
trunk/Cocoa/AntiRSI/AntiRSI.m
r332 r333 26 26 extern CFTimeInterval CGSSecondsSinceLastInputEvent(unsigned long eventType); 27 27 28 static int badge_session_minutes = -1; 29 28 30 @implementation AntiRSI 31 32 - (void)computeResetSessionDate; 33 { 34 NSCalendarDate *now = [NSCalendarDate calendarDate]; 35 NSCalendarDate *reset = 36 [NSCalendarDate dateWithYear:[now yearOfCommonEra] 37 month:[now monthOfYear] 38 day:[now dayOfMonth] 39 hour:[reset_session_timer_time hourOfDay] 40 minute:[reset_session_timer_time minuteOfHour] 41 second:0 42 timeZone:[NSTimeZone systemTimeZone]]; 43 if ([now compare:reset] != NSOrderedAscending) 44 reset = [reset dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0]; 45 reset_session_date = [reset timeIntervalSinceReferenceDate]; 46 } 29 47 30 48 // bindings methods … … 53 71 { work_break_period = 60 * round(f); } 54 72 73 - (void)setReset_session_timer_time:(NSDate *)d; 74 { 75 if (reset_session_timer_time != nil) 76 [reset_session_timer_time autorelease]; 77 reset_session_timer_time = [[NSCalendarDate alloc] initWithTimeIntervalSinceReferenceDate:[d timeIntervalSinceReferenceDate]]; 78 [reset_session_timer_time setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; 79 [self computeResetSessionDate]; 80 } 81 55 82 - (void)installTimer:(double)interval 56 83 { … … 103 130 elapsed=[c retain]; 104 131 [dock_badge setBadgeColor:elapsed]; 132 badge_session_minutes = -1; 105 133 [self drawDockImage]; 106 134 } … … 225 253 [self bind:@"background" toObject:dc withKeyPath:@"values.background" options:unarchive]; 226 254 227 // watch for timer changes228 [dc addObserver:self forKeyPath:@"values.reset_session_timer_time" options:0 context:NULL];229 230 255 // alert every binding 231 256 [dc revert:self]; … … 236 261 // about dialog 237 262 [version setStringValue:[NSString stringWithFormat:@"Version %@", sVersion]]; 238 }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:0252 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 } 263 264 … … 534 535 if (draw_dock_badge) { 535 536 static NSImage *badge = nil; 536 static int badge_session_minutes = -1;537 537 int session_minutes = (int)session_t / 60; 538 538 if (badge_session_minutes != session_minutes) {
Note:
See TracChangeset
for help on using the changeset viewer.