Adds Action button that allows quick setting of upload and download limits,

Makes the bottom bar look like Mail's,
Moves stats to a top, hideable bar.
This commit is contained in:
Eric Petit 2006-05-01 00:15:18 +00:00
parent 844d0e3520
commit 796e2b868e
14 changed files with 209 additions and 39 deletions

View File

@ -15,7 +15,6 @@
4D1838BF09DEC0430047D688 /* net.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D1838A009DEC0430047D688 /* net.c */; };
4D1838C009DEC0430047D688 /* metainfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1838A109DEC0430047D688 /* metainfo.h */; };
4D1838C109DEC0430047D688 /* metainfo.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D1838A209DEC0430047D688 /* metainfo.c */; };
4D1838C209DEC0430047D688 /* peermessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1838A309DEC0430047D688 /* peermessages.h */; };
4D1838C309DEC0430047D688 /* peer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1838A409DEC0430047D688 /* peer.h */; };
4D1838C409DEC0430047D688 /* peer.c in Sources */ = {isa = PBXBuildFile; fileRef = 4D1838A509DEC0430047D688 /* peer.c */; };
4D1838C509DEC0430047D688 /* net.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1838A609DEC0430047D688 /* net.h */; };
@ -78,6 +77,10 @@
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
A21610FC0A050B1700E8E4C1 /* MenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A21610FB0A050B1700E8E4C1 /* MenuButton.m */; };
A26D450B0A0503AC00A10BB3 /* peermessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1838A309DEC0430047D688 /* peermessages.h */; };
A2A84AD00A04FCD000C898D4 /* ActionButton.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2A84ACF0A04FCD000C898D4 /* ActionButton.tiff */; };
A2C655650A04FEDC00E9FD82 /* BottomBorder.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A2C655640A04FEDC00E9FD82 /* BottomBorder.tiff */; };
/* End PBXBuildFile section */
/* Begin PBXBuildStyle section */
@ -190,6 +193,12 @@
4DFBC2DE09C0970D00D5C571 /* Torrent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Torrent.m; path = macosx/Torrent.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; name = Info.plist; path = macosx/Info.plist; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Transmission.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Transmission.app; sourceTree = BUILT_PRODUCTS_DIR; };
A21610FA0A050B1700E8E4C1 /* MenuButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = MenuButton.h; path = macosx/MenuButton.h; sourceTree = "<group>"; };
A21610FB0A050B1700E8E4C1 /* MenuButton.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = MenuButton.m; path = macosx/MenuButton.m; sourceTree = "<group>"; };
A2A84ACF0A04FCD000C898D4 /* ActionButton.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = ActionButton.tiff; path = macosx/Images/ActionButton.tiff; sourceTree = "<group>"; };
A2A84AD10A04FCDC00C898D4 /* ActionButton.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = ActionButton.tiff; path = macosx/Images/ActionButton.tiff; sourceTree = "<group>"; };
A2A84AD20A04FCDC00C898D4 /* BottomBorder.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = BottomBorder.tiff; path = macosx/Images/BottomBorder.tiff; sourceTree = "<group>"; };
A2C655640A04FEDC00E9FD82 /* BottomBorder.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = BottomBorder.tiff; path = macosx/Images/BottomBorder.tiff; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -242,6 +251,8 @@
4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */,
29B97316FDCFA39411CA2CEA /* main.m */,
32CA4F630368D1EE00C91783 /* Transmission_Prefix.pch */,
A21610FA0A050B1700E8E4C1 /* MenuButton.h */,
A21610FB0A050B1700E8E4C1 /* MenuButton.m */,
);
name = Sources;
sourceTree = "<group>";
@ -271,6 +282,8 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
A2A84AD10A04FCDC00C898D4 /* ActionButton.tiff */,
A2A84AD20A04FCDC00C898D4 /* BottomBorder.tiff */,
4D2784360905709500687951 /* Transmission.icns */,
4D043A7E090AE979009FEDA8 /* TransmissionDocument.icns */,
4DF7500808A103AD007B0D70 /* Info.png */,
@ -293,6 +306,8 @@
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
29B97318FDCFA39411CA2CEA /* MainMenu.nib */,
A2A84ACF0A04FCD000C898D4 /* ActionButton.tiff */,
A2C655640A04FEDC00E9FD82 /* BottomBorder.tiff */,
);
name = Resources;
sourceTree = "<group>";
@ -387,7 +402,6 @@
4D1838BC09DEC0430047D688 /* internal.h in Headers */,
4D1838BD09DEC0430047D688 /* inout.h in Headers */,
4D1838C009DEC0430047D688 /* metainfo.h in Headers */,
4D1838C209DEC0430047D688 /* peermessages.h in Headers */,
4D1838C309DEC0430047D688 /* peer.h in Headers */,
4D1838C509DEC0430047D688 /* net.h in Headers */,
4D1838C609DEC0430047D688 /* fdlimit.h in Headers */,
@ -404,6 +418,7 @@
4D1838DA09DEC0430047D688 /* clients.h in Headers */,
4D1838FA09DEC4380047D688 /* utils.h in Headers */,
4D1838FC09DEC4380047D688 /* transmission.h in Headers */,
A26D450B0A0503AC00A10BB3 /* peermessages.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -527,6 +542,8 @@
4DE5CCCB0981D9BE00BE280E /* Defaults.plist in Resources */,
4DDFDD22099A5D8E00189D81 /* DownloadBadge.png in Resources */,
4DDFDD23099A5D8E00189D81 /* UploadBadge.png in Resources */,
A2A84AD00A04FCD000C898D4 /* ActionButton.tiff in Resources */,
A2C655650A04FEDC00E9FD82 /* BottomBorder.tiff in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -575,6 +592,7 @@
4DE5CCA70980735700BE280E /* Badger.m in Sources */,
4DFBC2DF09C0970D00D5C571 /* Torrent.m in Sources */,
4DCCBB3E09C3D71100D3CABF /* TorrentCell.m in Sources */,
A21610FC0A050B1700E8E4C1 /* MenuButton.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -52,6 +52,9 @@
IBOutlet TorrentTableView * fTableView;
IBOutlet NSTextField * fTotalDLField;
IBOutlet NSTextField * fTotalULField;
IBOutlet NSTextField * fTotalTorrentsField;
IBOutlet NSBox * fStats;
BOOL fStatusBar;
IBOutlet NSPanel * fInfoPanel;
IBOutlet NSImageView * fInfoImageView;
@ -120,6 +123,7 @@
- (void) runCustomizationPalette: (id) sender;
- (void) showHideToolbar: (id) sender;
- (void) toggleStatusBar: (id) sender;
- (void) showPreferenceWindow: (id) sender;

View File

@ -85,6 +85,10 @@ static void sleepCallBack( void * controller, io_service_t y,
[fToolbar setAutosavesConfiguration: YES];
[fWindow setToolbar: fToolbar];
[fWindow setDelegate: self];
fStatusBar = YES;
if (![fDefaults boolForKey: @"StatusBar"])
[self toggleStatusBar: nil];
[fTableView setTorrents: fTorrents];
[[fTableView tableColumnWithIdentifier: @"Torrent"] setDataCell:
@ -660,6 +664,10 @@ static void sleepCallBack( void * controller, io_service_t y,
NSString * uploadRate = [NSString stringForSpeed: ul];
[fTotalDLField setStringValue: downloadRate];
[fTotalULField setStringValue: uploadRate];
int count = [fTorrents count];
[fTotalTorrentsField setStringValue: [NSString stringWithFormat:
@"%d Torrent%s", count, count == 1 ? "" : "s"]];
[self updateInfoPanel];
@ -839,6 +847,24 @@ static void sleepCallBack( void * controller, io_service_t y,
[fWindow toggleToolbarShown:sender];
}
- (void) toggleStatusBar: (id) sender
{
fStatusBar = !fStatusBar;
NSSize frameSize = [fScrollView frame].size;
[fStats setHidden: !fStatusBar];
if (fStatusBar)
frameSize.height -= 18;
else
frameSize.height += 18;
[fScrollView setFrameSize: frameSize];
[fWindow display];
[fDefaults setBool: fStatusBar forKey: @"StatusBar"];
}
- (BOOL)validateToolbarItem:(NSToolbarItem *)toolbarItem
{
SEL action = [toolbarItem action];
@ -894,6 +920,13 @@ static void sleepCallBack( void * controller, io_service_t y,
[menuItem setTitle: [fInfoPanel isVisible] ? @"Hide Info" : @"Show Info"];
return YES;
}
//enable toggle toolbar
if (action == @selector(toggleStatusBar:))
{
[menuItem setTitle: fStatusBar ? @"Hide Status Bar" : @"Show Status Bar"];
return YES;
}
//enable resume all item
if (action == @selector(resumeAllTorrents:))

View File

@ -8,12 +8,12 @@
<false/>
<key>BindPort</key>
<integer>9090</integer>
<key>CheckDownload</key>
<false/>
<key>CheckQuit</key>
<true/>
<key>CheckRemove</key>
<true/>
<key>CheckDownload</key>
<false/>
<key>CheckUpload</key>
<true/>
<key>DownloadChoice</key>
@ -32,6 +32,8 @@
<string>~/Desktop</string>
<key>ShowInspector</key>
<false/>
<key>StatusBar</key>
<true/>
<key>UploadLimit</key>
<integer>20</integer>
<key>UseAdvancedBar</key>

View File

@ -22,6 +22,7 @@
showPreferenceWindow = id;
stopAllTorrents = id;
stopTorrent = id;
toggleStatusBar = id;
};
CLASS = Controller;
LANGUAGE = ObjC;
@ -51,14 +52,18 @@
fRevealItem = NSMenuItem;
fScrollView = NSScrollView;
fShowHideToolbar = NSMenuItem;
fStats = NSBox;
fTableView = TorrentTableView;
fTotalDLField = NSTextField;
fTotalTorrentsField = NSTextField;
fTotalULField = NSTextField;
fWindow = NSWindow;
};
SUPERCLASS = NSObject;
},
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = MenuButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; },
{CLASS = NSSegmentedControl; LANGUAGE = ObjC; SUPERCLASS = NSControl; },
{CLASS = NameCell; LANGUAGE = ObjC; SUPERCLASS = NSCell; },
{
ACTIONS = {
@ -67,7 +72,9 @@
setDownloadLocation = id;
setLimit = id;
setLimitCheck = id;
setLimitMenu = id;
setPort = id;
setQuickSpeed = id;
setQuitMessage = id;
setRemoveMessage = id;
setUpdate = id;
@ -80,6 +87,9 @@
fBlankView = NSView;
fDownloadCheck = NSButton;
fDownloadField = NSTextField;
fDownloadLimitItem = NSMenuItem;
fDownloadMenu = NSMenu;
fDownloadNoLimitItem = NSMenuItem;
fFolderPopUp = NSPopUpButton;
fGeneralView = NSView;
fNetworkView = NSView;
@ -90,6 +100,9 @@
fUpdatePopUp = NSPopUpButton;
fUploadCheck = NSButton;
fUploadField = NSTextField;
fUploadLimitItem = NSMenuItem;
fUploadMenu = NSMenu;
fUploadNoLimitItem = NSMenuItem;
fWindow = NSWindow;
};
SUPERCLASS = NSObject;

View File

@ -3,9 +3,11 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>62 69 426 365 0 0 1280 832 </string>
<string>51 70 426 365 0 0 1152 842 </string>
<key>IBEditorPositions</key>
<dict>
<key>1041</key>
<string>344 478 204 68 0 0 1152 842 </string>
<key>29</key>
<string>79 778 371 44 0 0 1152 842 </string>
<key>456</key>
@ -13,13 +15,13 @@
<key>581</key>
<string>324 628 112 68 0 0 1152 842 </string>
<key>589</key>
<string>54 521 112 118 0 0 1152 842 </string>
<string>54 521 103 68 0 0 1152 842 </string>
<key>783</key>
<string>411 429 420 250 0 0 1280 832 </string>
<string>366 453 420 250 0 0 1152 842 </string>
<key>796</key>
<string>411 472 420 164 0 0 1280 832 </string>
<string>366 496 420 164 0 0 1152 842 </string>
<key>825</key>
<string>544 501 155 107 0 0 1280 832 </string>
<string>498 525 155 107 0 0 1152 842 </string>
</dict>
<key>IBFramework Version</key>
<string>443.0</string>
@ -27,7 +29,6 @@
<integer>3</integer>
<key>IBOpenObjects</key>
<array>
<integer>796</integer>
<integer>21</integer>
</array>
<key>IBSystem Version</key>

Binary file not shown.

Binary file not shown.

Binary file not shown.

6
macosx/MenuButton.h Normal file
View File

@ -0,0 +1,6 @@
#import <Cocoa/Cocoa.h>
@interface MenuButton : NSButton
{
}
@end

21
macosx/MenuButton.m Normal file
View File

@ -0,0 +1,21 @@
#import "MenuButton.h"
@implementation MenuButton
- (void) mouseDown: (NSEvent *) event
{
[self setState: NSOnState];
[self highlight: YES];
[NSMenu popUpContextMenu: [self menu] withEvent: event forView: self];
[self setState: NSOffState];
[self highlight: NO];
}
- (NSMenu *) menuForEvent: (NSEvent *) e
{
return nil;
}
@end

View File

@ -47,6 +47,10 @@
IBOutlet NSButton * fDownloadCheck;
IBOutlet NSTextField * fDownloadField;
IBOutlet NSMenu * fUploadMenu, * fDownloadMenu;
IBOutlet NSMenuItem * fUploadLimitItem, * fUploadNoLimitItem,
* fDownloadLimitItem, * fDownloadNoLimitItem;
IBOutlet NSWindow * fWindow;
NSString * fDownloadFolder;
@ -65,5 +69,7 @@
- (void) setPort: (id) sender;
- (void) setLimitCheck: (id) sender;
- (void) setLimit: (id) sender;
- (void) setLimitMenu: (id) sender;
- (void) setQuickSpeed: (id) sender;
@end

View File

@ -124,6 +124,13 @@
[fUploadField setIntValue: uploadLimit];
[fUploadField setEnabled: checkUpload];
[fUploadLimitItem setTitle:
[NSString stringWithFormat: @"Limit (%d KB/s)", uploadLimit]];
if (checkUpload)
[fUploadLimitItem setState: NSOnState];
else
[fUploadNoLimitItem setState: NSOnState];
tr_setUploadLimit( fHandle, checkUpload ? uploadLimit : -1 );
//set download limit
@ -134,6 +141,13 @@
[fDownloadField setIntValue: downloadLimit];
[fDownloadField setEnabled: checkDownload];
[fDownloadLimitItem setTitle:
[NSString stringWithFormat: @"Limit (%d KB/s)", downloadLimit]];
if (checkDownload)
[fDownloadLimitItem setState: NSOnState];
else
[fDownloadNoLimitItem setState: NSOnState];
tr_setDownloadLimit( fHandle, checkDownload ? downloadLimit : -1 );
//set remove and quit prompts
@ -230,33 +244,22 @@
}
}
- (void) setLimitCheck: (id) sender
{
NSString * key;
NSTextField * field;
if( sender == fUploadCheck )
{
key = @"CheckUpload";
field = fUploadField;
}
else
{
key = @"CheckDownload";
field = fDownloadField;
}
BOOL check = [sender state] == NSOnState;
[fDefaults setBool: check forKey: key];
[self setLimit: field];
[field setEnabled: check];
}
- (void) setLimit: (id) sender
{
int limit = [sender intValue];
NSString * key = ( sender == fUploadField ) ?
@"UploadLimit" : @"DownloadLimit";
NSString * key;
NSMenuItem * menuItem;
if (sender == fUploadField)
{
key = @"UploadLimit";
menuItem = fUploadLimitItem;
}
else
{
key = @"DownloadLimit";
menuItem = fDownloadLimitItem;
}
//if value entered is not an int or is less than 0 do not change
if (![[sender stringValue] isEqualToString:
@ -268,6 +271,7 @@
}
else
{
[menuItem setTitle: [NSString stringWithFormat: @"Limit (%d KB/s)", limit]];
[fDefaults setInteger: limit forKey: key];
}
@ -279,6 +283,65 @@
( [fDownloadCheck state] == NSOffState ) ? -1 : limit );
}
- (void) setLimitCheck: (id) sender
{
NSString * key;
NSTextField * field;
NSMenuItem * limitItem, * noLimitItem;
if( sender == fUploadCheck )
{
key = @"CheckUpload";
field = fUploadField;
limitItem = fUploadLimitItem;
noLimitItem = fUploadNoLimitItem;
}
else
{
key = @"CheckDownload";
field = fDownloadField;
limitItem = fDownloadLimitItem;
noLimitItem = fDownloadNoLimitItem;
}
BOOL check = [sender state] == NSOnState;
[limitItem setState: check ? NSOnState : NSOffState];
[noLimitItem setState: !check ? NSOnState : NSOffState];
[fDefaults setBool: check forKey: key];
[self setLimit: field];
[field setEnabled: check];
}
- (void) setLimitMenu: (id) sender
{
NSButton * check = (sender == fUploadLimitItem || sender == fUploadNoLimitItem)
? fUploadCheck : fDownloadCheck;
int state = (sender == fUploadLimitItem || sender == fDownloadLimitItem)
? NSOnState : NSOffState;
[check setState: state];
[self setLimitCheck: check];
}
- (void) setQuickSpeed: (id) sender
{
NSString * title = [sender title];
int limit = [[title substringToIndex: [title length] - [@" KB/s" length]] intValue];
if ([sender menu] == fUploadMenu)
{
[fUploadField setIntValue: limit];
[self setLimitMenu: fUploadLimitItem];
}
else
{
[fDownloadField setIntValue: limit];
[self setLimitMenu: fDownloadLimitItem];
}
}
- (void) setQuitMessage: (id) sender
{
[fDefaults setBool: ( [fQuitCheck state] == NSOnState )

View File

@ -137,11 +137,14 @@
if( row >= 0 )
{
if( OSX_VERSION >= 10.3 )
[self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]
byExtendingSelection: [self isRowSelected: row]];
else
[self selectRow: row byExtendingSelection: [self isRowSelected: row]];
if (![self isRowSelected: row])
{
if( OSX_VERSION >= 10.3 )
[self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]
byExtendingSelection: NO];
else
[self selectRow: row byExtendingSelection: NO];
}
return fContextRow;
}
else