Sounds pulldowns only get sounds from the built-in system sound folder. This should avoid an Apple error (and resulting crash) with some wav files on Intel macs.

This commit is contained in:
Mitchell Livingston 2007-02-09 15:02:25 +00:00
parent 131fa9011d
commit c9d2f7005c
2 changed files with 19 additions and 21 deletions

View File

@ -82,20 +82,19 @@
//set play sound //set play sound
NSMutableArray * sounds = [NSMutableArray array]; NSMutableArray * sounds = [NSMutableArray array];
NSEnumerator * soundEnumerator, NSEnumerator * soundEnumerator;
* soundDirectoriesEnumerator = [[NSArray arrayWithObjects: @"System/Library/Sounds",
[NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"], nil] objectEnumerator];
NSString * soundPath, * sound;
//get list of all sounds and sort alphabetically //get list of all sounds and sort alphabetically
while ((soundPath = [soundDirectoriesEnumerator nextObject])) if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: @"System/Library/Sounds"])
if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: soundPath]) {
NSString * sound;
while ((sound = [soundEnumerator nextObject])) while ((sound = [soundEnumerator nextObject]))
{ {
sound = [sound stringByDeletingPathExtension]; sound = [sound stringByDeletingPathExtension];
if ([NSSound soundNamed: sound]) if ([NSSound soundNamed: sound])
[sounds addObject: sound]; [sounds addObject: sound];
} }
}
fSounds = [[sounds sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] retain]; fSounds = [[sounds sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] retain];
} }
@ -146,7 +145,6 @@
//set port //set port
[fPortField setIntValue: [fDefaults integerForKey: @"BindPort"]]; [fPortField setIntValue: [fDefaults integerForKey: @"BindPort"]];
[self updatePortStatus]; [self updatePortStatus];
fNatStatus = -1; fNatStatus = -1;
@ -419,32 +417,33 @@
- (void) setSound: (id) sender - (void) setSound: (id) sender
{ {
//play sound when selecting //play sound when selecting
NSString * soundName = [sender titleOfSelectedItem];
NSSound * sound; NSSound * sound;
if ((sound = [NSSound soundNamed: soundName])) if ((sound = [NSSound soundNamed: [sender titleOfSelectedItem]]))
[sound play]; [sound play];
} }
- (void) setUpdate: (id) sender - (void) setUpdate: (id) sender
{ {
int index = [fUpdatePopUp indexOfSelectedItem]; int index = [fUpdatePopUp indexOfSelectedItem];
NSString * update;
NSTimeInterval seconds; NSTimeInterval seconds;
if (index == UPDATE_DAILY) if (index == UPDATE_DAILY)
{ {
[fDefaults setObject: @"Daily" forKey: @"UpdateCheck"]; update = @"Daily";
seconds = 86400; seconds = 86400;
} }
else if (index == UPDATE_WEEKLY) else if (index == UPDATE_WEEKLY)
{ {
[fDefaults setObject: @"Weekly" forKey: @"UpdateCheck"]; update = @"Weekly";
seconds = 604800; seconds = 604800;
} }
else else
{ {
[fDefaults setObject: @"Never" forKey: @"UpdateCheck"]; update = @"Never";
seconds = 0; seconds = 0;
} }
[fDefaults setObject: update forKey: @"UpdateCheck"];
[fDefaults setInteger: seconds forKey: @"SUScheduledCheckInterval"]; [fDefaults setInteger: seconds forKey: @"SUScheduledCheckInterval"];
if (fUpdater) if (fUpdater)

View File

@ -1261,7 +1261,6 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
- (NSImage *) advancedBar - (NSImage *) advancedBar
{ {
int h;
uint32_t * p; uint32_t * p;
uint8_t * bitmapData = [fBitmap bitmapData]; uint8_t * bitmapData = [fBitmap bitmapData];
int bytesPerRow = [fBitmap bytesPerRow]; int bytesPerRow = [fBitmap bytesPerRow];
@ -1271,7 +1270,7 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[self getAvailability: piecesAvailablity size: pieceCount]; [self getAvailability: piecesAvailablity size: pieceCount];
//lines 2 to 14: blue, green, or gray depending on whether we have the piece or not //lines 2 to 14: blue, green, or gray depending on whether we have the piece or not
int i, index = 0; int i, h, index = 0;
float increment = (float)pieceCount / (float)MAX_PIECES, indexValue = 0; float increment = (float)pieceCount / (float)MAX_PIECES, indexValue = 0;
uint32_t color; uint32_t color;
BOOL change; BOOL change;