Ignore:
Timestamp:
Jan 30, 2012, 12:14:43 AM (10 years ago)
Author:
livings124
Message:

Sort the Sort menu items on launch, since the main menu is now localized through a strings file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r13178 r13184  
    403403    [fTableView registerForDraggedTypes: [NSArray arrayWithObject: TORRENT_TABLE_VIEW_DATA_TYPE]];
    404404    [fWindow registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, NSURLPboardType, nil]];
     405   
     406    //sort the sort menu items (localization is from strings file)
     407    NSMutableArray * sortMenuItems = [NSMutableArray arrayWithCapacity: 7];
     408    NSUInteger sortMenuIndex = 0;
     409    BOOL foundSortItem = NO;
     410    for (NSMenuItem * item in [fSortMenu itemArray])
     411    {
     412        if ([item action] == @selector(setSort:) && [item tag] != SORT_ORDER_TAG)
     413        {
     414            [sortMenuItems addObject: item];
     415            [fSortMenu removeItemAtIndex: sortMenuIndex];
     416            foundSortItem = YES;
     417        }
     418        else
     419        {
     420            if (foundSortItem)
     421                break;
     422            ++sortMenuIndex;
     423        }
     424    }
     425   
     426    [sortMenuItems sortUsingDescriptors: [NSArray arrayWithObject: [NSSortDescriptor sortDescriptorWithKey: @"title" ascending: YES selector: @selector(localizedCompare:)]]];
     427   
     428    for (NSMenuItem * item in sortMenuItems)
     429        [fSortMenu insertItem: item atIndex: sortMenuIndex++];
    405430   
    406431    //you would think this would be called later in this method from updateUI, but it's not reached in awakeFromNib
Note: See TracChangeset for help on using the changeset viewer.