]> granicus.if.org Git - transmission/commitdiff
#2680 "Group Name" cleared after choosing "Custom location"
authorMitchell Livingston <livings124@transmissionbt.com>
Wed, 16 Dec 2009 03:19:09 +0000 (03:19 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Wed, 16 Dec 2009 03:19:09 +0000 (03:19 +0000)
macosx/GroupsPrefsController.m

index 7b4e91653a15861afc5ea181246181ca48677d94..55f39d2e404c2bb93da127431cbf403300518d78 100644 (file)
@@ -35,6 +35,7 @@
 @interface GroupsPrefsController (Private)
 
 - (void) updateSelectedGroup;
+- (void) refreshCustomLocation;
 
 @end
 
         NSString * path = [[openPanel filenames] objectAtIndex: 0];
         [[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
         [[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
-        [self updateSelectedGroup]; //update the popup's icon/title
     }
     else
     {
         if (![[GroupsController groups] customDownloadLocationForIndex: index])
-        {
             [[GroupsController groups] setUsesCustomDownloadLocation: NO forIndex: index];
-            [fCustomLocationEnableCheck setState: NSOffState];
-            [fCustomLocationPopUp setEnabled: NO];
-        }
     }
-
+    
+    [self refreshCustomLocation];
+    
     [fCustomLocationPopUp selectItemAtIndex: 0];
 }
 
     [fAddRemoveControl setEnabled: [fTableView numberOfSelectedRows] > 0 forSegment: REMOVE_TAG];
     if ([fTableView numberOfSelectedRows] == 1)
     {
-        NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
+        const NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
         [fSelectedColorView setColor: [[GroupsController groups] colorForIndex: index]];
         [fSelectedColorView setEnabled: YES];
         [fSelectedColorNameField setStringValue: [[GroupsController groups] nameForIndex: index]];
         [fSelectedColorNameField setEnabled: YES];
-        [fCustomLocationEnableCheck setState: [[GroupsController groups] usesCustomDownloadLocationForIndex: index]];
-        [fCustomLocationEnableCheck setEnabled: YES];
-        [fCustomLocationPopUp setEnabled: [fCustomLocationEnableCheck state] == NSOnState];
-        if ([[GroupsController groups] customDownloadLocationForIndex: index])
-        {
-            NSString * location = [[GroupsController groups] customDownloadLocationForIndex: index];
-            ExpandedPathToPathTransformer * pathTransformer = [[[ExpandedPathToPathTransformer alloc] init] autorelease];
-            [[fCustomLocationPopUp itemAtIndex: 0] setTitle: [pathTransformer transformedValue: location]];
-            ExpandedPathToIconTransformer * iconTransformer = [[[ExpandedPathToIconTransformer alloc] init] autorelease];
-            [[fCustomLocationPopUp itemAtIndex: 0] setImage: [iconTransformer transformedValue: location]];
-        }
-        else
-        {
-            [[fCustomLocationPopUp itemAtIndex: 0] setTitle: @""];
-            [[fCustomLocationPopUp itemAtIndex: 0] setImage: nil];
-        }
+        
+        [self refreshCustomLocation];
 
         [fAutoAssignRulesEnableCheck setState: [[GroupsController groups] usesAutoAssignRulesForIndex: index]];
         [fAutoAssignRulesEnableCheck setEnabled: YES];
     }
 }
 
+- (void) refreshCustomLocation
+{
+    const NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
+    
+    [fCustomLocationEnableCheck setState: [[GroupsController groups] usesCustomDownloadLocationForIndex: index]];
+    [fCustomLocationEnableCheck setEnabled: YES];
+    [fCustomLocationPopUp setEnabled: [fCustomLocationEnableCheck state] == NSOnState];
+    
+    if ([[GroupsController groups] customDownloadLocationForIndex: index])
+    {
+        NSString * location = [[GroupsController groups] customDownloadLocationForIndex: index];
+        ExpandedPathToPathTransformer * pathTransformer = [[[ExpandedPathToPathTransformer alloc] init] autorelease];
+        [[fCustomLocationPopUp itemAtIndex: 0] setTitle: [pathTransformer transformedValue: location]];
+        ExpandedPathToIconTransformer * iconTransformer = [[[ExpandedPathToIconTransformer alloc] init] autorelease];
+        [[fCustomLocationPopUp itemAtIndex: 0] setImage: [iconTransformer transformedValue: location]];
+    }
+    else
+    {
+        [[fCustomLocationPopUp itemAtIndex: 0] setTitle: @""];
+        [[fCustomLocationPopUp itemAtIndex: 0] setImage: nil];
+    }
+}
+
 @end