mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
clean code up a little
This commit is contained in:
parent
5c2f4e5fd1
commit
41d5f3c8f5
2 changed files with 52 additions and 50 deletions
|
@ -521,7 +521,6 @@ static int static_lastid = 0;
|
||||||
return fStat->ratio;
|
return fStat->ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning make enum
|
|
||||||
- (int) ratioSetting
|
- (int) ratioSetting
|
||||||
{
|
{
|
||||||
return fRatioSetting;
|
return fRatioSetting;
|
||||||
|
|
|
@ -352,9 +352,6 @@
|
||||||
|
|
||||||
BOOL create = [menu numberOfItems] <= 0, folder;
|
BOOL create = [menu numberOfItems] <= 0, folder;
|
||||||
|
|
||||||
NSMenu * supermenu = [menu supermenu];
|
|
||||||
NSArray * items;
|
|
||||||
NSDictionary * folderDict;
|
|
||||||
#warning move to submethod
|
#warning move to submethod
|
||||||
if (menu == fUploadMenu || menu == fDownloadMenu)
|
if (menu == fUploadMenu || menu == fDownloadMenu)
|
||||||
{
|
{
|
||||||
|
@ -391,67 +388,73 @@
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ((folderDict = [[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject]))
|
else if ([menu supermenu]) //assume the menu is part of the file list
|
||||||
items = [[[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject] objectForKey: @"Children"];
|
|
||||||
else
|
|
||||||
items = [fMenuTorrent fileList];
|
|
||||||
|
|
||||||
#warning move rest to submethod
|
|
||||||
NSEnumerator * enumerator = [items objectEnumerator];
|
|
||||||
NSDictionary * dict;
|
|
||||||
NSMenuItem * item;
|
|
||||||
while ((dict = [enumerator nextObject]))
|
|
||||||
{
|
{
|
||||||
NSString * name = [dict objectForKey: @"Name"];
|
NSMenu * supermenu = [menu supermenu];
|
||||||
|
NSArray * items;
|
||||||
|
NSDictionary * folderDict;
|
||||||
|
if ((folderDict = [[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]] representedObject]))
|
||||||
|
items = [folderDict objectForKey: @"Children"];
|
||||||
|
else
|
||||||
|
items = [fMenuTorrent fileList];
|
||||||
|
|
||||||
folder = [[dict objectForKey: @"IsFolder"] boolValue];
|
NSEnumerator * enumerator = [items objectEnumerator];
|
||||||
|
NSDictionary * dict;
|
||||||
if (create)
|
NSMenuItem * item;
|
||||||
|
while ((dict = [enumerator nextObject]))
|
||||||
{
|
{
|
||||||
item = [[NSMenuItem alloc] initWithTitle: name action: NULL keyEquivalent: @""];
|
NSString * name = [dict objectForKey: @"Name"];
|
||||||
|
|
||||||
NSImage * icon;
|
folder = [[dict objectForKey: @"IsFolder"] boolValue];
|
||||||
if (!folder)
|
|
||||||
|
if (create)
|
||||||
{
|
{
|
||||||
icon = [[dict objectForKey: @"Icon"] copy];
|
item = [[NSMenuItem alloc] initWithTitle: name action: NULL keyEquivalent: @""];
|
||||||
[icon setFlipped: NO];
|
|
||||||
|
NSImage * icon;
|
||||||
|
if (!folder)
|
||||||
|
{
|
||||||
|
icon = [[dict objectForKey: @"Icon"] copy];
|
||||||
|
[icon setFlipped: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSMenu * itemMenu = [[NSMenu alloc] initWithTitle: name];
|
||||||
|
[itemMenu setAutoenablesItems: NO];
|
||||||
|
[item setSubmenu: itemMenu];
|
||||||
|
[itemMenu setDelegate: self];
|
||||||
|
[itemMenu release];
|
||||||
|
|
||||||
|
icon = [[[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')] copy];
|
||||||
|
}
|
||||||
|
|
||||||
|
[item setRepresentedObject: dict];
|
||||||
|
|
||||||
|
[icon setScalesWhenResized: YES];
|
||||||
|
[icon setSize: NSMakeSize(16.0, 16.0)];
|
||||||
|
[item setImage: icon];
|
||||||
|
[icon release];
|
||||||
|
|
||||||
|
[item setAction: @selector(checkFile:)];
|
||||||
|
|
||||||
|
[menu addItem: item];
|
||||||
|
[item release];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
item = [menu itemWithTitle: name];
|
||||||
NSMenu * itemMenu = [[NSMenu alloc] initWithTitle: name];
|
|
||||||
[itemMenu setAutoenablesItems: NO];
|
|
||||||
[item setSubmenu: itemMenu];
|
|
||||||
[itemMenu setDelegate: self];
|
|
||||||
[itemMenu release];
|
|
||||||
|
|
||||||
icon = [[[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')] copy];
|
|
||||||
}
|
|
||||||
|
|
||||||
[item setRepresentedObject: dict];
|
NSIndexSet * indexSet = [dict objectForKey: @"Indexes"];
|
||||||
|
[item setState: [fMenuTorrent checkForFiles: indexSet]];
|
||||||
[icon setScalesWhenResized: YES];
|
[item setEnabled: [fMenuTorrent canChangeDownloadCheckForFiles: indexSet]];
|
||||||
[icon setSize: NSMakeSize(16.0, 16.0)];
|
|
||||||
[item setImage: icon];
|
|
||||||
[icon release];
|
|
||||||
|
|
||||||
[item setAction: @selector(checkFile:)];
|
|
||||||
|
|
||||||
[menu addItem: item];
|
|
||||||
[item release];
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
item = [menu itemWithTitle: name];
|
|
||||||
|
|
||||||
NSIndexSet * indexSet = [dict objectForKey: @"Indexes"];
|
|
||||||
[item setState: [fMenuTorrent checkForFiles: indexSet]];
|
|
||||||
[item setEnabled: [fMenuTorrent canChangeDownloadCheckForFiles: indexSet]];
|
|
||||||
}
|
}
|
||||||
|
else;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setQuickLimitMode: (id) sender
|
- (void) setQuickLimitMode: (id) sender
|
||||||
{
|
{
|
||||||
int tag = [sender tag];
|
int tag = [sender tag];
|
||||||
int mode;
|
tr_speedlimit_t mode;
|
||||||
if (tag == ACTION_MENU_UNLIMITED_TAG)
|
if (tag == ACTION_MENU_UNLIMITED_TAG)
|
||||||
mode = TR_SPEEDLIMIT_UNLIMITED;
|
mode = TR_SPEEDLIMIT_UNLIMITED;
|
||||||
else if (tag == ACTION_MENU_LIMIT_TAG)
|
else if (tag == ACTION_MENU_LIMIT_TAG)
|
||||||
|
|
Loading…
Reference in a new issue