mirror of
https://github.com/transmission/transmission
synced 2025-03-15 16:29:34 +00:00
use sounds from the user's sounds folder as well as system sounds
This commit is contained in:
parent
624d54d281
commit
910bc0d7b8
4 changed files with 45 additions and 36 deletions
2
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
2
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
|
@ -23,7 +23,7 @@
|
|||
</array>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>66</integer>
|
||||
<integer>41</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8R4031</string>
|
||||
|
|
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -40,8 +40,6 @@
|
|||
* fDownloadSoundPopUp, * fSeedingSoundPopUp;
|
||||
IBOutlet NSTextField * fRatioStopField, * fQueueDownloadField, * fQueueSeedField, * fStalledField;
|
||||
|
||||
NSArray * fSounds;
|
||||
|
||||
SUUpdater * fUpdater;
|
||||
|
||||
IBOutlet NSTextField * fUploadField, * fDownloadField,
|
||||
|
@ -58,8 +56,15 @@
|
|||
- (id) initWithWindowNibName: (NSString *) name handle: (tr_handle_t *) handle;
|
||||
- (void) setUpdater: (SUUpdater *) updater;
|
||||
|
||||
- (void) setBadge: (id) sender;
|
||||
- (void) setPort: (id) sender;
|
||||
- (void) setNat: (id) sender;
|
||||
- (void) updatePortStatus;
|
||||
- (void) portCheckerDidFinishProbing: (PortChecker *) portChecker;
|
||||
|
||||
- (NSArray *) sounds;
|
||||
- (void) setSound: (id) sender;
|
||||
|
||||
- (void) setBadge: (id) sender;
|
||||
- (void) resetWarnings: (id) sender;
|
||||
- (void) setCheckForUpdate: (id) sender;
|
||||
|
||||
|
@ -73,11 +78,6 @@
|
|||
- (void) folderSheetShow: (id) sender;
|
||||
- (void) incompleteFolderSheetShow: (id) sender;
|
||||
|
||||
- (void) setPort: (id) sender;
|
||||
- (void) setNat: (id) sender;
|
||||
- (void) updatePortStatus;
|
||||
- (void) portCheckerDidFinishProbing: (PortChecker *) portChecker;
|
||||
|
||||
- (void) applyRatioSetting: (id) sender;
|
||||
- (void) updateRatioStopField;
|
||||
- (void) setRatioStop: (id) sender;
|
||||
|
|
|
@ -80,25 +80,8 @@
|
|||
|
||||
//actually set bandwidth limits
|
||||
[self applySpeedSettings: nil];
|
||||
|
||||
//set play sound
|
||||
NSMutableArray * sounds = [NSMutableArray array];
|
||||
NSEnumerator * soundEnumerator;
|
||||
|
||||
//get list of all sounds and sort alphabetically
|
||||
if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: @"System/Library/Sounds"])
|
||||
{
|
||||
NSString * sound;
|
||||
while ((sound = [soundEnumerator nextObject]))
|
||||
{
|
||||
sound = [sound stringByDeletingPathExtension];
|
||||
if ([NSSound soundNamed: sound])
|
||||
[sounds addObject: sound];
|
||||
}
|
||||
}
|
||||
|
||||
fSounds = [[sounds sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] retain];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -106,7 +89,6 @@
|
|||
{
|
||||
if (fNatStatusTimer)
|
||||
[fNatStatusTimer invalidate];
|
||||
[fSounds release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -319,6 +301,41 @@
|
|||
[portChecker release];
|
||||
}
|
||||
|
||||
- (NSArray *) sounds
|
||||
{
|
||||
NSMutableArray * sounds = [[NSMutableArray alloc] init];
|
||||
|
||||
NSArray * directories = [NSArray arrayWithObjects: @"/System/Library/Sounds", @"/Library/Sounds",
|
||||
[NSHomeDirectory() stringByAppendingPathComponent: @"Library/Sounds"], nil];
|
||||
BOOL isDirectory;
|
||||
NSEnumerator * soundEnumerator;
|
||||
NSString * sound;
|
||||
|
||||
NSString * directory;
|
||||
NSEnumerator * enumerator = [directories objectEnumerator];
|
||||
while ((directory = [enumerator nextObject]))
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath: directory isDirectory: &isDirectory] && isDirectory)
|
||||
{
|
||||
soundEnumerator = [[[NSFileManager defaultManager] directoryContentsAtPath: directory] objectEnumerator];
|
||||
while ((sound = [soundEnumerator nextObject]))
|
||||
{
|
||||
sound = [sound stringByDeletingPathExtension];
|
||||
if ([NSSound soundNamed: sound])
|
||||
[sounds addObject: sound];
|
||||
}
|
||||
}
|
||||
|
||||
return sounds;
|
||||
}
|
||||
|
||||
- (void) setSound: (id) sender
|
||||
{
|
||||
//play sound when selecting
|
||||
NSSound * sound;
|
||||
if ((sound = [NSSound soundNamed: [sender titleOfSelectedItem]]))
|
||||
[sound play];
|
||||
}
|
||||
|
||||
- (void) applySpeedSettings: (id) sender
|
||||
{
|
||||
if ([fDefaults boolForKey: @"SpeedLimit"])
|
||||
|
@ -422,14 +439,6 @@
|
|||
[[NSNotificationCenter defaultCenter] postNotificationName: @"DockBadgeChange" object: self];
|
||||
}
|
||||
|
||||
- (void) setSound: (id) sender
|
||||
{
|
||||
//play sound when selecting
|
||||
NSSound * sound;
|
||||
if ((sound = [NSSound soundNamed: [sender titleOfSelectedItem]]))
|
||||
[sound play];
|
||||
}
|
||||
|
||||
- (void) resetWarnings: (id) sender
|
||||
{
|
||||
[fDefaults setBool: YES forKey: @"WarningDebug"];
|
||||
|
|
Loading…
Add table
Reference in a new issue