Adium

Changeset 15593

Show
Ignore:
Timestamp:
03/25/2006 08:36:00 PM (3 years ago)
Author:
kiel
Message:

Using NSToolbarItem's copy method instead of re-implementing it. It seems to resolve a bug where a toolbar item doesn't seem to have a toolbar in text-only mode. Please revert this if it causes any problems.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Frameworks/AIUtilities Framework/Source/AIToolbarUtilities.m

    r14073 r15593  
    109109+ (NSToolbarItem *)toolbarItemFromDictionary:(NSDictionary *)theDict withIdentifier:(NSString *)itemIdentifier 
    110110{ 
    111     /* We create and autorelease a new NSToolbarItem (or a subclass of one, hence [item class]) 
    112          * and then go through the process of setting up its attributes from the master toolbar item matching that identifier 
    113          * in our dictionary of items. 
    114          */ 
    115     NSToolbarItem *item; 
    116         NSToolbarItem *newItem; 
    117          
    118         item = [theDict objectForKey:itemIdentifier]; 
    119         newItem = [[[[item class] alloc] initWithItemIdentifier:itemIdentifier] autorelease]; 
    120  
    121     [newItem setLabel:[item label]]; 
    122     [newItem setPaletteLabel:[item paletteLabel]]; 
    123     if ([item view] != NULL) { 
    124                 //For a toolbar only used in one window at a time, it's alright for a view to not allow copying 
    125                 if ([[item view] respondsToSelector:@selector(copyWithZone:)]) { 
    126                         [newItem setView:[[[item view] copy] autorelease]]; 
    127                 } else { 
    128                         [newItem setView:[item view]]; 
    129                 } 
    130     } else { 
    131         [newItem setImage:[item image]]; 
    132     } 
    133          
    134     [newItem setToolTip:[item toolTip]]; 
    135     [newItem setTarget:[item target]]; 
    136     [newItem setAction:[item action]]; 
    137     [newItem setMenuFormRepresentation:[item menuFormRepresentation]]; 
    138          
    139     //If we have a custom view, we *have* to set the min/max size - otherwise, it'll default to 0,0 and the custom 
    140     //view won't show up at all!  This doesn't affect toolbar items with images, however. 
    141     if ([newItem view] != NULL) { 
    142         [newItem setMinSize:[item minSize]]; 
    143         [newItem setMaxSize:[item maxSize]]; 
    144                  
    145                 if ([[newItem view] respondsToSelector:@selector(setToolbarItem:)]) { 
    146                         [[newItem view] setToolbarItem:newItem]; 
    147                 } 
    148     } 
    149  
    150     return newItem; 
     111        return [[[theDict objectForKey:itemIdentifier] copy] autorelease]; 
    151112} 
    152113