Changeset 2139


Ignore:
Timestamp:
Jun 17, 2007, 5:50:33 PM (15 years ago)
Author:
livings124
Message:

open newly created files when created

Location:
branches/file_selection/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/macosx/Controller.h

    r2100 r2139  
    105105
    106106- (void) openFiles:             (NSArray *) filenames;
    107 - (void) openFiles:             (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore forceDeleteTorrent: (BOOL) delete;
     107- (void) openFiles:             (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
     108                                            forceDeleteTorrent: (BOOL) delete;
     109- (void) openCreatedFile:       (NSNotification *) notification;
    108110- (void) openFilesWithDict:     (NSDictionary *) dictionary;
    109111- (void) openFilesAsk:          (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete;
  • branches/file_selection/macosx/Controller.m

    r2137 r2139  
    416416    [nc addObserver: self selector: @selector(updateDockBadge:)
    417417                    name: @"DockBadgeChange" object: nil];
     418   
     419    //open newly created torrent file
     420    [nc addObserver: self selector: @selector(openCreatedFile:)
     421                    name: @"OpenCreatedTorrentFile" object: nil];
    418422
    419423    //timer to update the interface every second
     
    634638    NSString * path = [[fPendingTorrentDownloads objectForKey: [[download request] URL]] objectForKey: @"Path"];
    635639   
    636     [self openFiles: [NSArray arrayWithObject: path] ignoreDownloadFolder:
     640    [self openFiles: [NSArray arrayWithObject: path] forcePath: nil ignoreDownloadFolder:
    637641        ![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Constant"] forceDeleteTorrent: YES];
    638642   
     
    646650- (void) application: (NSApplication *) app openFiles: (NSArray *) filenames
    647651{
    648     [self openFiles: filenames ignoreDownloadFolder: NO forceDeleteTorrent: NO];
    649 }
    650 
    651 - (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore forceDeleteTorrent: (BOOL) delete
     652    [self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     653}
     654
     655- (void) openFiles: (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
     656        forceDeleteTorrent: (BOOL) delete
    652657{
    653658    NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
    654     if (ignore || [downloadChoice isEqualToString: @"Ask"])
     659    if (ignore || (!path && [downloadChoice isEqualToString: @"Ask"]))
    655660    {
    656661        [self openFilesAsk: [filenames mutableCopy] forceDeleteTorrent: delete];
     
    658663    }
    659664   
    660     if ([fDefaults boolForKey: @"UseIncompleteDownloadFolder"]
     665    if (!path && [fDefaults boolForKey: @"UseIncompleteDownloadFolder"]
    661666        && access([[[fDefaults stringForKey: @"IncompleteDownloadFolder"] stringByExpandingTildeInPath] UTF8String], 0))
    662667    {
     
    682687        return;
    683688    }
    684     if ([downloadChoice isEqualToString: @"Constant"]
     689    if (!path && [downloadChoice isEqualToString: @"Constant"]
    685690        && access([[[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath] UTF8String], 0))
    686691    {
     
    713718        if (!(torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent: delete lib: fLib]))
    714719            continue;
    715 
     720       
    716721        //add it to the "File > Open Recent" menu
    717722        [[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
    718 
    719         NSString * folder = [downloadChoice isEqualToString: @"Constant"]
    720             ? [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath]
    721             : [torrentPath stringByDeletingLastPathComponent];
     723       
     724        NSString * folder;
     725        if (path)
     726            folder = path;
     727        else if ([downloadChoice isEqualToString: @"Constant"])
     728            folder = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
     729        else
     730            folder = [torrentPath stringByDeletingLastPathComponent];
    722731       
    723732        [torrent setDownloadFolder: folder];
     
    729738
    730739    [self updateTorrentsInQueue];
     740}
     741
     742- (void) openCreatedFile: (NSNotification *) notification
     743{
     744    NSDictionary * dict = [notification userInfo];
     745    [self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] forcePath: [dict objectForKey: @"Path"]
     746            ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     747    [dict release];
    731748}
    732749
     
    754771- (void) openFilesWithDict: (NSDictionary *) dictionary
    755772{
    756     [self openFiles: [dictionary objectForKey: @"Filenames"]
     773    [self openFiles: [dictionary objectForKey: @"Filenames"] forcePath: nil
    757774        ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue]
    758775        forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue]];
     
    844861- (void) openFiles: (NSArray *) filenames
    845862{
    846     [self openFiles: filenames ignoreDownloadFolder: NO forceDeleteTorrent: NO];
     863    [self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO forceDeleteTorrent: NO];
    847864}
    848865
     
    872889- (void) openFromSheet: (NSDictionary *) dictionary
    873890{
    874     [self openFiles: [dictionary objectForKey: @"Files"]
     891    [self openFiles: [dictionary objectForKey: @"Files"] forcePath: nil
    875892        ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue] forceDeleteTorrent: NO];
    876893   
  • branches/file_selection/macosx/CreatorWindowController.m

    r2137 r2139  
    260260        else
    261261        {
    262             #warning add to T
     262            #warning make optional
     263            NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: fLocation, @"File",
     264                                    [fPath stringByDeletingLastPathComponent], @"Path", nil];
     265            [[NSNotificationCenter defaultCenter] postNotificationName: @"OpenCreatedTorrentFile" object: self userInfo: dict];
    263266        }
    264267       
Note: See TracChangeset for help on using the changeset viewer.