From: Mitchell Livingston Date: Sat, 31 May 2008 03:11:59 +0000 (+0000) Subject: don't archive group images; update group images when colors change X-Git-Tag: 1.22~193 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d4618ef74d3051eaa48985d60dd850bff0030452;p=transmission don't archive group images; update group images when colors change --- diff --git a/macosx/GroupsController.m b/macosx/GroupsController.m index ff857586f..cb02c2603 100644 --- a/macosx/GroupsController.m +++ b/macosx/GroupsController.m @@ -157,7 +157,10 @@ GroupsController * fGroupsInstance = nil; - (NSColor *) setColor: (NSColor *) color forIndex: (int) index { - [[fGroups objectAtIndex: [self rowValueForIndex: index]] setObject: color forKey: @"Color"]; + NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]]; + [dict removeObjectForKey: @"Icon"]; + + [dict setObject: color forKey: @"Color"]; [[GroupsController groups] saveGroups]; [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self]; @@ -296,7 +299,19 @@ GroupsController * fGroupsInstance = nil; - (void) saveGroups { - [[NSUserDefaults standardUserDefaults] setObject: [NSArchiver archivedDataWithRootObject: fGroups] forKey: @"Groups"]; + //don't archive the icon + NSMutableArray * groups = [NSMutableArray arrayWithCapacity: [fGroups count]]; + NSEnumerator * enumerator = [fGroups objectEnumerator]; + NSDictionary * dict; + while ((dict = [enumerator nextObject])) + { + NSMutableDictionary * newDict = [dict mutableCopy]; + [newDict removeObjectForKey: @"Icon"]; + [groups addObject: newDict]; + [newDict release]; + } + + [[NSUserDefaults standardUserDefaults] setObject: [NSArchiver archivedDataWithRootObject: groups] forKey: @"Groups"]; } - (NSImage *) imageForGroup: (NSMutableDictionary *) dict