Changeset 113 for trunk/Cocoa/Pester/Source/PSAlarmAlertController.m
- Timestamp:
- 03/10/03 05:48:21 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source/PSAlarmAlertController.m
r105 r113 50 50 } 51 51 52 - (void)performAlertsForAlarm:(PSAlarm *)alarm; 53 { 54 PSAlerts *alerts = [alarm alerts]; 55 NSArray *allAlerts = [alerts allAlerts]; 56 if ([allAlerts count] == 0) { 57 [self _resumeAlarm: alarm]; 58 } else { 59 pendingAlerts = [[NSMutableSet alloc] init]; 60 [pendingAlerts addObjectsFromArray: allAlerts]; 61 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_alertCompleted:) 62 name: PSAlarmAlertCompletedNotification object: alarm]; 63 [self retain]; // release in _alertCompleted: 64 } 65 [alerts triggerForAlarm: alarm]; 66 if ([alerts requirePesterFrontmost] && ![NSApp isActive]) { // restore frontmost process afterward 67 NSDictionary *activeProcessInfo = [[NSWorkspace sharedWorkspace] activeApplication]; 68 frontmostApp.highLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberHigh"] longValue]; 69 frontmostApp.lowLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberLow"] longValue]; 70 appWasHidden = [NSApp isHidden]; 71 [NSApp activateIgnoringOtherApps: YES]; 72 } 73 } 74 52 75 - (id)initWithAlarm:(PSAlarm *)alarm; 53 76 { 54 77 if ( (self = [super init]) != nil) { 55 PSAlerts *alerts = [alarm alerts]; 56 NSArray *allAlerts = [alerts allAlerts]; 57 if ([allAlerts count] == 0) { 58 [self _resumeAlarm: alarm]; 59 } else { 60 pendingAlerts = [[NSMutableSet alloc] init]; 61 [pendingAlerts addObjectsFromArray: allAlerts]; 62 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_alertCompleted:) 63 name: PSAlarmAlertCompletedNotification object: alarm]; 64 [self retain]; // release in _alertCompleted: 65 } 66 [alerts triggerForAlarm: alarm]; 67 if ([alerts requirePesterFrontmost] && ![NSApp isActive]) { // restore frontmost process afterward 68 NSDictionary *activeProcessInfo = [[NSWorkspace sharedWorkspace] activeApplication]; 69 frontmostApp.highLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberHigh"] longValue]; 70 frontmostApp.lowLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberLow"] longValue]; 71 appWasHidden = [NSApp isHidden]; 72 [NSApp activateIgnoringOtherApps: YES]; 73 } 78 // because we're called within a notification, and alerts may deliver further notifications, make sure the rest of the notification clients are able to execute first 79 [self performSelector: @selector(performAlertsForAlarm:) withObject: alarm afterDelay: 0]; 74 80 } 75 81 return self;
Note:
See TracChangeset
for help on using the changeset viewer.