Changeset 1093 for trunk/macosx


Ignore:
Timestamp:
Nov 16, 2006, 9:24:24 PM (15 years ago)
Author:
livings124
Message:

Choose a new volume for downloading if the current isn't available. I still need feedback on this.

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r1084 r1093  
    136136- (void) showPreferenceWindow: (id) sender;
    137137
     138- (void) makeWindowKey;
    138139- (void) showInfo: (id) sender;
    139140- (void) setInfoTab: (id) sender;
  • trunk/macosx/Controller.m

    r1089 r1093  
    310310    [nc addObserver: self selector: @selector(setWindowSizeToFit)
    311311                    name: @"AutoSizeSettingChange" object: nil];
     312   
     313    [nc addObserver: self selector: @selector(makeWindowKey)
     314                    name: @"MakeWindowKey" object: nil];
    312315   
    313316    //check to start another because of stopped torrent
     
    9971000}
    9981001
     1002- (void) makeWindowKey
     1003{
     1004    [fWindow makeKeyWindow];
     1005}
     1006
    9991007- (void) showInfo: (id) sender
    10001008{
  • trunk/macosx/Torrent.h

    r1092 r1093  
    9797
    9898- (BOOL) alertForRemainingDiskSpace;
    99 - (BOOL) alertForDriveAvailable;
     99- (BOOL) alertForVolumeAvailable;
    100100
    101101- (NSImage *)   icon;
  • trunk/macosx/Torrent.m

    r1092 r1093  
    179179- (void) setDownloadFolder: (NSString *) path
    180180{
    181     fDownloadFolder = [path copy];
     181    if (path)
     182        fDownloadFolder = [path copy];
    182183   
    183184    if (!fUseIncompleteFolder || [[NSFileManager defaultManager] fileExistsAtPath:
     
    414415    fFinishedSeeding = NO;
    415416   
    416     if (![self isActive] && [self alertForDriveAvailable] && [self alertForRemainingDiskSpace])
     417    if (![self isActive] && [self alertForVolumeAvailable] && [self alertForRemainingDiskSpace])
    417418        tr_torrentStart(fHandle);
    418419}
     
    553554}
    554555
    555 - (BOOL) alertForDriveAvailable
     556- (BOOL) alertForVolumeAvailable
    556557{
    557558    NSArray * pathComponents = [[self downloadFolder] pathComponents];
     
    576577                                            "Volume cannot be found alert -> message"), volumeName]];
    577578        [alert addButtonWithTitle: NSLocalizedString(@"OK", "Volume cannot be found alert -> button")];
    578         #warning should choose new directory
    579         [alert addButtonWithTitle: NSLocalizedString(@"Download Anyway", "Volume cannot be found alert -> button")];
     579        [alert addButtonWithTitle: [NSLocalizedString(@"Choose New Directory",
     580                                    "Volume cannot be found alert -> directory button") stringByAppendingEllipsis]];
    580581       
    581582        if ([alert runModal] == NSAlertFirstButtonReturn)
    582         {
    583583            [[NSNotificationCenter defaultCenter] postNotificationName: @"StoppedDownloading" object: self];
    584             return NO;
    585         }
    586584        else
    587             return YES;
     585        {
     586            NSOpenPanel * panel = [NSOpenPanel openPanel];
     587           
     588            [panel setPrompt: @"Select"];
     589            [panel setAllowsMultipleSelection: NO];
     590            [panel setCanChooseFiles: NO];
     591            [panel setCanChooseDirectories: YES];
     592
     593            [panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"",
     594                                "Open torrent -> select destination folder"), [self name]]];
     595           
     596            [[NSNotificationCenter defaultCenter] postNotificationName: @"MakeWindowKey" object: nil];
     597            [panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: [NSApp keyWindow] modalDelegate: self
     598                    didEndSelector: @selector(destinationChoiceClosed:returnCode:contextInfo:) contextInfo: nil];
     599        }
     600       
     601        return NO;
    588602    }
    589603   
    590604    return YES;
    591605}
     606
     607- (void) destinationChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) context
     608{
     609    NSString * folder = [[openPanel filenames] objectAtIndex: 0];
     610    NSLog(@"%@", folder);
     611    if (code == NSOKButton)
     612    {
     613        if (fUseIncompleteFolder)
     614        {
     615            [fIncompleteFolder release];
     616            fIncompleteFolder = [folder retain];
     617            [self setDownloadFolder: nil];
     618        }
     619        else
     620        {
     621            [fDownloadFolder release];
     622            fDownloadFolder = folder;
     623            [self setDownloadFolder: fDownloadFolder];
     624        }
     625       
     626        [self startTransfer];
     627        [self update];
     628    }
     629    else
     630        [[NSNotificationCenter defaultCenter] postNotificationName: @"StoppedDownloading" object: self];
     631}
     632
    592633
    593634- (NSImage *) icon
Note: See TracChangeset for help on using the changeset viewer.