Changeset 4085


Ignore:
Timestamp:
Dec 6, 2007, 8:54:26 PM (14 years ago)
Author:
livings124
Message:

even more toolbar cleanup code

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/ButtonGroupToolbarItem.m

    r4084 r4085  
    5858   
    5959    NSMenuItem * addItem;
    60     int i;
    61     for (i = 0; i < [(NSSegmentedControl *)[self view] segmentCount]; i++)
     60    int i, count = [(NSSegmentedControl *)[self view] segmentCount];
     61    for (i = 0; i < count; i++)
    6262    {
    6363        addItem = [[NSMenuItem alloc] initWithTitle: [labels objectAtIndex: i] action: [self action] keyEquivalent: @""];
     
    7878    NSMenuItem * menuItem = [super menuFormRepresentation];
    7979   
    80     int i;
    81     for (i = 0; i < [(NSSegmentedControl *)[self view] segmentCount]; i++)
     80    int i, count = [(NSSegmentedControl *)[self view] segmentCount];
     81    for (i = 0; i < count; i++)
    8282        [[[menuItem submenu] itemAtIndex: i] setEnabled: [[self target] validateToolbarItem:
    8383            [[[NSToolbarItem alloc] initWithItemIdentifier: [fIdentifiers objectAtIndex: i]] autorelease]]];
  • trunk/macosx/Controller.m

    r4084 r4085  
    26452645- (void) doNothing: (id) sender {}
    26462646
    2647 - (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident willBeInsertedIntoToolbar: (BOOL) flag
    2648 {
    2649     ButtonToolbarItem * item = [[[ButtonToolbarItem alloc] initWithItemIdentifier: ident] autorelease];
     2647- (ButtonToolbarItem *) standardToolbarButtonWithIdentifier: (NSString *) ident
     2648{
     2649    ButtonToolbarItem * item = [[ButtonToolbarItem alloc] initWithItemIdentifier: ident];
    26502650   
    26512651    NSButton * button = [[NSButton alloc] initWithFrame: NSZeroRect];
     
    26602660    [item setMaxSize: buttonSize];
    26612661   
     2662    return [item autorelease];
     2663}
     2664
     2665- (NSToolbarItem *) toolbar: (NSToolbar *) toolbar itemForItemIdentifier: (NSString *) ident willBeInsertedIntoToolbar: (BOOL) flag
     2666{
    26622667    if ([ident isEqualToString: TOOLBAR_CREATE])
    26632668    {
     2669        ButtonToolbarItem * item = [self standardToolbarButtonWithIdentifier: ident];
     2670       
    26642671        [item setLabel: NSLocalizedString(@"Create", "Create toolbar item -> label")];
    26652672        [item setPaletteLabel: NSLocalizedString(@"Create Torrent File", "Create toolbar item -> palette label")];
     
    26692676        [item setAction: @selector(createFile:)];
    26702677        [item setAutovalidates: NO];
     2678       
     2679        return item;
    26712680    }
    26722681    else if ([ident isEqualToString: TOOLBAR_OPEN])
    26732682    {
     2683        ButtonToolbarItem * item = [self standardToolbarButtonWithIdentifier: ident];
     2684       
    26742685        [item setLabel: NSLocalizedString(@"Open", "Open toolbar item -> label")];
    26752686        [item setPaletteLabel: NSLocalizedString(@"Open Torrent Files", "Open toolbar item -> palette label")];
     
    26792690        [item setAction: @selector(openShowSheet:)];
    26802691        [item setAutovalidates: NO];
     2692       
     2693        return item;
    26812694    }
    26822695    else if ([ident isEqualToString: TOOLBAR_REMOVE])
    26832696    {
     2697        ButtonToolbarItem * item = [self standardToolbarButtonWithIdentifier: ident];
     2698       
    26842699        [item setLabel: NSLocalizedString(@"Remove", "Remove toolbar item -> label")];
    26852700        [item setPaletteLabel: NSLocalizedString(@"Remove Selected", "Remove toolbar item -> palette label")];
     
    26882703        [item setTarget: self];
    26892704        [item setAction: @selector(removeNoDelete:)];
     2705       
     2706        return item;
    26902707    }
    26912708    else if ([ident isEqualToString: TOOLBAR_INFO])
    26922709    {
     2710        ButtonToolbarItem * item = [self standardToolbarButtonWithIdentifier: ident];
     2711       
    26932712        [item setLabel: NSLocalizedString(@"Inspector", "Inspector toolbar item -> label")];
    26942713        [item setPaletteLabel: NSLocalizedString(@"Toggle Inspector", "Inspector toolbar item -> palette label")];
     
    26982717        [item setAction: @selector(showInfo:)];
    26992718        [item setAutovalidates: NO];
     2719       
     2720        return item;
    27002721    }
    27012722    else if ([ident isEqualToString: TOOLBAR_PAUSE_RESUME_ALL])
    27022723    {
    2703         ButtonGroupToolbarItem * groupItem = [[[ButtonGroupToolbarItem alloc] initWithItemIdentifier: ident] autorelease];
     2724        ButtonGroupToolbarItem * groupItem = [[ButtonGroupToolbarItem alloc] initWithItemIdentifier: ident];
    27042725       
    27052726        NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
     
    27322753       
    27332754        [segmentedControl release];
    2734         return groupItem;
    2735     }
    2736 
     2755        return [groupItem autorelease];
     2756    }
    27372757    else if ([ident isEqualToString: TOOLBAR_PAUSE_RESUME_SELECTED])
    27382758    {
    2739         ButtonGroupToolbarItem * groupItem = [[[ButtonGroupToolbarItem alloc] initWithItemIdentifier: ident] autorelease];
     2759        ButtonGroupToolbarItem * groupItem = [[ButtonGroupToolbarItem alloc] initWithItemIdentifier: ident];
    27402760       
    27412761        NSSegmentedControl * segmentedControl = [[NSSegmentedControl alloc] initWithFrame: NSZeroRect];
     
    27682788       
    27692789        [segmentedControl release];
    2770         return groupItem;
     2790        return [groupItem autorelease];
    27712791    }
    27722792    else if ([ident isEqualToString: TOOLBAR_FILTER])
    27732793    {
     2794        ButtonToolbarItem * item = [self standardToolbarButtonWithIdentifier: ident];
     2795       
    27742796        [item setLabel: NSLocalizedString(@"Filter", "Filter toolbar item -> label")];
    27752797        [item setPaletteLabel: NSLocalizedString(@"Toggle Filter", "Filter toolbar item -> palette label")];
     
    27792801        [item setAction: @selector(toggleFilterBar:)];
    27802802        [item setAutovalidates: NO];
     2803       
     2804        return item;
    27812805    }
    27822806    else
    27832807        return nil;
    2784 
    2785     return item;
    27862808}
    27872809
Note: See TracChangeset for help on using the changeset viewer.