]> granicus.if.org Git - transmission/commitdiff
some small simplifications to the group code
authorMitchell Livingston <livings124@transmissionbt.com>
Thu, 5 Jun 2008 02:46:39 +0000 (02:46 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Thu, 5 Jun 2008 02:46:39 +0000 (02:46 +0000)
macosx/Controller.m
macosx/English.lproj/Localizable.strings
macosx/GroupsController.m

index ec235695c5bc4cd516a59c15aaf2694cb662801b..7305fb04162a4c1d763c5df58a9f2a8feab74994 100644 (file)
@@ -2265,21 +2265,17 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
     
     NSImage * icon;
     NSString * toolTip;
-    switch (groupIndex)
+    if (groupIndex == GROUP_FILTER_ALL_TAG)
     {
-        case GROUP_FILTER_ALL_TAG:
-            icon = [NSImage imageNamed: @"PinTemplate.png"];
-            toolTip = NSLocalizedString(@"All Groups", "Groups -> Button");
-            break;
-        case -1:
-            icon = [NSImage imageNamed: @"GroupsNoneTemplate.png"];
-            toolTip = [NSString stringWithFormat: @"%@: %@", NSLocalizedString(@"Group", "Groups -> Button"),
-                        NSLocalizedString(@"No Label", "Groups -> Button")];
-            break;
-        default:
-            icon = [[GroupsController groups] imageForIndex: groupIndex];
-            toolTip = [NSString stringWithFormat: @"%@: %@", NSLocalizedString(@"Group", "Groups -> Button"),
-                        [[GroupsController groups] nameForIndex: groupIndex]];
+        icon = [NSImage imageNamed: @"PinTemplate.png"];
+        toolTip = NSLocalizedString(@"All Groups", "Groups -> Button");
+    }
+    else
+    {
+        icon = [[GroupsController groups] imageForIndex: groupIndex];
+        NSString * groupName = groupIndex != -1 ? [[GroupsController groups] nameForIndex: groupIndex]
+                                                : NSLocalizedString(@"None", "Groups -> Button");
+        toolTip = [NSString stringWithFormat: @"%@: %@", NSLocalizedString(@"Group", "Groups -> Button"), groupName];
     }
     
     //tiger doesn't have built-in image scaling in buttons
@@ -2542,7 +2538,9 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
 
 - (id) outlineView: (NSOutlineView *) outlineView objectValueForTableColumn: (NSTableColumn *) tableColumn byItem: (id) item
 {
-    if (![item isKindOfClass: [Torrent class]])
+    if ([item isKindOfClass: [Torrent class]])
+        return [item hashString];
+    else
     {
         NSString * ident = [tableColumn identifier];
         if ([ident isEqualToString: @"Group"])
@@ -2554,8 +2552,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]
-                                : [NSImage imageNamed: @"GroupsNoneTemplate.png"];
+            return [[GroupsController groups] imageForIndex: group];
         }
         else if ([ident isEqualToString: @"DL Image"])
             return [NSImage imageNamed: @"DownArrowGroupTemplate.png"];
@@ -2591,8 +2588,6 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
             }
         }
     }
-    else
-        return [item hashString];
 }
 
 - (BOOL) outlineView: (NSOutlineView *) outlineView writeItems: (NSArray *) items toPasteboard: (NSPasteboard *) pasteboard
index 8ecaba2d342bf1498187f1a27c7c4d95290a2cd3..aba7d29887df804070d16912be73c8b73a02bb51 100644 (file)
Binary files a/macosx/English.lproj/Localizable.strings and b/macosx/English.lproj/Localizable.strings differ
index cbf7e5369acd9ed55dac8c81343030e1ac85502f..c7b485ab9aa036c9fffba073a812fa9abd5b4e86 100644 (file)
@@ -146,7 +146,8 @@ GroupsController * fGroupsInstance = nil;
 - (NSImage *) imageForIndex: (int) index
 {
     int orderIndex = [self rowValueForIndex: index];
-    return orderIndex != -1 ? [self imageForGroup: [fGroups objectAtIndex: orderIndex]] : nil;
+    return orderIndex != -1 ? [self imageForGroup: [fGroups objectAtIndex: orderIndex]]
+                            : [NSImage imageNamed: @"GroupsNoneTemplate.png"];
 }
 
 - (NSColor *) colorForIndex: (int) index