1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-02-22 14:10:34 +00:00

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_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_WARN_UNUSED_FUNCTION = NO; GCC_WARN_UNUSED_FUNCTION = NO;
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = NO; GCC_WARN_UNUSED_VARIABLE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.4; MACOSX_DEPLOYMENT_TARGET = 10.4;
OTHER_LDFLAGS = ""; OTHER_LDFLAGS = "";
@ -2461,6 +2462,7 @@
GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_WARN_UNUSED_FUNCTION = NO; GCC_WARN_UNUSED_FUNCTION = NO;
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VARIABLE = NO; GCC_WARN_UNUSED_VARIABLE = NO;
MACOSX_DEPLOYMENT_TARGET = 10.4; MACOSX_DEPLOYMENT_TARGET = 10.4;
OTHER_LDFLAGS = ""; OTHER_LDFLAGS = "";

View file

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

View file

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

View file

@ -41,7 +41,7 @@
- (NSString *) nameForIndex: (int) index; - (NSString *) nameForIndex: (int) index;
- (void) setName: (NSString *) name forIndex: (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 *) colorForIndex: (int) index;
- (NSColor *) setColor: (NSColor *) color forIndex: (int) index; - (NSColor *) setColor: (NSColor *) color forIndex: (int) index;

View file

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

View file

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