mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
Adds download rate limit to OS X interface
This commit is contained in:
parent
ca267ac99a
commit
c6afb1c534
6 changed files with 64 additions and 29 deletions
|
@ -12,12 +12,16 @@
|
||||||
<true/>
|
<true/>
|
||||||
<key>CheckRemove</key>
|
<key>CheckRemove</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>CheckDownload</key>
|
||||||
|
<false/>
|
||||||
<key>CheckUpload</key>
|
<key>CheckUpload</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>DownloadChoice</key>
|
<key>DownloadChoice</key>
|
||||||
<string>Constant</string>
|
<string>Constant</string>
|
||||||
<key>DownloadFolder</key>
|
<key>DownloadFolder</key>
|
||||||
<string>~/Desktop</string>
|
<string>~/Desktop</string>
|
||||||
|
<key>DownloadLimit</key>
|
||||||
|
<integer>100</integer>
|
||||||
<key>InfoVisible</key>
|
<key>InfoVisible</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>Move</key>
|
<key>Move</key>
|
||||||
|
|
6
macosx/English.lproj/MainMenu.nib/classes.nib
generated
6
macosx/English.lproj/MainMenu.nib/classes.nib
generated
|
@ -65,12 +65,12 @@
|
||||||
folderSheetShow = id;
|
folderSheetShow = id;
|
||||||
setBadge = id;
|
setBadge = id;
|
||||||
setDownloadLocation = id;
|
setDownloadLocation = id;
|
||||||
setLimitUploadCheck = id;
|
setLimit = id;
|
||||||
|
setLimitCheck = id;
|
||||||
setPort = id;
|
setPort = id;
|
||||||
setQuitMessage = id;
|
setQuitMessage = id;
|
||||||
setRemoveMessage = id;
|
setRemoveMessage = id;
|
||||||
setUpdate = id;
|
setUpdate = id;
|
||||||
setUploadLimit = id;
|
|
||||||
};
|
};
|
||||||
CLASS = PrefsController;
|
CLASS = PrefsController;
|
||||||
LANGUAGE = ObjC;
|
LANGUAGE = ObjC;
|
||||||
|
@ -78,6 +78,8 @@
|
||||||
fBadgeDownloadRateCheck = NSButton;
|
fBadgeDownloadRateCheck = NSButton;
|
||||||
fBadgeUploadRateCheck = NSButton;
|
fBadgeUploadRateCheck = NSButton;
|
||||||
fBlankView = NSView;
|
fBlankView = NSView;
|
||||||
|
fDownloadCheck = NSButton;
|
||||||
|
fDownloadField = NSTextField;
|
||||||
fFolderPopUp = NSPopUpButton;
|
fFolderPopUp = NSPopUpButton;
|
||||||
fGeneralView = NSView;
|
fGeneralView = NSView;
|
||||||
fNetworkView = NSView;
|
fNetworkView = NSView;
|
||||||
|
|
3
macosx/English.lproj/MainMenu.nib/info.nib
generated
3
macosx/English.lproj/MainMenu.nib/info.nib
generated
|
@ -17,7 +17,7 @@
|
||||||
<key>783</key>
|
<key>783</key>
|
||||||
<string>411 429 420 250 0 0 1280 832 </string>
|
<string>411 429 420 250 0 0 1280 832 </string>
|
||||||
<key>796</key>
|
<key>796</key>
|
||||||
<string>484 520 420 129 0 0 1440 878 </string>
|
<string>411 472 420 164 0 0 1280 832 </string>
|
||||||
<key>825</key>
|
<key>825</key>
|
||||||
<string>544 501 155 107 0 0 1280 832 </string>
|
<string>544 501 155 107 0 0 1280 832 </string>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
<integer>3</integer>
|
<integer>3</integer>
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
|
<integer>796</integer>
|
||||||
<integer>21</integer>
|
<integer>21</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
|
|
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -44,6 +44,8 @@
|
||||||
IBOutlet NSTextField * fPortField;
|
IBOutlet NSTextField * fPortField;
|
||||||
IBOutlet NSButton * fUploadCheck;
|
IBOutlet NSButton * fUploadCheck;
|
||||||
IBOutlet NSTextField * fUploadField;
|
IBOutlet NSTextField * fUploadField;
|
||||||
|
IBOutlet NSButton * fDownloadCheck;
|
||||||
|
IBOutlet NSTextField * fDownloadField;
|
||||||
|
|
||||||
IBOutlet NSWindow * fWindow;
|
IBOutlet NSWindow * fWindow;
|
||||||
|
|
||||||
|
@ -60,8 +62,8 @@
|
||||||
- (void) setDownloadLocation: (id) sender;
|
- (void) setDownloadLocation: (id) sender;
|
||||||
- (void) folderSheetShow: (id) sender;
|
- (void) folderSheetShow: (id) sender;
|
||||||
|
|
||||||
- (void) setLimitUploadCheck: (id) sender;
|
|
||||||
- (void) setPort: (id) sender;
|
- (void) setPort: (id) sender;
|
||||||
- (void) setUploadLimit: (id) sender;
|
- (void) setLimitCheck: (id) sender;
|
||||||
|
- (void) setLimit: (id) sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -126,6 +126,16 @@
|
||||||
|
|
||||||
tr_setUploadLimit( fHandle, checkUpload ? uploadLimit : -1 );
|
tr_setUploadLimit( fHandle, checkUpload ? uploadLimit : -1 );
|
||||||
|
|
||||||
|
//set download limit
|
||||||
|
BOOL checkDownload = [fDefaults boolForKey: @"CheckDownload"];
|
||||||
|
int downloadLimit = [fDefaults integerForKey: @"DownloadLimit"];
|
||||||
|
|
||||||
|
[fDownloadCheck setState: checkDownload ? NSOnState : NSOffState];
|
||||||
|
[fDownloadField setIntValue: downloadLimit];
|
||||||
|
[fDownloadField setEnabled: checkDownload];
|
||||||
|
|
||||||
|
tr_setDownloadLimit( fHandle, checkDownload ? downloadLimit : -1 );
|
||||||
|
|
||||||
//set remove and quit prompts
|
//set remove and quit prompts
|
||||||
[fQuitCheck setState: [fDefaults boolForKey: @"CheckQuit"] ?
|
[fQuitCheck setState: [fDefaults boolForKey: @"CheckQuit"] ?
|
||||||
NSOnState : NSOffState];
|
NSOnState : NSOffState];
|
||||||
|
@ -220,36 +230,52 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setLimitUploadCheck: (id) sender
|
- (void) setLimitCheck: (id) sender
|
||||||
{
|
{
|
||||||
BOOL checkUpload = [fUploadCheck state] == NSOnState;
|
NSString * key;
|
||||||
|
NSTextField * field;
|
||||||
[fDefaults setBool: checkUpload forKey: @"CheckUpload"];
|
if( sender == fUploadCheck )
|
||||||
|
|
||||||
[self setUploadLimit: nil];
|
|
||||||
[fUploadField setEnabled: checkUpload];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void) setUploadLimit: (id) sender
|
|
||||||
{
|
|
||||||
int uploadLimit = [fUploadField intValue];
|
|
||||||
|
|
||||||
//if value entered is not an int or is less than 0 do not change
|
|
||||||
if (![[fUploadField stringValue] isEqualToString:
|
|
||||||
[NSString stringWithInt: uploadLimit]] || uploadLimit < 0)
|
|
||||||
{
|
{
|
||||||
NSBeep();
|
key = @"CheckUpload";
|
||||||
uploadLimit = [fDefaults integerForKey: @"UploadLimit"];
|
field = fUploadField;
|
||||||
[fUploadField setIntValue: uploadLimit];
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[fDefaults setInteger: uploadLimit forKey: @"UploadLimit"];
|
key = @"CheckDownload";
|
||||||
|
field = fDownloadField;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([fUploadCheck state] == NSOffState || uploadLimit == 0)
|
BOOL check = [sender state] == NSOnState;
|
||||||
uploadLimit = -1;
|
[fDefaults setBool: check forKey: key];
|
||||||
tr_setUploadLimit( fHandle, uploadLimit );
|
|
||||||
|
[self setLimit: field];
|
||||||
|
[field setEnabled: check];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setLimit: (id) sender
|
||||||
|
{
|
||||||
|
int limit = [sender intValue];
|
||||||
|
NSString * key = ( sender == fUploadField ) ?
|
||||||
|
@"CheckUpload" : @"CheckDownload";
|
||||||
|
|
||||||
|
//if value entered is not an int or is less than 0 do not change
|
||||||
|
if (![[sender stringValue] isEqualToString:
|
||||||
|
[NSString stringWithInt: limit]] || limit < 0)
|
||||||
|
{
|
||||||
|
NSBeep();
|
||||||
|
limit = [fDefaults integerForKey: key];
|
||||||
|
[sender setIntValue: limit];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[fDefaults setInteger: limit forKey: key];
|
||||||
|
if( sender == fUploadField )
|
||||||
|
tr_setUploadLimit( fHandle,
|
||||||
|
( [fUploadCheck state] == NSOffState ) ? -1 : limit );
|
||||||
|
else
|
||||||
|
tr_setDownloadLimit( fHandle,
|
||||||
|
( [fDownloadCheck state] == NSOffState ) ? -1 : limit );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setQuitMessage: (id) sender
|
- (void) setQuitMessage: (id) sender
|
||||||
|
|
Loading…
Reference in a new issue