mirror of
https://github.com/transmission/transmission
synced 2025-03-06 11:38:21 +00:00
allow new menu method to use an index set instead of range
This commit is contained in:
parent
420115e322
commit
ca6f1934b3
3 changed files with 12 additions and 10 deletions
|
@ -26,6 +26,6 @@
|
|||
|
||||
@interface NSMenu (NSMenuAdditions)
|
||||
|
||||
- (void) moveItemsToEndFromMenu: (NSMenu *) oldMenu inRange: (NSRange) range;
|
||||
- (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes;
|
||||
|
||||
@end
|
||||
|
|
|
@ -26,15 +26,17 @@
|
|||
|
||||
@implementation NSMenu (NSMenuAdditions)
|
||||
|
||||
- (void) moveItemsToEndFromMenu: (NSMenu *) oldMenu inRange: (NSRange) range
|
||||
- (void) appendItemsFromMenu: (NSMenu *) menu atIndexes: (NSIndexSet *) indexes
|
||||
{
|
||||
int bottom = [self numberOfItems];
|
||||
|
||||
NSMenuItem * item;
|
||||
int i;
|
||||
for (i=0; i<range.length; i++)
|
||||
unsigned int i;
|
||||
for (i = [indexes lastIndex]; i != NSNotFound; i = [indexes indexLessThanIndex: i])
|
||||
{
|
||||
item = [[oldMenu itemAtIndex: range.location] retain];
|
||||
[oldMenu removeItem: item];
|
||||
[self addItem: item];
|
||||
item = [[menu itemAtIndex:i] retain];
|
||||
[menu removeItem: item];
|
||||
[self insertItem: item atIndex: bottom];
|
||||
[item release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -317,8 +317,8 @@
|
|||
[self updateFileMenu: fileMenu forFiles: [fMenuTorrent fileList]];
|
||||
|
||||
//add file menu items to action menu
|
||||
NSRange range = NSMakeRange(0, [fileMenu numberOfItems]);
|
||||
[fActionMenu moveItemsToEndFromMenu: fileMenu inRange: range];
|
||||
NSRange range = NSMakeRange(0, [fileMenu numberOfItems]);
|
||||
[fActionMenu appendItemsFromMenu: fileMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range]];
|
||||
|
||||
//place menu below button
|
||||
NSRect rect = [self actionRectForRow: row];
|
||||
|
@ -334,7 +334,7 @@
|
|||
|
||||
//move file menu items back to the torrent's file menu
|
||||
range.location = [fActionMenu numberOfItems] - range.length;
|
||||
[fileMenu moveItemsToEndFromMenu: fActionMenu inRange: range];
|
||||
[fileMenu appendItemsFromMenu: fActionMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: range]];
|
||||
|
||||
[fMenuTorrent release];
|
||||
fMenuTorrent = nil;
|
||||
|
|
Loading…
Add table
Reference in a new issue