Changeset 5236


Ignore:
Timestamp:
Mar 11, 2008, 3:46:38 AM (14 years ago)
Author:
livings124
Message:

make the file menu code a bit more straightforward

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/TorrentTableView.m

    r5235 r5236  
    530530        return;
    531531   
    532     //get and update file menu
     532    NSInteger numberOfNonFileItems = [fActionMenu numberOfItems];
     533   
     534    //update file action menu
    533535    fMenuTorrent = [[self itemAtRow: row] retain];
    534    
    535     NSMenu * fileMenu = [[NSMenu alloc] initWithTitle: @"TorrentMenu"];
    536     [fileMenu setAutoenablesItems: NO];
    537     [self createFileMenu: fileMenu forFiles: [fMenuTorrent fileList]];
    538    
    539     //add file menu items to action menu
    540     NSInteger numberOfItems = [fileMenu numberOfItems];
    541     [fActionMenu appendItemsFromMenu: fileMenu atIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, numberOfItems)]
    542         atBottom: YES];
    543     [fileMenu release];
     536    [self createFileMenu: fActionMenu forFiles: [fMenuTorrent fileList]];
    544537   
    545538    //place menu below button
     
    556549   
    557550    NSInteger i;
    558     for (i = 0; i < numberOfItems; i++)
    559         [fActionMenu removeItemAtIndex: [fActionMenu numberOfItems]-1];
     551    for (i = [fActionMenu numberOfItems]-1; i >= numberOfNonFileItems; i--)
     552        [fActionMenu removeItemAtIndex: i];
    560553   
    561554    [fMenuTorrent release];
     
    637630    else  //assume the menu is part of the file list
    638631    {
     632        if ([menu numberOfItems] > 0)
     633            return;
     634       
    639635        NSMenu * supermenu = [menu supermenu];
    640636        [self createFileMenu: menu forFiles: [[[supermenu itemAtIndex: [supermenu indexOfItemWithSubmenu: menu]]
     
    827823- (void) createFileMenu: (NSMenu *) menu forFiles: (NSArray *) files
    828824{
    829     if ([menu numberOfItems] > 0)
    830         return;
    831    
    832825    NSEnumerator * enumerator = [files objectEnumerator];
    833826    NSDictionary * dict;
Note: See TracChangeset for help on using the changeset viewer.