1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

hopefully fix bug with entering values with commas in prefs, switch pref formatters to 10.4

This commit is contained in:
Mitchell Livingston 2007-12-06 00:27:39 +00:00
parent 904c51634c
commit 40d5a4a39a
4 changed files with 29 additions and 76 deletions

View file

@ -9,11 +9,9 @@
<key>IBOldestOS</key> <key>IBOldestOS</key>
<integer>5</integer> <integer>5</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array/>
<integer>66</integer>
</array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>9A581</string> <string>9B18</string>
<key>targetFramework</key> <key>targetFramework</key>
<string>IBCocoaFramework</string> <string>IBCocoaFramework</string>
</dict> </dict>

View file

@ -36,6 +36,8 @@
IBOutlet NSView * fGeneralView, * fTransfersView, * fBandwidthView, * fAdvancedView; IBOutlet NSView * fGeneralView, * fTransfersView, * fBandwidthView, * fAdvancedView;
NSString * fInitialString;
IBOutlet NSPopUpButton * fFolderPopUp, * fIncompleteFolderPopUp, * fImportFolderPopUp, IBOutlet NSPopUpButton * fFolderPopUp, * fIncompleteFolderPopUp, * fImportFolderPopUp,
* fDownloadSoundPopUp, * fSeedingSoundPopUp; * fDownloadSoundPopUp, * fSeedingSoundPopUp;
IBOutlet NSTextField * fRatioStopField, * fQueueDownloadField, * fQueueSeedField, * fStalledField; IBOutlet NSTextField * fRatioStopField, * fQueueDownloadField, * fQueueSeedField, * fStalledField;
@ -49,7 +51,7 @@
IBOutlet NSButton * fNatCheck; IBOutlet NSButton * fNatCheck;
IBOutlet NSImageView * fPortStatusImage; IBOutlet NSImageView * fPortStatusImage;
IBOutlet NSProgressIndicator * fPortStatusProgress; IBOutlet NSProgressIndicator * fPortStatusProgress;
NSTimer * fNatStatusTimer; NSTimer * fPortStatusTimer;
int fPublicPort, fNatStatus; int fPublicPort, fNatStatus;
} }

View file

@ -90,8 +90,8 @@
- (void) dealloc - (void) dealloc
{ {
if (fNatStatusTimer) if (fPortStatusTimer)
[fNatStatusTimer invalidate]; [fPortStatusTimer invalidate];
[super dealloc]; [super dealloc];
} }
@ -131,19 +131,16 @@
[fSpeedLimitDownloadField setIntValue: [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]]; [fSpeedLimitDownloadField setIntValue: [fDefaults integerForKey: @"SpeedLimitDownloadLimit"]];
//set port //set port
#warning why no binding?
[fPortField setIntValue: [fDefaults integerForKey: @"BindPort"]]; [fPortField setIntValue: [fDefaults integerForKey: @"BindPort"]];
fNatStatus = -1; fNatStatus = -1;
[self updatePortStatus]; [self updatePortStatus];
fNatStatusTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self fPortStatusTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target: self
selector: @selector(updatePortStatus) userInfo: nil repeats: YES]; selector: @selector(updatePortStatus) userInfo: nil repeats: YES];
//set queue values //set queue values
[fQueueDownloadField setIntValue: [fDefaults integerForKey: @"QueueDownloadNumber"]]; [fQueueDownloadField setIntValue: [fDefaults integerForKey: @"QueueDownloadNumber"]];
[fQueueSeedField setIntValue: [fDefaults integerForKey: @"QueueSeedNumber"]]; [fQueueSeedField setIntValue: [fDefaults integerForKey: @"QueueSeedNumber"]];
//set stalled value
[fStalledField setIntValue: [fDefaults integerForKey: @"StalledMinutes"]]; [fStalledField setIntValue: [fDefaults integerForKey: @"StalledMinutes"]];
} }
@ -210,22 +207,13 @@
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
{ {
return [NSArray arrayWithObjects: TOOLBAR_GENERAL, TOOLBAR_TRANSFERS, return [NSArray arrayWithObjects: TOOLBAR_GENERAL, TOOLBAR_TRANSFERS, TOOLBAR_BANDWIDTH, TOOLBAR_ADVANCED, nil];
TOOLBAR_BANDWIDTH, TOOLBAR_ADVANCED, nil];
} }
- (void) setPort: (id) sender - (void) setPort: (id) sender
{ {
int port = [sender intValue]; int port = [sender intValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", port]])
{
NSBeep();
[sender setIntValue: [fDefaults integerForKey: @"BindPort"]];
return;
}
[fDefaults setInteger: port forKey: @"BindPort"]; [fDefaults setInteger: port forKey: @"BindPort"];
tr_setBindPort(fHandle, port); tr_setBindPort(fHandle, port);
fPublicPort = -1; fPublicPort = -1;
@ -361,16 +349,7 @@
- (void) setRatioStop: (id) sender - (void) setRatioStop: (id) sender
{ {
float ratio = [sender floatValue]; [fDefaults setFloat: [sender floatValue] forKey: @"RatioLimit"];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratio]] || ratio < 0)
{
NSBeep();
[sender setFloatValue: [fDefaults floatForKey: @"RatioLimit"]];
return;
}
[fDefaults setFloat: ratio forKey: @"RatioLimit"];
[self applyRatioSetting: nil]; [self applyRatioSetting: nil];
} }
@ -385,35 +364,14 @@
- (void) setGlobalLimit: (id) sender - (void) setGlobalLimit: (id) sender
{ {
BOOL upload = sender == fUploadField; [fDefaults setInteger: [sender intValue] forKey: sender == fUploadField ? @"UploadLimit" : @"DownloadLimit"];
int limit = [sender intValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]] || limit < 0)
{
NSBeep();
[sender setIntValue: [fDefaults integerForKey: upload ? @"UploadLimit" : @"DownloadLimit"]];
return;
}
[fDefaults setInteger: limit forKey: upload ? @"UploadLimit" : @"DownloadLimit"];
[self applySpeedSettings: self]; [self applySpeedSettings: self];
} }
- (void) setSpeedLimit: (id) sender - (void) setSpeedLimit: (id) sender
{ {
BOOL upload = sender == fSpeedLimitUploadField; [fDefaults setInteger: [sender intValue] forKey: sender == fSpeedLimitUploadField
? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
int limit = [sender intValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]])
{
NSBeep();
[sender setIntValue: [fDefaults integerForKey: upload ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"]];
return;
}
[fDefaults setInteger: limit forKey: upload ? @"SpeedLimitUploadLimit" : @"SpeedLimitDownloadLimit"];
[self applySpeedSettings: self]; [self applySpeedSettings: self];
} }
@ -422,6 +380,20 @@
[[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self]; [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoSpeedLimitChange" object: self];
} }
- (BOOL) control: (NSControl *) control textShouldBeginEditing: (NSText *) fieldEditor
{
#warning release!
fInitialString = [[control stringValue] retain];
}
- (BOOL) control: (NSControl *) control didFailToFormatString: (NSString *) string errorDescription: (NSString *) error
{
NSBeep();
if (fInitialString)
[control setStringValue: fInitialString];
return NO;
}
- (void) setBadge: (id) sender - (void) setBadge: (id) sender
{ {
[[NSNotificationCenter defaultCenter] postNotificationName: @"DockBadgeChange" object: self]; [[NSNotificationCenter defaultCenter] postNotificationName: @"DockBadgeChange" object: self];
@ -429,7 +401,6 @@
- (void) resetWarnings: (id) sender - (void) resetWarnings: (id) sender
{ {
[fDefaults setBool: YES forKey: @"WarningDebug"];
[fDefaults setBool: YES forKey: @"WarningDuplicate"]; [fDefaults setBool: YES forKey: @"WarningDuplicate"];
[fDefaults setBool: YES forKey: @"WarningRemainingSpace"]; [fDefaults setBool: YES forKey: @"WarningRemainingSpace"];
} }
@ -449,17 +420,7 @@
- (void) setQueueNumber: (id) sender - (void) setQueueNumber: (id) sender
{ {
BOOL download = sender == fQueueDownloadField; [fDefaults setInteger: [sender intValue] forKey: sender == fQueueDownloadField ? @"QueueDownloadNumber" : @"QueueSeedNumber"];
int limit = [sender intValue];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]] || limit < 1)
{
NSBeep();
[sender setIntValue: [fDefaults integerForKey: download ? @"QueueDownloadNumber" : @"QueueSeedNumber"]];
return;
}
[fDefaults setInteger: limit forKey: download ? @"QueueDownloadNumber" : @"QueueSeedNumber"];
[self setQueue: nil]; [self setQueue: nil];
} }
@ -470,15 +431,7 @@
- (void) setStalledMinutes: (id) sender - (void) setStalledMinutes: (id) sender
{ {
int minutes = [sender intValue]; [fDefaults setInteger: [sender intValue] forKey: @"StalledMinutes"];
if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", minutes]] || minutes < 1)
{
NSBeep();
[sender setIntValue: [fDefaults integerForKey: @"StalledMinutes"]];
return;
}
[fDefaults setInteger: minutes forKey: @"StalledMinutes"];
[self setStalled: nil]; [self setStalled: nil];
} }