Changeset 53 for trunk/Cocoa/Pester/Source/PSMovieAlert.m
- Timestamp:
- 01/02/03 05:30:03 (21 years ago)
- Location:
- trunk/Cocoa/Pester/Source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/Pester/Source
- Property svn:ignore
-
old new 1 1 build 2 .gdb_history
-
- Property svn:ignore
-
trunk/Cocoa/Pester/Source/PSMovieAlert.m
r45 r53 10 10 #import "PSMovieAlert.h" 11 11 #import "PSMovieAlertController.h" 12 #import "NSDictionary-NJRExtensions.h" 12 13 #import "NSMovie-NJRExtensions.h" 14 #import "BDAlias.h" 15 16 // property list keys 17 static NSString * const PLAlertRepetitions = @"times"; // NSString 18 static NSString * const PLAlertAlias = @"alias"; // NSData 13 19 14 20 @implementation PSMovieAlert … … 16 22 + (PSMovieAlert *)alertWithMovieFileAlias:(BDAlias *)anAlias repetitions:(unsigned short)numReps; 17 23 { 18 return [[[self alloc] initWith Alias: anAlias repetitions: numReps] autorelease];24 return [[[self alloc] initWithMovieFileAlias: anAlias repetitions: numReps] autorelease]; 19 25 } 20 26 21 - (id)initWith Alias:(BDAlias *)anAlias repetitions:(unsigned int) numReps;27 - (id)initWithMovieFileAlias:(BDAlias *)anAlias repetitions:(unsigned int) numReps; 22 28 { 23 29 if ( (self = [super init]) != nil) { 30 NSString *path = [anAlias fullPath]; 31 if (path == nil) { 32 [self release]; 33 [NSException raise: PSAlertCreationException format: @"CanÕt locate media to play as alert."]; 34 } 24 35 alias = [anAlias retain]; 25 36 repetitions = numReps; 26 movie = [[NSMovie alloc] initWithURL: [NSURL fileURLWithPath: [anAlias fullPath]] byReference: YES];37 movie = [[NSMovie alloc] initWithURL: [NSURL fileURLWithPath: path] byReference: YES]; 27 38 if (movie == nil) { 28 39 [self release]; … … 46 57 } 47 58 59 - (BOOL)requiresPesterFrontmost; 60 { 61 return hasVideo; 62 } 63 48 64 - (NSMovie *)movie; 49 65 { 50 66 return movie; 67 } 68 69 - (BDAlias *)movieFileAlias; 70 { 71 return alias; 51 72 } 52 73 … … 73 94 } 74 95 96 - (NSAttributedString *)actionDescription; 97 { 98 BOOL isStatic = [movie isStatic]; 99 NSMutableAttributedString *string = [[(isStatic ? @"Show " : @"Play ") small] mutableCopy]; 100 NSString *kindString = nil, *name = [alias displayNameWithKindString: &kindString]; 101 if (name == nil) name = @"ÇcanÕt locate media fileÈ"; 102 else [string appendAttributedString: [[NSString stringWithFormat: @"%@ ", kindString] small]]; 103 [string appendAttributedString: [name underlined]]; 104 if (repetitions > 1 && !isStatic) { 105 [string appendAttributedString: [[NSString stringWithFormat: @" %hu times", repetitions] small]]; 106 } 107 return [string autorelease]; 108 } 109 110 #pragma mark property list serialization (Pester 1.1) 111 112 - (NSDictionary *)propertyListRepresentation; 113 { 114 NSMutableDictionary *plAlert = [[super propertyListRepresentation] mutableCopy]; 115 [plAlert setObject: [NSNumber numberWithUnsignedShort: repetitions] forKey: PLAlertRepetitions]; 116 [plAlert setObject: [alias aliasData] forKey: PLAlertAlias]; 117 return [plAlert autorelease]; 118 } 119 120 - (id)initWithPropertyList:(NSDictionary *)dict; 121 { 122 return [self initWithMovieFileAlias: [BDAlias aliasWithData: [dict objectForRequiredKey: PLAlertAlias]] 123 repetitions: [[dict objectForRequiredKey: PLAlertRepetitions] unsignedShortValue]]; 124 } 125 75 126 @end
Note:
See TracChangeset
for help on using the changeset viewer.