From 52169bb0f41762fd04c23fc7d8bf30ac771ebd92 Mon Sep 17 00:00:00 2001 From: Hummer12007 Date: Sun, 27 Mar 2016 17:49:00 +0300 Subject: [PATCH] Implemented system sounds lookup, fixes #156, supersedes #180 --- Classes/Dialogs/Preferences/PreferencesController.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Classes/Dialogs/Preferences/PreferencesController.m b/Classes/Dialogs/Preferences/PreferencesController.m index 4bd88cc5..86e32ad9 100644 --- a/Classes/Dialogs/Preferences/PreferencesController.m +++ b/Classes/Dialogs/Preferences/PreferencesController.m @@ -207,7 +207,14 @@ - (NSArray*)availableSounds { static NSArray* ary; if (!ary) { - ary = [NSArray arrayWithObjects:@"-", @"Beep", @"Basso", @"Blow", @"Bottle", @"Frog", @"Funk", @"Glass", @"Hero", @"Morse", @"Ping", @"Pop", @"Purr", @"Sosumi", @"Submarine", @"Tink", nil]; + NSMutableArray* arr = [NSMutableArray arrayWithObject:@"-"]; + for (NSString *path in [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, + NSAllDomainsMask, YES) objectEnumerator]) + for (NSString *soundFile in [[NSFileManager defaultManager] + enumeratorAtPath:[path stringByAppendingPathComponent:@"Sounds"]]) + if ([NSSound soundNamed:[soundFile stringByDeletingPathExtension]]) + [arr addObject:[soundFile stringByDeletingPathExtension]]; + ary = [arr copy]; } return ary; }