Put NSAutoreleasePool usage around other distributed notification observer methods
[adiumx.git] / Source / AIStatusIconPreviewController.m
blob7acdbf541e14b919b1deb45ad4b3a4f52ea44193
1 /* 
2 * Adium is the legal property of its developers, whose names are listed in the copyright file included
3  * with this source distribution.
4  * 
5  * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
6  * General Public License as published by the Free Software Foundation; either version 2 of the License,
7  * or (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
11  * Public License for more details.
12  * 
13  * You should have received a copy of the GNU General Public License along with this program; if not,
14  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15  */
17 #import "AIStatusIconPreviewController.h"
19 @implementation AIStatusIconPreviewController
21 - (NSView *) previewView
23         return tableView;
26 - (void) setXtra:(AIXtraInfo *)xtraInfo
28         [images autorelease];
29         images = [[NSMutableArray alloc] init];
30         [statusNames autorelease];
31         NSEnumerator * paths;
32         NSString * resourcePath = [xtraInfo resourcePath];
33         NSDictionary * iconDict = [[NSDictionary dictionaryWithContentsOfFile:[resourcePath stringByAppendingPathComponent:@"Icons.plist"]] objectForKey:@"List"];
34         
35         paths = [[iconDict allValues] objectEnumerator];
36         statusNames = [[iconDict allKeys] retain];
37                         
38         NSImage * image;
39         NSString * imageName;
40         NSString * imagePath;
41         while((imageName = [paths nextObject]))
42         {
43                 imagePath = [resourcePath stringByAppendingPathComponent:imageName];
44                 image = [[[NSImage alloc] initWithContentsOfFile:imagePath] autorelease];
45                 if(image)
46                         [images addObject:image];
47         }
48         [tableView reloadData];
49         [tableView sizeToFit];
52 - (void) awakeFromNib
53 {       
54         [tableView setIntercellSpacing:NSMakeSize(1.0f, 3.0f)];
55         [tableView setHeaderView:nil];
56         
57         NSTableColumn * column = [[NSTableColumn alloc] initWithIdentifier:@"Status Icon"];
58         [column setMaxWidth:32.0f];
59         [column setMinWidth:32.0f];
60         [column setDataCell:[[[NSImageCell alloc]init]autorelease]];
61         [tableView addTableColumn:column];
62         [column release];
63         
64         column = [[NSTableColumn alloc] initWithIdentifier:@"Status Name"];
65         [tableView addTableColumn:column];
66         [column release];
69 - (BOOL)tableView:(NSTableView *)aTableView shouldSelectRow:(int)rowIndex
71         return NO;
74 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
76         return [statusNames count];
79 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
81         if([[aTableColumn identifier] isEqualToString:@"Status Icon"])
82                 return [images objectAtIndex:rowIndex];
83         else
84                 return [statusNames objectAtIndex:rowIndex];
87 @end