potential decrease in memory usage when showing the group dividers

This commit is contained in:
Mitchell Livingston 2008-05-31 02:38:44 +00:00
parent c00a3a97b7
commit 62f034cdbd
6 changed files with 27 additions and 20 deletions

View File

@ -2442,6 +2442,7 @@
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_WARN_UNUSED_FUNCTION = NO;
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.4;
OTHER_LDFLAGS = "";
@ -2461,6 +2462,7 @@
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_WARN_UNUSED_FUNCTION = NO;
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.4;
OTHER_LDFLAGS = "";

View File

@ -1625,7 +1625,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
return desired;
}
#warning migrate to Torrent.m
- (void) torrentFinishedDownloading: (NSNotification *) notification
{
Torrent * torrent = [notification object];
@ -2279,7 +2278,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
NSLocalizedString(@"No Label", "Groups -> Button")];
break;
default:
icon = [[GroupsController groups] imageForIndex: groupIndex isSmall: YES];
icon = [[GroupsController groups] imageForIndex: groupIndex];
toolTip = [NSString stringWithFormat: @"%@: %@", NSLocalizedString(@"Group", "Groups -> Button"),
[[GroupsController groups] nameForIndex: groupIndex]];
}
@ -2548,7 +2547,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
else if ([ident isEqualToString: @"Color"])
{
int group = [[item objectForKey: @"Group"] intValue];
return group != -1 ? [[GroupsController groups] imageForIndex: group isSmall: YES]
return group != -1 ? [[GroupsController groups] imageForIndex: group]
: [NSImage imageNamed: @"GroupsNoneTemplate.png"];
}
else if ([ident isEqualToString: @"DL Image"])

View File

@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9C7010</string>
<string key="IBDocument.InterfaceBuilderVersion">658</string>
<string key="IBDocument.AppKitVersion">949.26</string>
<string key="IBDocument.SystemVersion">9D34</string>
<string key="IBDocument.InterfaceBuilderVersion">667</string>
<string key="IBDocument.AppKitVersion">949.33</string>
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="2"/>
<integer value="3093"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -270,7 +270,7 @@ ARcABAAAAAEAAAACARwAAwAAAAEAAQAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="354434380">
<string key="NSIdentifier">Color</string>
<double key="NSWidth">3.200000e+01</double>
<double key="NSWidth">2.900000e+01</double>
<double key="NSMinWidth">1.600000e+01</double>
<double key="NSMaxWidth">3.000000e+03</double>
<object class="NSTableHeaderCell" key="NSHeaderCell">

View File

@ -41,7 +41,7 @@
- (NSString *) nameForIndex: (int) index;
- (void) setName: (NSString *) name forIndex: (int) index;
- (NSImage *) imageForIndex: (int) index isSmall: (BOOL) small;
- (NSImage *) imageForIndex: (int) index;
- (NSColor *) colorForIndex: (int) index;
- (NSColor *) setColor: (NSColor *) color forIndex: (int) index;

View File

@ -27,13 +27,12 @@
#import "NSBezierPathAdditions.h"
#define ICON_WIDTH 16.0
#define ICON_WIDTH_SMALL 12.0
@interface GroupsController (Private)
- (void) saveGroups;
- (NSImage *) imageForGroup: (NSDictionary *) dict isSmall: (BOOL) small;
- (NSImage *) imageForGroup: (NSMutableDictionary *) dict;
@end
@ -143,10 +142,10 @@ GroupsController * fGroupsInstance = nil;
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
}
- (NSImage *) imageForIndex: (int) index isSmall: (BOOL) small
- (NSImage *) imageForIndex: (int) index
{
int orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [self imageForGroup: [fGroups objectAtIndex: orderIndex] isSmall: small] : nil;
return orderIndex != -1 ? [self imageForGroup: [fGroups objectAtIndex: orderIndex]] : nil;
}
- (NSColor *) colorForIndex: (int) index
@ -256,13 +255,14 @@ GroupsController * fGroupsInstance = nil;
[item release];
NSEnumerator * enumerator = [fGroups objectEnumerator];
NSDictionary * dict;
NSMutableDictionary * dict;
while ((dict = [enumerator nextObject]))
{
item = [[NSMenuItem alloc] initWithTitle: [dict objectForKey: @"Name"] action: action keyEquivalent: @""];
[item setTarget: target];
[item setImage: [self imageForGroup: dict isSmall: small]];
#warning factor in size
[item setImage: [self imageForGroup: dict]];
[item setTag: [[dict objectForKey: @"Index"] intValue]];
[menu addItem: item];
@ -281,10 +281,13 @@ GroupsController * fGroupsInstance = nil;
[[NSUserDefaults standardUserDefaults] setObject: [NSArchiver archivedDataWithRootObject: fGroups] forKey: @"Groups"];
}
- (NSImage *) imageForGroup: (NSDictionary *) dict isSmall: (BOOL) small
- (NSImage *) imageForGroup: (NSMutableDictionary *) dict
{
float width = small ? ICON_WIDTH_SMALL : ICON_WIDTH;
NSRect rect = NSMakeRect(0.0, 0.0, width, width);
NSImage * image;
if ((image = [dict objectForKey: @"Icon"]))
return image;
NSRect rect = NSMakeRect(0.0, 0.0, ICON_WIDTH, ICON_WIDTH);
NSBezierPath * bp = [NSBezierPath bezierPathWithRoundedRect: rect radius: 3.0];
NSImage * icon = [[NSImage alloc] initWithSize: rect.size];
@ -306,7 +309,10 @@ GroupsController * fGroupsInstance = nil;
[icon unlockFocus];
return [icon autorelease];
[dict setObject: icon forKey: @"Icon"];
[icon release];
return icon;
}
@end

View File

@ -88,7 +88,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
NSString * identifier = [tableColumn identifier];
if ([identifier isEqualToString: @"Color"])
return [groupsController imageForIndex: groupsIndex isSmall: NO];
return [groupsController imageForIndex: groupsIndex];
else
return [groupsController nameForIndex: groupsIndex];
}