mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
bind sound popups and catch if auto speed limit times are the same
This commit is contained in:
parent
5d77966aa4
commit
52841c94b9
5 changed files with 31 additions and 50 deletions
|
@ -1323,7 +1323,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
//check if should be on if within range
|
||||
BOOL shouldBeOn;
|
||||
int hour = [[NSCalendarDate calendarDate] hourOfDay];
|
||||
if (onHour < offHour)
|
||||
|
||||
if (onHour == offHour)
|
||||
shouldBeOn = NO;
|
||||
else if (onHour < offHour)
|
||||
shouldBeOn = hour >= onHour && hour < offHour;
|
||||
else
|
||||
shouldBeOn = hour < offHour || hour >= onHour;
|
||||
|
@ -1340,8 +1343,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
//toggle if within first few seconds of hour
|
||||
NSCalendarDate * currentDate = [NSCalendarDate calendarDate];
|
||||
if ([currentDate minuteOfHour] == 0 && [currentDate secondOfMinute] < AUTO_SPEED_LIMIT_SECONDS
|
||||
&& [currentDate hourOfDay] == [fDefaults integerForKey: fSpeedLimitEnabled
|
||||
? @"SpeedLimitAutoOffHour" : @"SpeedLimitAutoOnHour"])
|
||||
&& [currentDate hourOfDay] == [fDefaults integerForKey: fSpeedLimitEnabled
|
||||
? @"SpeedLimitAutoOffHour" : @"SpeedLimitAutoOnHour"]
|
||||
&& (fSpeedLimitEnabled || [fDefaults integerForKey: @"SpeedLimitAutoOnHour"]
|
||||
!= [fDefaults integerForKey: @"SpeedLimitAutoOffHour"]))
|
||||
{
|
||||
[self toggleSpeedLimit: nil];
|
||||
|
||||
|
|
2
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
2
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
|
@ -11,7 +11,7 @@
|
|||
<key>28</key>
|
||||
<string>294 434 563 290 0 0 1152 842 </string>
|
||||
<key>41</key>
|
||||
<string>138 348 563 317 0 0 1152 842 </string>
|
||||
<string>294 420 563 317 0 0 1152 842 </string>
|
||||
<key>66</key>
|
||||
<string>294 507 563 144 0 0 1152 842 </string>
|
||||
</dict>
|
||||
|
|
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -39,6 +39,8 @@
|
|||
IBOutlet NSPopUpButton * fFolderPopUp, * fImportFolderPopUp,
|
||||
* fDownloadSoundPopUp, * fSeedingSoundPopUp;
|
||||
|
||||
NSArray * fSounds;
|
||||
|
||||
SUUpdater * fUpdater;
|
||||
IBOutlet NSPopUpButton * fUpdatePopUp;
|
||||
|
||||
|
|
|
@ -79,6 +79,25 @@
|
|||
|
||||
//actually set bandwidth limits
|
||||
[self applySpeedSettings: nil];
|
||||
|
||||
//set play sound
|
||||
NSMutableArray * sounds = [NSMutableArray array];
|
||||
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
|
||||
while ((soundPath = [soundDirectoriesEnumerator nextObject]))
|
||||
if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: soundPath])
|
||||
while ((sound = [soundEnumerator nextObject]))
|
||||
{
|
||||
sound = [sound stringByDeletingPathExtension];
|
||||
if ([NSSound soundNamed: sound])
|
||||
[sounds addObject: sound];
|
||||
}
|
||||
|
||||
fSounds = [[sounds sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)] retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -87,6 +106,7 @@
|
|||
{
|
||||
if (fNatStatusTimer)
|
||||
[fNatStatusTimer invalidate];
|
||||
[fSounds release];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
@ -118,45 +138,6 @@
|
|||
[self updateNatStatus];
|
||||
fNatStatusTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self
|
||||
selector: @selector(updateNatStatus) userInfo: nil repeats: YES];
|
||||
|
||||
//set play sound
|
||||
NSMutableArray * sounds = [NSMutableArray array];
|
||||
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
|
||||
while ((soundPath = [soundDirectoriesEnumerator nextObject]))
|
||||
if (soundEnumerator = [[NSFileManager defaultManager] enumeratorAtPath: soundPath])
|
||||
while ((sound = [soundEnumerator nextObject]))
|
||||
{
|
||||
sound = [sound stringByDeletingPathExtension];
|
||||
if ([NSSound soundNamed: sound])
|
||||
[sounds addObject: sound];
|
||||
}
|
||||
|
||||
[sounds sortUsingSelector: @selector(caseInsensitiveCompare:)];
|
||||
|
||||
//set download sound
|
||||
[fDownloadSoundPopUp removeAllItems];
|
||||
[fDownloadSoundPopUp addItemsWithTitles: sounds];
|
||||
|
||||
int downloadSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"DownloadSound"]];
|
||||
if (downloadSoundIndex >= 0)
|
||||
[fDownloadSoundPopUp selectItemAtIndex: downloadSoundIndex];
|
||||
else
|
||||
[fDefaults setObject: [fDownloadSoundPopUp titleOfSelectedItem] forKey: @"DownloadSound"];
|
||||
|
||||
//set seeding sound
|
||||
[fSeedingSoundPopUp removeAllItems];
|
||||
[fSeedingSoundPopUp addItemsWithTitles: sounds];
|
||||
|
||||
int seedingSoundIndex = [fDownloadSoundPopUp indexOfItemWithTitle: [fDefaults stringForKey: @"SeedingSound"]];
|
||||
if (seedingSoundIndex >= 0)
|
||||
[fSeedingSoundPopUp selectItemAtIndex: seedingSoundIndex];
|
||||
else
|
||||
[fDefaults setObject: [fSeedingSoundPopUp titleOfSelectedItem] forKey: @"SeedingSound"];
|
||||
|
||||
//set update check
|
||||
NSString * updateCheck = [fDefaults stringForKey: @"UpdateCheck"];
|
||||
|
@ -358,13 +339,6 @@
|
|||
NSSound * sound;
|
||||
if ((sound = [NSSound soundNamed: soundName]))
|
||||
[sound play];
|
||||
|
||||
#warning use bindings
|
||||
if (sender == fDownloadSoundPopUp)
|
||||
[fDefaults setObject: soundName forKey: @"DownloadSound"];
|
||||
else if (sender == fSeedingSoundPopUp)
|
||||
[fDefaults setObject: soundName forKey: @"SeedingSound"];
|
||||
else;
|
||||
}
|
||||
|
||||
- (void) setUpdate: (id) sender
|
||||
|
|
Loading…
Reference in a new issue