Changeset 13108


Ignore:
Timestamp:
Dec 11, 2011, 10:31:01 PM (10 years ago)
Author:
livings124
Message:

eliminate all warnings by switching NSOpenPanel/NSSavePanels to use completion handler blocks

Location:
trunk/macosx
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/AddMagnetWindowController.m

    r12943 r13108  
    4040- (void) setDestinationPath: (NSString *) destination;
    4141
    42 - (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) contextInfo;
    43 
    4442- (void) setGroupsMenu;
    4543- (void) changeGroupValue: (id) sender;
     
    133131                        "Add -> select destination folder"), [fTorrent name]]];
    134132   
    135     [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: [self window] modalDelegate: self
    136             didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: nil];
     133    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     134        if (result == NSFileHandlingPanelOKButton)
     135            [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path]];
     136        else
     137        {
     138            if (!fDestination)
     139                [self performSelectorOnMainThread: @selector(cancelAdd:) withObject: nil waitUntilDone: NO];
     140        }
     141    }];
    137142}
    138143
     
    228233}
    229234
    230 - (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) contextInfo
    231 {
    232     if (code == NSOKButton)
    233         [self setDestinationPath: [[[openPanel URLs] objectAtIndex: 0] path]];
    234     else
    235     {
    236         if (!fDestination)
    237             [self performSelectorOnMainThread: @selector(cancelAdd:) withObject: nil waitUntilDone: NO];
    238     }
    239 }
    240 
    241235- (void) setGroupsMenu
    242236{
  • trunk/macosx/AddWindowController.m

    r12943 r13108  
    4545- (void) setDestinationPath: (NSString *) destination;
    4646
    47 - (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) contextInfo;
    48 
    4947- (void) setGroupsMenu;
    5048- (void) changeGroupValue: (id) sender;
     
    167165                        "Add -> select destination folder"), [fTorrent name]]];
    168166   
    169     [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: [self window] modalDelegate: self
    170             didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: nil];
     167    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     168        if (result == NSFileHandlingPanelOKButton)
     169        {
     170            fLockDestination = NO;
     171            [self setDestinationPath: [[[panel URLs] objectAtIndex: 0] path]];
     172        }
     173        else
     174        {
     175            if (!fDestination)
     176                [self performSelectorOnMainThread: @selector(cancelAdd:) withObject: nil waitUntilDone: NO];
     177        }
     178    }];
    171179}
    172180
     
    323331}
    324332
    325 - (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) contextInfo
    326 {
    327     if (code == NSOKButton)
    328     {
    329         fLockDestination = NO;
    330         [self setDestinationPath: [[[openPanel URLs] objectAtIndex: 0] path]];
    331     }
    332     else
    333     {
    334         if (!fDestination)
    335             [self performSelectorOnMainThread: @selector(cancelAdd:) withObject: nil waitUntilDone: NO];
    336     }
    337 }
    338 
    339333- (void) setGroupsMenu
    340334{
  • trunk/macosx/Controller.h

    r13004 r13108  
    153153- (void) moveDataFilesSelected: (id) sender;
    154154- (void) moveDataFiles: (NSArray *) torrents;
    155 - (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (NSInteger) code contextInfo: (NSArray *) torrents;
    156155
    157156- (void) copyTorrentFiles: (id) sender;
  • trunk/macosx/Controller.m

    r13096 r13108  
    10041004{
    10051005    NSOpenPanel * panel = [NSOpenPanel openPanel];
    1006 
     1006   
    10071007    [panel setAllowsMultipleSelection: YES];
    10081008    [panel setCanChooseFiles: YES];
    10091009    [panel setCanChooseDirectories: NO];
    1010 
    1011     [panel beginSheetForDirectory: nil file: nil types: [NSArray arrayWithObjects: @"org.bittorrent.torrent", @"torrent", nil]
    1012         modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(openSheetClosed:returnCode:contextInfo:)
    1013         contextInfo: [NSNumber numberWithBool: sender == fOpenIgnoreDownloadFolder]];
    1014 }
    1015 
    1016 - (void) openSheetClosed: (NSOpenPanel *) panel returnCode: (NSInteger) code contextInfo: (NSNumber *) useOptions
    1017 {
    1018     if (code == NSOKButton)
    1019     {
    1020         NSMutableArray * filenames = [NSMutableArray arrayWithCapacity: [[panel URLs] count]];
    1021         for (NSURL * url in [panel URLs])
    1022             [filenames addObject: [url path]];
    1023        
    1024         NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: filenames, @"Filenames",
    1025             [NSNumber numberWithInt: [useOptions boolValue] ? ADD_SHOW_OPTIONS : ADD_MANUAL], @"AddType", nil];
    1026         [self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dictionary waitUntilDone: NO];
    1027     }
     1010   
     1011    [panel setAllowedFileTypes: [NSArray arrayWithObjects: @"org.bittorrent.torrent", @"torrent", nil]];
     1012   
     1013    [panel beginSheetModalForWindow: fWindow completionHandler: ^(NSInteger result) {
     1014        if (result == NSFileHandlingPanelOKButton)
     1015        {
     1016            NSMutableArray * filenames = [NSMutableArray arrayWithCapacity: [[panel URLs] count]];
     1017            for (NSURL * url in [panel URLs])
     1018                [filenames addObject: [url path]];
     1019           
     1020            NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: filenames, @"Filenames",
     1021                                         [NSNumber numberWithInt: sender == fOpenIgnoreDownloadFolder ? ADD_SHOW_OPTIONS : ADD_MANUAL], @"AddType", nil];
     1022            [self performSelectorOnMainThread: @selector(openFilesWithDict:) withObject: dictionary waitUntilDone: NO];
     1023        }
     1024    }];
    10281025}
    10291026
     
    14321429    [panel setCanCreateDirectories: YES];
    14331430   
    1434     torrents = [torrents retain];
    14351431    NSInteger count = [torrents count];
    14361432    if (count == 1)
     
    14401436        [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for %d data files.",
    14411437                            "Move torrent -> select destination folder"), count]];
    1442        
    1443     [panel beginSheetForDirectory: nil file: nil modalForWindow: fWindow modalDelegate: self
    1444         didEndSelector: @selector(moveDataFileChoiceClosed:returnCode:contextInfo:) contextInfo: torrents];
    1445 }
    1446 
    1447 - (void) moveDataFileChoiceClosed: (NSOpenPanel *) panel returnCode: (NSInteger) code contextInfo: (NSArray *) torrents
    1448 {
    1449     if (code == NSOKButton)
    1450     {
    1451         for (Torrent * torrent in torrents)
    1452             [torrent moveTorrentDataFileTo: [[[panel URLs] objectAtIndex: 0] path]];
    1453     }
    1454    
    1455     [torrents release];
     1438   
     1439    [panel beginSheetModalForWindow: fWindow completionHandler: ^(NSInteger result) {
     1440        if (result == NSFileHandlingPanelOKButton)
     1441        {
     1442            for (Torrent * torrent in torrents)
     1443                [torrent moveTorrentDataFileTo: [[[panel URLs] objectAtIndex: 0] path]];
     1444        }
     1445    }];
    14561446}
    14571447
     
    14771467        [panel setExtensionHidden: NO];
    14781468       
    1479         [panel beginSheetForDirectory: nil file: [torrent name] modalForWindow: fWindow modalDelegate: self
    1480             didEndSelector: @selector(saveTorrentCopySheetClosed:returnCode:contextInfo:) contextInfo: torrents];
     1469        [panel setNameFieldStringValue: [torrent name]];
     1470       
     1471        [panel beginSheetModalForWindow: fWindow completionHandler: ^(NSInteger result) {
     1472            //copy torrent to new location with name of data file
     1473            if (result == NSFileHandlingPanelOKButton)
     1474                [torrent copyTorrentFileTo: [[panel URL] path]];
     1475           
     1476            [torrents removeObjectAtIndex: 0];
     1477            [self performSelectorOnMainThread: @selector(copyTorrentFileForTorrents:) withObject: torrents waitUntilDone: NO];
     1478        }];
    14811479    }
    14821480    else
     
    15001498        [self copyTorrentFileForTorrents: torrents];
    15011499    }
    1502 }
    1503 
    1504 - (void) saveTorrentCopySheetClosed: (NSSavePanel *) panel returnCode: (NSInteger) code contextInfo: (NSMutableArray *) torrents
    1505 {
    1506     //copy torrent to new location with name of data file
    1507     if (code == NSOKButton)
    1508         [[torrents objectAtIndex: 0] copyTorrentFileTo: [[panel URL] path]];
    1509    
    1510     [torrents removeObjectAtIndex: 0];
    1511     [self performSelectorOnMainThread: @selector(copyTorrentFileForTorrents:) withObject: torrents waitUntilDone: NO];
    15121500}
    15131501
  • trunk/macosx/CreatorWindowController.m

    r13094 r13108  
    3535
    3636+ (NSString *) chooseFile;
    37 - (void) locationSheetClosed: (NSSavePanel *) openPanel returnCode: (NSInteger) code contextInfo: (void *) info;
    3837
    3938- (void) createBlankAddressAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
     
    210209    [panel setCanSelectHiddenExtension: YES];
    211210   
    212     [panel beginSheetForDirectory: [fLocation stringByDeletingLastPathComponent] file: [fLocation lastPathComponent]
    213             modalForWindow: [self window] modalDelegate: self didEndSelector: @selector(locationSheetClosed:returnCode:contextInfo:)
    214             contextInfo: nil];
     211    [panel setDirectoryURL: [NSURL fileURLWithPath: [fLocation stringByDeletingLastPathComponent]]];
     212    [panel setNameFieldStringValue: [fLocation lastPathComponent]];
     213   
     214    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     215        if (result == NSFileHandlingPanelOKButton)
     216        {
     217            [fLocation release];
     218            fLocation = [[[panel URL] path] retain];
     219           
     220            [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
     221            [fLocationField setToolTip: fLocation];
     222        }
     223    }];
    215224}
    216225
     
    406415    BOOL success = [panel runModal] == NSOKButton;
    407416    return success ? [[[panel URLs] objectAtIndex: 0] path] : nil;
    408 }
    409 
    410 - (void) locationSheetClosed: (NSSavePanel *) panel returnCode: (NSInteger) code contextInfo: (void *) info
    411 {
    412     if (code == NSOKButton)
    413     {
    414         [fLocation release];
    415         fLocation = [[[panel URL] path] retain];
    416        
    417         [fLocationField setStringValue: [fLocation stringByAbbreviatingWithTildeInPath]];
    418         [fLocationField setToolTip: fLocation];
    419     }
    420417}
    421418
  • trunk/macosx/GroupsPrefsController.m

    r12943 r13108  
    195195    [panel setCanChooseDirectories: YES];
    196196    [panel setCanCreateDirectories: YES];
    197 
    198     [panel beginSheetForDirectory: nil file: nil types: nil
    199         modalForWindow: [fCustomLocationPopUp window] modalDelegate: self didEndSelector:
    200         @selector(customDownloadLocationSheetClosed:returnCode:contextInfo:) contextInfo: nil];
     197   
     198    [panel beginSheetModalForWindow: [fCustomLocationPopUp window] completionHandler: ^(NSInteger result) {
     199        const NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
     200        if (result == NSFileHandlingPanelOKButton)
     201        {
     202            NSString * path = [[[panel URLs] objectAtIndex: 0] path];
     203            [[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
     204            [[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
     205        }
     206        else
     207        {
     208            if (![[GroupsController groups] customDownloadLocationForIndex: index])
     209                [[GroupsController groups] setUsesCustomDownloadLocation: NO forIndex: index];
     210        }
     211       
     212        [self refreshCustomLocationWithSingleGroup];
     213       
     214        [fCustomLocationPopUp selectItemAtIndex: 0];
     215    }];
    201216}
    202217
     
    215230
    216231    [fCustomLocationPopUp setEnabled: ([fCustomLocationEnableCheck state] == NSOnState)];
    217 }
    218 
    219 - (void) customDownloadLocationSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
    220 {
    221     NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
    222     if (code == NSOKButton)
    223     {
    224         NSString * path = [[[openPanel URLs] objectAtIndex: 0] path];
    225         [[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
    226         [[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
    227     }
    228     else
    229     {
    230         if (![[GroupsController groups] customDownloadLocationForIndex: index])
    231             [[GroupsController groups] setUsesCustomDownloadLocation: NO forIndex: index];
    232     }
    233    
    234     [self refreshCustomLocationWithSingleGroup];
    235    
    236     [fCustomLocationPopUp selectItemAtIndex: 0];
    237232}
    238233
  • trunk/macosx/MessageWindowController.m

    r12943 r13108  
    379379- (void) writeToFile: (id) sender
    380380{
    381     //make the array sorted by date
    382     NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey: @"Index" ascending: YES];
    383     NSArray * descriptors = [[NSArray alloc] initWithObjects: descriptor, nil];
    384     NSArray * sortedMessages = [[fDisplayedMessages sortedArrayUsingDescriptors: descriptors] retain];
    385     [descriptors release];
    386    
    387381    NSSavePanel * panel = [NSSavePanel savePanel];
    388382    [panel setAllowedFileTypes: [NSArray arrayWithObject: @"txt"]];
    389383    [panel setCanSelectHiddenExtension: YES];
    390384   
    391     [panel beginSheetForDirectory: nil file: NSLocalizedString(@"untitled", "Save log panel -> default file name")
    392             modalForWindow: [self window] modalDelegate: self
    393             didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: sortedMessages];
    394 }
    395 
    396 - (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (NSInteger) code contextInfo: (NSArray *) messages
    397 {
    398     if (code == NSOKButton)
    399     {
    400         //create the text to output
    401         NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [messages count]];
    402         for (NSDictionary * message in messages)
    403             [messageStrings addObject: [self stringForMessage: message]];
    404    
    405         NSString * fileString = [messageStrings componentsJoinedByString: @"\n"];
    406        
    407         if (![fileString writeToFile: [[panel URL] path] atomically: YES encoding: NSUTF8StringEncoding error: nil])
     385    [panel setNameFieldStringValue: NSLocalizedString(@"untitled", "Save log panel -> default file name")];
     386   
     387    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     388        if (result == NSFileHandlingPanelOKButton)
    408389        {
    409             NSAlert * alert = [[NSAlert alloc] init];
    410             [alert addButtonWithTitle: NSLocalizedString(@"OK", "Save log alert panel -> button")];
    411             [alert setMessageText: NSLocalizedString(@"Log Could Not Be Saved", "Save log alert panel -> title")];
    412             [alert setInformativeText: [NSString stringWithFormat:
    413                     NSLocalizedString(@"There was a problem creating the file \"%@\".",
    414                     "Save log alert panel -> message"), [[[panel URL] path] lastPathComponent]]];
    415             [alert setAlertStyle: NSWarningAlertStyle];
     390            //make the array sorted by date
     391            NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey: @"Index" ascending: YES];
     392            NSArray * descriptors = [[NSArray alloc] initWithObjects: descriptor, nil];
     393            NSArray * sortedMessages = [fDisplayedMessages sortedArrayUsingDescriptors: descriptors];
     394            [descriptors release];
    416395           
    417             [alert runModal];
    418             [alert release];
     396            //create the text to output
     397            NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [sortedMessages count]];
     398            for (NSDictionary * message in sortedMessages)
     399                [messageStrings addObject: [self stringForMessage: message]];
     400           
     401            NSString * fileString = [messageStrings componentsJoinedByString: @"\n"];
     402           
     403            if (![fileString writeToFile: [[panel URL] path] atomically: YES encoding: NSUTF8StringEncoding error: nil])
     404            {
     405                NSAlert * alert = [[NSAlert alloc] init];
     406                [alert addButtonWithTitle: NSLocalizedString(@"OK", "Save log alert panel -> button")];
     407                [alert setMessageText: NSLocalizedString(@"Log Could Not Be Saved", "Save log alert panel -> title")];
     408                [alert setInformativeText: [NSString stringWithFormat:
     409                                            NSLocalizedString(@"There was a problem creating the file \"%@\".",
     410                                                              "Save log alert panel -> message"), [[[panel URL] path] lastPathComponent]]];
     411                [alert setAlertStyle: NSWarningAlertStyle];
     412               
     413                [alert runModal];
     414                [alert release];
     415            }
    419416        }
    420     }
    421    
    422     [messages release];
     417    }];
    423418}
    424419
  • trunk/macosx/PrefsController.m

    r13103 r13108  
    6060- (void) setPrefView: (id) sender;
    6161
    62 - (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
    63 - (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
    64 - (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
    65 - (void) doneScriptSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
    66 
    6762- (void) setKeychainPassword: (const char *) password forService: (const char *) service username: (const char *) username;
    6863
     
    816811    [panel setCanChooseDirectories: YES];
    817812    [panel setCanCreateDirectories: YES];
    818 
    819     [panel beginSheetForDirectory: nil file: nil types: nil
    820         modalForWindow: [self window] modalDelegate: self didEndSelector:
    821         @selector(folderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
     813   
     814    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     815        if (result == NSFileHandlingPanelOKButton)
     816        {
     817            [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
     818           
     819            NSString * folder = [[[panel URLs] objectAtIndex: 0] path];
     820            [fDefaults setObject: folder forKey: @"DownloadFolder"];
     821            [fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
     822           
     823            tr_sessionSetDownloadDir(fHandle, [folder UTF8String]);
     824        }
     825        else
     826        {
     827            //reset if cancelled
     828            [fFolderPopUp selectItemAtIndex: [fDefaults boolForKey: @"DownloadLocationConstant"] ? DOWNLOAD_FOLDER : DOWNLOAD_TORRENT];
     829        }
     830    }];
    822831}
    823832
     
    831840    [panel setCanChooseDirectories: YES];
    832841    [panel setCanCreateDirectories: YES];
    833 
    834     [panel beginSheetForDirectory: nil file: nil types: nil
    835         modalForWindow: [self window] modalDelegate: self didEndSelector:
    836         @selector(incompleteFolderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
     842   
     843    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     844        if (result == NSFileHandlingPanelOKButton)
     845        {
     846            NSString * folder = [[[panel URLs] objectAtIndex: 0] path];
     847            [fDefaults setObject: folder forKey: @"IncompleteDownloadFolder"];
     848           
     849            tr_sessionSetIncompleteDir(fHandle, [folder UTF8String]);
     850        }
     851        [fIncompleteFolderPopUp selectItemAtIndex: 0];
     852    }];
    837853}
    838854
     
    847863    [panel setCanCreateDirectories: NO];
    848864   
    849     [panel beginSheetForDirectory: nil file: nil types: nil
    850                    modalForWindow: [self window] modalDelegate: self didEndSelector:
    851      @selector(doneScriptSheetClosed:returnCode:contextInfo:) contextInfo: nil];
     865    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     866        if (result == NSFileHandlingPanelOKButton)
     867        {
     868            NSString * filePath = [[[panel URLs] objectAtIndex: 0] path];
     869           
     870            [fDefaults setObject: filePath forKey: @"DoneScriptPath"];
     871            tr_sessionSetTorrentDoneScript(fHandle, [filePath UTF8String]);
     872           
     873            [fDefaults setBool: YES forKey: @"DoneScriptEnabled"];
     874            tr_sessionSetTorrentDoneScriptEnabled(fHandle, YES);
     875        }
     876        [fDoneScriptPopUp selectItemAtIndex: 0];
     877    }];
    852878}
    853879
     
    900926    [panel setCanCreateDirectories: YES];
    901927
    902     [panel beginSheetForDirectory: nil file: nil types: nil
    903         modalForWindow: [self window] modalDelegate: self didEndSelector:
    904         @selector(importFolderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
     928    [panel beginSheetModalForWindow: [self window] completionHandler: ^(NSInteger result) {
     929        NSString * path = [fDefaults stringForKey: @"AutoImportDirectory"];
     930        if (result == NSFileHandlingPanelOKButton)
     931        {
     932            UKKQueue * sharedQueue = [UKKQueue sharedFileWatcher];
     933            if (path)
     934                [sharedQueue removePathFromQueue: [path stringByExpandingTildeInPath]];
     935           
     936            path = [[[panel URLs] objectAtIndex: 0] path];
     937            [fDefaults setObject: path forKey: @"AutoImportDirectory"];
     938            [sharedQueue addPath: [path stringByExpandingTildeInPath]];
     939           
     940            [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
     941        }
     942        else if (!path)
     943            [fDefaults setBool: NO forKey: @"AutoImport"];
     944       
     945        [fImportFolderPopUp selectItemAtIndex: 0];
     946    }];
    905947}
    906948
     
    13931435}
    13941436
    1395 - (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
    1396 {
    1397     if (code == NSOKButton)
    1398     {
    1399         [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
    1400        
    1401         NSString * folder = [[[openPanel URLs] objectAtIndex: 0] path];
    1402         [fDefaults setObject: folder forKey: @"DownloadFolder"];
    1403         [fDefaults setObject: @"Constant" forKey: @"DownloadChoice"];
    1404        
    1405         tr_sessionSetDownloadDir(fHandle, [folder UTF8String]);
    1406     }
    1407     else
    1408     {
    1409         //reset if cancelled
    1410         [fFolderPopUp selectItemAtIndex: [fDefaults boolForKey: @"DownloadLocationConstant"] ? DOWNLOAD_FOLDER : DOWNLOAD_TORRENT];
    1411     }
    1412 }
    1413 
    1414 - (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
    1415 {
    1416     if (code == NSOKButton)
    1417     {
    1418         NSString * folder = [[[openPanel URLs] objectAtIndex: 0] path];
    1419         [fDefaults setObject: folder forKey: @"IncompleteDownloadFolder"];
    1420        
    1421         tr_sessionSetIncompleteDir(fHandle, [folder UTF8String]);
    1422     }
    1423     [fIncompleteFolderPopUp selectItemAtIndex: 0];
    1424 }
    1425 
    1426 - (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
    1427 {
    1428     NSString * path = [fDefaults stringForKey: @"AutoImportDirectory"];
    1429     if (code == NSOKButton)
    1430     {
    1431         UKKQueue * sharedQueue = [UKKQueue sharedFileWatcher];
    1432         if (path)
    1433             [sharedQueue removePathFromQueue: [path stringByExpandingTildeInPath]];
    1434        
    1435         path = [[[openPanel URLs] objectAtIndex: 0] path];
    1436         [fDefaults setObject: path forKey: @"AutoImportDirectory"];
    1437         [sharedQueue addPath: [path stringByExpandingTildeInPath]];
    1438        
    1439         [[NSNotificationCenter defaultCenter] postNotificationName: @"AutoImportSettingChange" object: self];
    1440     }
    1441     else if (!path)
    1442         [fDefaults setBool: NO forKey: @"AutoImport"];
    1443    
    1444     [fImportFolderPopUp selectItemAtIndex: 0];
    1445 }
    1446 
    1447 - (void) doneScriptSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
    1448 {
    1449     if (code == NSOKButton)
    1450     {
    1451         NSString * filePath = [[[openPanel URLs] objectAtIndex: 0] path];
    1452        
    1453         if ([[NSFileManager defaultManager] fileExistsAtPath: filePath])  // script file exists
    1454         {
    1455             [fDefaults setObject: filePath forKey: @"DoneScriptPath"];
    1456             [fDefaults setBool: YES forKey: @"DoneScriptEnabled"];
    1457         }
    1458         else // script file doesn't exist so don't enable
    1459         {
    1460             [fDefaults setObject: nil forKey:@"DoneScriptPath"];
    1461             [fDefaults setBool: NO forKey: @"DoneScriptEnabled"];
    1462         }
    1463         tr_sessionSetTorrentDoneScript(fHandle, [[fDefaults stringForKey:@"DoneScriptPath"] UTF8String]);
    1464         tr_sessionSetTorrentDoneScriptEnabled(fHandle, [fDefaults boolForKey:@"DoneScriptEnabled"]);
    1465     }
    1466     [fDoneScriptPopUp selectItemAtIndex: 0];
    1467 }
    1468 
    14691437- (void) setKeychainPassword: (const char *) password forService: (const char *) service username: (const char *) username
    14701438{
Note: See TracChangeset for help on using the changeset viewer.