Adium

Changeset 15748

Show
Ignore:
Timestamp:
04/12/2006 12:47:20 PM (3 years ago)
Author:
evands
Message:

Improved the Emoticons Customize sheet:

  • Emoticon images are cached (temporarily, of course) for a huge speed improvement when scrolling within the emoticons of an emoticon pack.
  • Name and text equivalent are now vertically centered and truncate if necessary by ellipsizing the tail. Fixes #3235.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plugins/Emoticons/AIEmoticonPreferences.h

    r11978 r15748  
    3333    NSButtonCell                            *checkCell; 
    3434    AIEmoticonPack                          *selectedEmoticonPack; 
     35        NSMutableDictionary                                             *emoticonImageCache; 
    3536 
    3637    NSArray                                 *dragRows; 
  • trunk/Plugins/Emoticons/AIEmoticonPreferences.m

    r15730 r15748  
    2525#import <AIUtilities/AIGenericViewCell.h> 
    2626#import <AIUtilities/AIImageAdditions.h> 
     27#import <AIUtilities/AIVerticallyCenteredTextCell.h> 
     28 
    2729#import <Adium/AIListObject.h> 
    2830#import "AIPreferenceController.h" 
     
    3032#define EMOTICON_PACK_DRAG_TYPE         @"AIEmoticonPack" 
    3133#define EMOTICON_MIN_ROW_HEIGHT         17 
     34#define EMOTICON_MAX_ROW_HEIGHT                 64 
    3235#define EMOTICON_PACKS_TOOLTIP          AILocalizedString(@"Reorder emoticon packs by dragging. Packs are used in the order listed.",nil) 
    3336 
     
    105108    [checkCell setRefusesFirstResponder:YES]; 
    106109    [[table_emoticons tableColumnWithIdentifier:@"Enabled"] setDataCell:checkCell]; 
    107          
    108         NSImageCell *imageCell = [[[NSImageCell alloc] init] autorelease]; 
     110        [checkCell release]; 
     111 
     112        NSImageCell *imageCell = [[NSImageCell alloc] initImageCell:nil]; 
    109113        if ([imageCell respondsToSelector:@selector(_setAnimates:)]) [imageCell _setAnimates:NO]; 
    110          
    111     [[table_emoticons tableColumnWithIdentifier:@"Image"] setDataCell:imageCell]; 
     114        [[table_emoticons tableColumnWithIdentifier:@"Image"] setDataCell:imageCell]; 
     115        [imageCell release]; 
     116 
     117        AIVerticallyCenteredTextCell *textCell = [[AIVerticallyCenteredTextCell alloc] init]; 
     118        [textCell setLineBreakMode:NSLineBreakByTruncatingTail]; 
     119        [[table_emoticons tableColumnWithIdentifier:@"Name"] setDataCell:textCell]; 
     120        [textCell release]; 
     121         
     122        textCell = [[AIVerticallyCenteredTextCell alloc] init]; 
     123        [textCell setLineBreakMode:NSLineBreakByTruncatingTail]; 
     124        [[table_emoticons tableColumnWithIdentifier:@"String"] setDataCell:textCell]; 
     125        [textCell release]; 
     126 
    112127    [table_emoticons setDrawsAlternatingRows:YES]; 
    113128         
     
    119134 
    120135        [button_OK setLocalizedString:AILocalizedString(@"CloseSheet",nil)]; 
    121  
     136         
    122137        //Redisplay the emoticons after an small delay so the sample emoticons line up properly 
    123138        //since the desired width isn't known by AIEmoticonPackCell until once through the list of packs 
     
    135150        [emoticonPackPreviewControllers release]; emoticonPackPreviewControllers = nil; 
    136151        [[adium preferenceController] unregisterPreferenceObserver:self]; 
     152        [emoticonImageCache release]; emoticonImageCache = nil; 
    137153 
    138154    //Flush all the images we loaded 
     
    197213        rowHeight = totalHeight / [[selectedEmoticonPack emoticons] count]; 
    198214        if (rowHeight < EMOTICON_MIN_ROW_HEIGHT) rowHeight = EMOTICON_MIN_ROW_HEIGHT; 
     215                if (rowHeight > EMOTICON_MAX_ROW_HEIGHT) rowHeight = EMOTICON_MAX_ROW_HEIGHT; 
    199216    } 
    200217     
     218        [emoticonImageCache release]; 
     219        emoticonImageCache = [[NSMutableDictionary alloc] init]; 
     220         
    201221    //Update the table 
    202222    [table_emoticons reloadData]; 
     
    270290             
    271291        } else if ([identifier isEqualToString:@"Image"]) { 
    272             return [emoticon image]; 
    273              
    274         } else if ([identifier isEqualToString:@"Name"]) { 
     292                        NSNumber *key = [NSNumber numberWithUnsignedInt:[emoticon hash]]; 
     293                        NSImage *image = [emoticonImageCache objectForKey:key]; 
     294                        if (!image) { 
     295                                image = [emoticon image]; 
     296                                [emoticonImageCache setObject:image 
     297                                                                           forKey:key]; 
     298                        } 
     299                         
     300                        return image; 
     301         
     302                } else if ([identifier isEqualToString:@"Name"]) { 
    275303            if ([selectedEmoticonPack isEnabled] && [emoticon isEnabled]) { 
    276304                                return [emoticon name]; 
  • trunk/Source/AIAppearancePreferencesPlugin.m

    r15574 r15748  
    329329 
    330330                name = [[filePath lastPathComponent] stringByDeletingPathExtension]; 
    331                 NSLog(@"Name is %@",name); 
     331 
    332332                if((xtraBundle = [NSBundle bundleWithPath:filePath]) && 
    333333                   ([[xtraBundle objectForInfoDictionaryKey:@"XtraBundleVersion"] intValue] == 1)) { 
     
    346346                                [alreadyAddedArray addObject:name]; 
    347347                        } else { 
    348                                 NSLog(@"Already added"); 
     348                                //NSLog(@"Already added"); 
    349349                        } 
    350350                }