mirror of
https://github.com/transmission/transmission
synced 2025-03-10 06:02:57 +00:00
preliminary support for setting speed limits through the action menu
This commit is contained in:
parent
2a8f9eb1f9
commit
f0f61ddd2b
8 changed files with 107 additions and 20 deletions
10
macosx/English.lproj/MainMenu.nib/classes.nib
generated
10
macosx/English.lproj/MainMenu.nib/classes.nib
generated
|
@ -179,9 +179,17 @@
|
||||||
SUPERCLASS = NSObject;
|
SUPERCLASS = NSObject;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
ACTIONS = {checkFile = id; setQuickLimit = id; setQuickLimitMode = id; };
|
||||||
CLASS = TorrentTableView;
|
CLASS = TorrentTableView;
|
||||||
LANGUAGE = ObjC;
|
LANGUAGE = ObjC;
|
||||||
OUTLETS = {fContextNoRow = NSMenu; fContextRow = NSMenu; fController = Controller; };
|
OUTLETS = {
|
||||||
|
fActionMenu = NSMenu;
|
||||||
|
fContextNoRow = NSMenu;
|
||||||
|
fContextRow = NSMenu;
|
||||||
|
fController = Controller;
|
||||||
|
fDownloadMenu = NSMenu;
|
||||||
|
fUploadMenu = NSMenu;
|
||||||
|
};
|
||||||
SUPERCLASS = NSTableView;
|
SUPERCLASS = NSTableView;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
10
macosx/English.lproj/MainMenu.nib/info.nib
generated
10
macosx/English.lproj/MainMenu.nib/info.nib
generated
|
@ -7,13 +7,15 @@
|
||||||
<key>IBEditorPositions</key>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>1041</key>
|
<key>1041</key>
|
||||||
<string>308 271 208 149 0 0 1152 842 </string>
|
<string>480 344 208 149 0 0 1680 1028 </string>
|
||||||
<key>1480</key>
|
<key>1480</key>
|
||||||
<string>366 546 420 63 0 0 1152 842 </string>
|
<string>366 546 420 63 0 0 1152 842 </string>
|
||||||
<key>1603</key>
|
<key>1603</key>
|
||||||
<string>337 544 477 67 0 0 1152 842 </string>
|
<string>337 544 477 67 0 0 1152 842 </string>
|
||||||
|
<key>1936</key>
|
||||||
|
<string>785 583 166 80 0 0 1680 1028 </string>
|
||||||
<key>29</key>
|
<key>29</key>
|
||||||
<string>149 756 451 44 0 0 1152 842 </string>
|
<string>261 932 451 44 0 0 1680 1028 </string>
|
||||||
<key>456</key>
|
<key>456</key>
|
||||||
<string>396 374 240 225 0 0 1152 842 </string>
|
<string>396 374 240 225 0 0 1152 842 </string>
|
||||||
<key>581</key>
|
<key>581</key>
|
||||||
|
@ -31,10 +33,12 @@
|
||||||
<integer>3</integer>
|
<integer>3</integer>
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
|
<integer>1936</integer>
|
||||||
<integer>21</integer>
|
<integer>21</integer>
|
||||||
<integer>29</integer>
|
<integer>29</integer>
|
||||||
|
<integer>1041</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>8R218</string>
|
<string>8R4031</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
generated
Binary file not shown.
|
@ -106,7 +106,12 @@
|
||||||
[self updateInfoForTorrents: [NSArray array]];
|
[self updateInfoForTorrents: [NSArray array]];
|
||||||
|
|
||||||
//allow for update notifications
|
//allow for update notifications
|
||||||
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateInfoStats) name: @"UpdateStats" object: nil];
|
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
||||||
|
[nc addObserver: self selector: @selector(updateInfoStats)
|
||||||
|
name: @"UpdateStats" object: nil];
|
||||||
|
|
||||||
|
[nc addObserver: self selector: @selector(updateInfoSettings)
|
||||||
|
name: @"UpdateSettings" object: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
|
|
@ -62,7 +62,7 @@ typedef enum
|
||||||
tr_file_stat_t * fileStat;
|
tr_file_stat_t * fileStat;
|
||||||
NSArray * fFileList, * fFlatFileList;
|
NSArray * fFileList, * fFlatFileList;
|
||||||
|
|
||||||
NSMenu * fTorrentMenu;
|
NSMenu * fFileMenu;
|
||||||
|
|
||||||
float fRatioLimit;
|
float fRatioLimit;
|
||||||
int fRatioSetting;
|
int fRatioSetting;
|
||||||
|
@ -213,7 +213,7 @@ typedef enum
|
||||||
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
- (BOOL) hasFilePriority: (int) priority forIndexes: (NSIndexSet *) indexSet;
|
||||||
- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
|
- (NSSet *) filePrioritiesForIndexes: (NSIndexSet *) indexSet;
|
||||||
|
|
||||||
- (NSMenu *) torrentMenu;
|
- (NSMenu *) fileMenu;
|
||||||
|
|
||||||
- (NSDate *) dateAdded;
|
- (NSDate *) dateAdded;
|
||||||
- (NSDate *) dateCompleted;
|
- (NSDate *) dateCompleted;
|
||||||
|
|
|
@ -165,7 +165,7 @@ static int static_lastid = 0;
|
||||||
[fFileList release];
|
[fFileList release];
|
||||||
[fFlatFileList release];
|
[fFlatFileList release];
|
||||||
|
|
||||||
[fTorrentMenu release];
|
[fFileMenu release];
|
||||||
|
|
||||||
[fQuickPauseDict release];
|
[fQuickPauseDict release];
|
||||||
|
|
||||||
|
@ -563,6 +563,7 @@ static int static_lastid = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#warning use enum value
|
||||||
- (int) speedMode: (BOOL) upload
|
- (int) speedMode: (BOOL) upload
|
||||||
{
|
{
|
||||||
return tr_torrentGetSpeedMode(fHandle, upload ? TR_UP : TR_DOWN);
|
return tr_torrentGetSpeedMode(fHandle, upload ? TR_UP : TR_DOWN);
|
||||||
|
@ -1314,14 +1315,14 @@ static int static_lastid = 0;
|
||||||
return priorities;
|
return priorities;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSMenu *) torrentMenu
|
- (NSMenu *) fileMenu
|
||||||
{
|
{
|
||||||
if (!fTorrentMenu)
|
if (!fFileMenu)
|
||||||
{
|
{
|
||||||
fTorrentMenu = [[NSMenu alloc] initWithTitle: [@"TorrentMenu:" stringByAppendingString: [self name]]];
|
fFileMenu = [[NSMenu alloc] initWithTitle: [@"TorrentMenu:" stringByAppendingString: [self name]]];
|
||||||
[fTorrentMenu setAutoenablesItems: NO];
|
[fFileMenu setAutoenablesItems: NO];
|
||||||
}
|
}
|
||||||
return fTorrentMenu;
|
return fFileMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSDate *) dateAdded
|
- (NSDate *) dateAdded
|
||||||
|
|
|
@ -52,13 +52,17 @@
|
||||||
|
|
||||||
NSDictionary * fSmallStatusAttributes;
|
NSDictionary * fSmallStatusAttributes;
|
||||||
|
|
||||||
|
IBOutlet NSMenu * fActionMenu, * fUploadMenu, * fDownloadMenu;
|
||||||
Torrent * fMenuTorrent;
|
Torrent * fMenuTorrent;
|
||||||
NSEvent * fMenuEvent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setTorrents: (NSArray *) torrents;
|
- (void) setTorrents: (NSArray *) torrents;
|
||||||
|
|
||||||
- (void) displayTorrentMenuForEvent: (NSEvent *) event;
|
- (void) displayTorrentMenuForEvent: (NSEvent *) event;
|
||||||
|
|
||||||
|
- (void) setQuickLimitMode: (id) sender;
|
||||||
|
- (void) setQuickLimit: (id) sender;
|
||||||
|
|
||||||
- (void) checkFile: (id) sender;
|
- (void) checkFile: (id) sender;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
|
|
||||||
#define ACTION_BUTTON_TO_TOP 47.0
|
#define ACTION_BUTTON_TO_TOP 47.0
|
||||||
|
|
||||||
|
#define ACTION_MENU_GLOBAL_TAG 101
|
||||||
|
#define ACTION_MENU_UNLIMITED_TAG 102
|
||||||
|
#define ACTION_MENU_LIMIT_TAG 103
|
||||||
|
|
||||||
|
#define ACTION_MENU_FILE_TAG 201
|
||||||
|
|
||||||
@interface TorrentTableView (Private)
|
@interface TorrentTableView (Private)
|
||||||
|
|
||||||
- (NSRect) pauseRectForRow: (int) row;
|
- (NSRect) pauseRectForRow: (int) row;
|
||||||
|
@ -304,9 +310,25 @@
|
||||||
if (row < 0)
|
if (row < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
//get file menu
|
||||||
fMenuTorrent = [[fTorrents objectAtIndex: row] retain];
|
fMenuTorrent = [[fTorrents objectAtIndex: row] retain];
|
||||||
NSMenu * torrentMenu = [fMenuTorrent torrentMenu];
|
NSMenu * fileMenu = [fMenuTorrent fileMenu];
|
||||||
[torrentMenu setDelegate: self];
|
[fileMenu setDelegate: self];
|
||||||
|
|
||||||
|
//remove old file menu
|
||||||
|
NSMenuItem * oldFileMenuItem;
|
||||||
|
if ((oldFileMenuItem = [fActionMenu itemWithTag: ACTION_MENU_FILE_TAG]))
|
||||||
|
[fActionMenu removeItem: oldFileMenuItem];
|
||||||
|
|
||||||
|
//set file menu
|
||||||
|
#warning localize
|
||||||
|
NSMenuItem * fileMenuItem = [[NSMenuItem alloc] initWithTitle: NSLocalizedString(@"Files",
|
||||||
|
"torrent action context menu -> files menu") action: NULL keyEquivalent: @""];
|
||||||
|
[fileMenuItem setTag: ACTION_MENU_FILE_TAG];
|
||||||
|
[fileMenuItem setSubmenu: fileMenu];
|
||||||
|
[fActionMenu addItem: fileMenuItem];
|
||||||
|
|
||||||
|
[fileMenuItem release];
|
||||||
|
|
||||||
NSRect rect = [self actionRectForRow: row];
|
NSRect rect = [self actionRectForRow: row];
|
||||||
NSPoint location = rect.origin;
|
NSPoint location = rect.origin;
|
||||||
|
@ -317,7 +339,7 @@
|
||||||
modifierFlags: [event modifierFlags] timestamp: [event timestamp] windowNumber: [event windowNumber]
|
modifierFlags: [event modifierFlags] timestamp: [event timestamp] windowNumber: [event windowNumber]
|
||||||
context: [event context] eventNumber: [event eventNumber] clickCount: [event clickCount] pressure: [event pressure]];
|
context: [event context] eventNumber: [event eventNumber] clickCount: [event clickCount] pressure: [event pressure]];
|
||||||
|
|
||||||
[NSMenu popUpContextMenu: torrentMenu withEvent: newEvent forView: self];
|
[NSMenu popUpContextMenu: fActionMenu withEvent: newEvent forView: self];
|
||||||
|
|
||||||
[fMenuTorrent release];
|
[fMenuTorrent release];
|
||||||
fMenuTorrent = nil;
|
fMenuTorrent = nil;
|
||||||
|
@ -326,17 +348,39 @@
|
||||||
- (void) menuNeedsUpdate: (NSMenu *) menu
|
- (void) menuNeedsUpdate: (NSMenu *) menu
|
||||||
{
|
{
|
||||||
//this method seems to be called when it shouldn't be
|
//this method seems to be called when it shouldn't be
|
||||||
if (!fMenuTorrent)
|
if (!fMenuTorrent || ![menu supermenu])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BOOL create = [menu numberOfItems] <= 0, folder;
|
BOOL create = [menu numberOfItems] <= 0, folder;
|
||||||
|
|
||||||
NSMenu * supermenu = [menu supermenu];
|
NSMenu * supermenu = [menu supermenu];
|
||||||
NSArray * items;
|
NSArray * items;
|
||||||
if (supermenu)
|
NSDictionary * folderDict;
|
||||||
|
#warning move to submethod
|
||||||
|
if (menu == fUploadMenu || menu == fDownloadMenu)
|
||||||
|
{
|
||||||
|
BOOL upload = menu == fUploadMenu;
|
||||||
|
tr_speedlimit_t mode = [fMenuTorrent speedMode: upload];
|
||||||
|
|
||||||
|
NSMenuItem * item = [menu itemWithTag: ACTION_MENU_LIMIT_TAG];
|
||||||
|
[item setState: mode == TR_SPEEDLIMIT_SINGLE ? NSOnState : NSOffState];
|
||||||
|
[item setTitle: [NSString stringWithFormat: NSLocalizedString(@"Limit (%d KB/s)",
|
||||||
|
"torrent action context menu -> upload/download limit"), [fMenuTorrent speedLimit: upload]]];
|
||||||
|
|
||||||
|
item = [menu itemWithTag: ACTION_MENU_UNLIMITED_TAG];
|
||||||
|
[item setState: mode == TR_SPEEDLIMIT_UNLIMITED ? NSOnState : NSOffState];
|
||||||
|
|
||||||
|
item = [menu itemWithTag: ACTION_MENU_GLOBAL_TAG];
|
||||||
|
[item setState: mode == TR_SPEEDLIMIT_GLOBAL ? NSOnState : NSOffState];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if ((folderDict = [[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject]))
|
||||||
items = [[[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject] objectForKey: @"Children"];
|
items = [[[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject] objectForKey: @"Children"];
|
||||||
else
|
else
|
||||||
items = [fMenuTorrent fileList];
|
items = [fMenuTorrent fileList];
|
||||||
|
|
||||||
|
#warning move rest to submethod
|
||||||
NSEnumerator * enumerator = [items objectEnumerator];
|
NSEnumerator * enumerator = [items objectEnumerator];
|
||||||
NSDictionary * dict;
|
NSDictionary * dict;
|
||||||
NSMenuItem * item;
|
NSMenuItem * item;
|
||||||
|
@ -388,6 +432,27 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setQuickLimitMode: (id) sender
|
||||||
|
{
|
||||||
|
int tag = [sender tag];
|
||||||
|
tr_speedlimit_t mode;
|
||||||
|
if (tag == ACTION_MENU_UNLIMITED_TAG)
|
||||||
|
mode = TR_SPEEDLIMIT_UNLIMITED;
|
||||||
|
else if (tag == ACTION_MENU_LIMIT_TAG)
|
||||||
|
mode = TR_SPEEDLIMIT_SINGLE;
|
||||||
|
else
|
||||||
|
mode = TR_SPEEDLIMIT_GLOBAL;
|
||||||
|
|
||||||
|
[fMenuTorrent setSpeedMode: mode upload: [sender menu] == fUploadMenu];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateSettings" object: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setQuickLimit: (id) sender
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
- (void) checkFile: (id) sender
|
- (void) checkFile: (id) sender
|
||||||
{
|
{
|
||||||
#warning get working
|
#warning get working
|
||||||
|
|
Loading…
Add table
Reference in a new issue