mirror of
https://github.com/transmission/transmission
synced 2025-03-12 23:23:54 +00:00
experiment with supporting custom user sounds on Leopard
This commit is contained in:
parent
1f95e1d450
commit
6ca3f6516b
1 changed files with 12 additions and 13 deletions
|
@ -310,25 +310,24 @@
|
||||||
{
|
{
|
||||||
NSMutableArray * sounds = [NSMutableArray array];
|
NSMutableArray * sounds = [NSMutableArray array];
|
||||||
|
|
||||||
//until Apple can fix soundNamed to not crash on invalid sound files, don't use custom sounds
|
NSMutableArray * directories = [NSMutableArray arrayWithObjects: @"/System/Library/Sounds", @"/Library/Sounds", nil];
|
||||||
NSArray * directories = [NSArray arrayWithObjects: @"/System/Library/Sounds", @"/Library/Sounds",
|
if ([NSApp isOnLeopardOrBetter])
|
||||||
/*[NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"],*/ nil];
|
[directories addObject: [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"]];
|
||||||
BOOL isDirectory;
|
|
||||||
NSEnumerator * soundEnumerator;
|
|
||||||
NSString * sound;
|
|
||||||
|
|
||||||
|
BOOL isDirectory;
|
||||||
NSString * directory;
|
NSString * directory;
|
||||||
NSEnumerator * enumerator = [directories objectEnumerator];
|
NSEnumerator * enumerator = [directories objectEnumerator];
|
||||||
while ((directory = [enumerator nextObject]))
|
while ((directory = [enumerator nextObject]))
|
||||||
if ([[NSFileManager defaultManager] fileExistsAtPath: directory isDirectory: &isDirectory] && isDirectory)
|
if ([[NSFileManager defaultManager] fileExistsAtPath: directory isDirectory: &isDirectory] && isDirectory)
|
||||||
{
|
{
|
||||||
soundEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath: directory] objectEnumerator];
|
NSString * sound;
|
||||||
while ((sound = [soundEnumerator nextObject]))
|
NSEnumerator * soundEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath: directory] objectEnumerator];
|
||||||
{
|
while ((sound = [soundEnumerator nextObject]))
|
||||||
sound = [sound stringByDeletingPathExtension];
|
{
|
||||||
if ([NSSound soundNamed: sound])
|
sound = [sound stringByDeletingPathExtension];
|
||||||
[sounds addObject: sound];
|
if ([NSSound soundNamed: sound])
|
||||||
}
|
[sounds addObject: sound];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sounds;
|
return sounds;
|
||||||
|
|
Loading…
Add table
Reference in a new issue