source: trunk/Cocoa/Pester/Source/PSAlerts.m@ 361

Last change on this file since 361 was 361, checked in by Nicholas Riley, 16 years ago

VERSION: Updated for 1.1b5.

English.lproj/InfoPlist.strings: Updated for 1.1b5.

English.lproj/MainMenu.nib: Change IB compatibility level to 10.4.
Disable controls which lead to unstable functionality in this version.
Added Sparkle support. Hook up removeMessageButton to
PSAlarmSetController for "-" fallback drawing.

English.lproj/Preferences.nib: Added Sparkle checkbox.

English.lproj/Read Me.nib: Leopard-ized with source list coloring,
highlight and removed focus ring (which caused artifacts anyway).

English.lproj/Snooze until.nib: Use new natural language date strings
and calendar button bezel style.

Info-Pester.plist: Updated for 1.1b5. Added Sparkle support.

NJRDateFormatter.m: Comment out debug logging on every keystroke.

PSAlarmSetController.[hm]: If "-" image exists (on Leopard), don't
draw it with text as well.

PSAlerts.m: Don't describe bounce alert (which is present for
backwards compatibility, but doesn't work yet in this version).

PSPowerManager.m: Temporarily disable; untested in this version.

Pester.xcodeproj: Change Development/Deployment to Debug/Release.
Link to Sparkle. STRIP_INSTALLED_PRODUCT=NO on release version for
now (eventually, can investigate using symbol files).

Read Me.rtfd: Updated for 1.1b5. Use real links. Clean up release
notes. Credit Sparkle and Date::Manip. Clean up styles so they look
better in the read me viewer. Fix Omni link.

Sparkle.diff: Changes to Sparkle, which is included as an external.
These aren't yet automatically applied.

Updates/Application icon.png: The icon converted to a PNG. This will
probably go away as it's too big.

Updates/release-notes.css: Release notes CSS based on the example that
comes with Sparkle.

Updates/release-notes.html: Dummy release notes file; nobody should
see this yet.

Updates/updates.xml: Initial Sparkle appcast file.

package-Pester.sh: Update for xcodebuild, Sparkle, etc. No longer
include source in download.

File size: 3.9 KB
RevLine 
[53]1//
2// PSAlerts.m
3// Pester
4//
5// Created by Nicholas Riley on Sat Dec 21 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9#import "PSAlerts.h"
10#import "PSAlert.h"
11#import "PSDockBounceAlert.h"
12#import "PSNotifierAlert.h"
13#import "PSBeepAlert.h"
14
15// property list keys
16static NSString * const PLAlerts = @"alerts"; // NSString
17
18@implementation PSAlerts
19
20#pragma mark initialize-release
21
22- (id)init;
23{
24 if ( (self = [super init]) != nil) {
25 alerts = [[NSMutableArray alloc] initWithCapacity: 4];
26 }
27 return self;
28}
29
30- (id)initWithPesterVersion1Alerts;
31{
32 if ( (self = [self init]) != nil) {
33 [self addAlert: [PSDockBounceAlert alert]];
34 [self addAlert: [PSNotifierAlert alert]];
35 [self addAlert: [PSBeepAlert alertWithRepetitions: 1]];
36 }
37 return self;
38}
39
40- (void)dealloc;
41{
42 [alerts release]; alerts = nil;
[355]43 [super dealloc];
[53]44}
45
46#pragma mark accessing
47
48- (void)addAlert:(PSAlert *)alert;
49{
50 [alerts addObject: alert];
51 if ([alert requiresPesterFrontmost])
52 requirePesterFrontmost = YES;
53}
54
55- (void)removeAlerts;
56{
57 [alerts removeAllObjects];
58 requirePesterFrontmost = NO;
59}
60
61- (NSEnumerator *)alertEnumerator;
62{
63 return [alerts objectEnumerator];
64}
65
66- (NSArray *)allAlerts;
67{
68 return [[alerts copy] autorelease];
69}
70
71- (BOOL)requirePesterFrontmost;
72{
73 return requirePesterFrontmost;
74}
75
76#pragma mark actions
77
[61]78- (void)prepareForAlarm:(PSAlarm *)alarm;
79{
80 [alerts makeObjectsPerformSelector: @selector(prepareForAlarm:) withObject: alarm];
81}
82
[53]83- (void)triggerForAlarm:(PSAlarm *)alarm;
84{
85 [alerts makeObjectsPerformSelector: @selector(triggerForAlarm:) withObject: alarm];
86}
87
88#pragma mark printing
89
90- (NSAttributedString *)prettyList;
91{
92 NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
93 NSEnumerator *e = [self alertEnumerator];
94 PSAlert *alert;
95 unsigned int length;
96 while ( (alert = [e nextObject]) != nil) {
[361]97 if ([alert isKindOfClass: [PSDockBounceAlert class]]) // XXX temporary for 1.1b5
98 continue;
[103]99 [string appendAttributedString: [NSLocalizedString(@"* ", "Unordered list label (usually a bullet followed by a space)") small]];
[53]100 [string appendAttributedString: [alert actionDescription]];
101 [string appendAttributedString: [@"\n" small]];
102 }
103 if ( (length = [string length]) == 0) {
104 [string release];
105 return nil;
106 } else {
107 NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
108 [string deleteCharactersInRange: NSMakeRange(length - 1, 1)]; // remove trailing newline
[103]109 [paraStyle setHeadIndent: [[string attribute: NSFontAttributeName atIndex: 0 effectiveRange: NULL] widthOfString: NSLocalizedString(@"* ", "Unordered list label (usually a bullet followed by a space)")]];
[53]110 [string addAttribute: NSParagraphStyleAttributeName value: paraStyle range: NSMakeRange(0, length - 1)];
111 [paraStyle release]; paraStyle = nil;
112 return [string autorelease];
113 }
114}
115
116#pragma mark property list serialization (Pester 1.1)
117
118- (NSDictionary *)propertyListRepresentation;
119{
120 NSMutableArray *plAlerts = [[NSMutableArray alloc] initWithCapacity: [alerts count]];
121 NSEnumerator *e = [self alertEnumerator];
122 PSAlert *alert;
123 while ( (alert = [e nextObject]) != nil) {
124 [plAlerts addObject: [alert propertyListRepresentation]];
125 }
[355]126 NSDictionary *dict = [NSDictionary dictionaryWithObject: plAlerts forKey: PLAlerts];
127 [plAlerts release];
128 return dict;
[53]129}
130
131- (id)initWithPropertyList:(NSDictionary *)dict;
132{
133 if ( (self = [self init]) != nil) {
134 NSArray *plAlerts = [dict objectForKey: PLAlerts];
135 NSEnumerator *e = [plAlerts objectEnumerator];
136 NSDictionary *alertDict;
137 while ( (alertDict = [e nextObject]) != nil) {
138 [self addAlert: [[PSAlert alloc] initWithPropertyList: alertDict]];
139 }
140 }
141 return self;
142}
143
144@end
Note: See TracBrowser for help on using the repository browser.