Changeset 5577


Ignore:
Timestamp:
Apr 10, 2008, 4:03:12 PM (14 years ago)
Author:
livings124
Message:

experiment with supporting custom user sounds on Leopard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PrefsController.m

    r5565 r5577  
    311311    NSMutableArray * sounds = [NSMutableArray array];
    312312   
    313     //until Apple can fix soundNamed to not crash on invalid sound files, don't use custom sounds
    314     NSArray * directories = [NSArray arrayWithObjects: @"/System/Library/Sounds", @"/Library/Sounds",
    315                                 /*[NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"],*/ nil];
     313    NSMutableArray * directories = [NSMutableArray arrayWithObjects: @"/System/Library/Sounds", @"/Library/Sounds", nil];
     314    if ([NSApp isOnLeopardOrBetter])
     315        [directories addObject: [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"]];
     316   
    316317    BOOL isDirectory;
    317     NSEnumerator * soundEnumerator;
    318     NSString * sound;
    319    
    320318    NSString * directory;
    321319    NSEnumerator * enumerator = [directories objectEnumerator];
     
    323321        if ([[NSFileManager defaultManager] fileExistsAtPath: directory isDirectory: &isDirectory] && isDirectory)
    324322        {
    325                 soundEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath: directory] objectEnumerator];
    326                 while ((sound = [soundEnumerator nextObject]))
    327                 {
    328                     sound = [sound stringByDeletingPathExtension];
    329                     if ([NSSound soundNamed: sound])
    330                         [sounds addObject: sound];
    331                 }
     323            NSString * sound;
     324            NSEnumerator * soundEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath: directory] objectEnumerator];
     325            while ((sound = [soundEnumerator nextObject]))
     326            {
     327                sound = [sound stringByDeletingPathExtension];
     328                if ([NSSound soundNamed: sound])
     329                    [sounds addObject: sound];
     330            }
    332331        }
    333332   
Note: See TracChangeset for help on using the changeset viewer.