Changeset 716


Ignore:
Timestamp:
Aug 2, 2006, 12:04:04 AM (15 years ago)
Author:
livings124
Message:

Holding down option and using the open menu item now ignores the default download location and asks where to download.

Location:
trunk/macosx
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r714 r716  
    5454    NSToolbar                       * fToolbar;
    5555   
     56    IBOutlet NSMenuItem             * fOpenIgnoreDownloadFolder;
     57   
    5658    IBOutlet NSMenuItem             * fAdvancedBarItem, * fSmallViewItem,
    5759                                    * fSpeedLimitItem, * fSpeedLimitDockItem;
     
    9294}
    9395
    94 - (void) openShowSheet:   (id) sender;
    95 - (void) openSheetClosed: (NSOpenPanel *) s returnCode: (int) code contextInfo: (void *) info;
     96- (void) openFiles: (NSArray *) filenames;
     97- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore;
     98- (void) openShowSheet: (id) sender;
    9699
    97100- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;
  • trunk/macosx/Controller.m

    r715 r716  
    431431}
    432432
     433- (NSArray *) torrentsAtIndexes: (NSIndexSet *) indexSet
     434{
     435    if ([fFilteredTorrents respondsToSelector: @selector(objectsAtIndexes:)])
     436        return [fFilteredTorrents objectsAtIndexes: indexSet];
     437    else
     438    {
     439        NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [indexSet count]];
     440        unsigned int i;
     441        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
     442            [torrents addObject: [fFilteredTorrents objectAtIndex: i]];
     443
     444        return torrents;
     445    }
     446}
     447
    433448- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
    434449    contextInfo: (Torrent *) torrent
     
    447462
    448463- (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
     464{
     465    [self openFiles: filenames ignoreDownloadFolder: NO];
     466}
     467
     468- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore
    449469{
    450470    NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"], * torrentPath;
     
    460480            noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
    461481
    462         if ([downloadChoice isEqualToString: @"Ask"])
     482        if (ignore || [downloadChoice isEqualToString: @"Ask"])
    463483        {
    464484            NSOpenPanel * panel = [NSOpenPanel openPanel];
     
    499519}
    500520
    501 - (NSArray *) torrentsAtIndexes: (NSIndexSet *) indexSet
    502 {
    503     if ([fFilteredTorrents respondsToSelector: @selector(objectsAtIndexes:)])
    504         return [fFilteredTorrents objectsAtIndexes: indexSet];
    505     else
    506     {
    507         NSMutableArray * torrents = [NSMutableArray arrayWithCapacity: [indexSet count]];
    508         unsigned int i;
    509         for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    510             [torrents addObject: [fFilteredTorrents objectAtIndex: i]];
    511 
    512         return torrents;
    513     }
    514 }
    515 
    516521//called on by applescript
    517522- (void) open: (NSArray *) files
    518523{
    519     [self performSelectorOnMainThread: @selector(openFromSheet:) withObject: files waitUntilDone: NO];
     524    [self performSelectorOnMainThread: @selector(openFiles:) withObject: files waitUntilDone: NO];
     525}
     526
     527- (void) openFiles: (NSArray *) filenames
     528{
     529    [self openFiles: filenames ignoreDownloadFolder: NO];
    520530}
    521531
     
    530540    [panel beginSheetForDirectory: nil file: nil types: [NSArray arrayWithObject: @"torrent"]
    531541        modalForWindow: fWindow modalDelegate: self didEndSelector:
    532         @selector(openSheetClosed:returnCode:contextInfo:) contextInfo: nil];
    533 }
    534 
    535 - (void) openSheetClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (void *) info
     542        @selector(openSheetClosed:returnCode:contextInfo:)
     543        contextInfo: [NSNumber numberWithBool: sender == fOpenIgnoreDownloadFolder]];
     544}
     545
     546- (void) openSheetClosed: (NSOpenPanel *) panel returnCode: (int) code contextInfo: (NSNumber *) ignore
    536547{
    537548    if (code == NSOKButton)
    538         [self performSelectorOnMainThread: @selector(openFromSheet:) withObject: [panel filenames] waitUntilDone: NO];
    539 }
    540 
    541 - (void) openFromSheet: (NSArray *) filenames
    542 {
    543     [self application: NSApp openFiles: filenames];
     549    {
     550        NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys:
     551                                        [panel filenames], @"Files", ignore, @"Ignore", nil];
     552        [self performSelectorOnMainThread: @selector(openFromSheet:) withObject: dictionary waitUntilDone: NO];
     553    }
     554}
     555
     556- (void) openFromSheet: (NSDictionary *) dictionary
     557{
     558    [self openFiles: [dictionary objectForKey: @"Files"]
     559        ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue]];
     560   
     561    [dictionary release];
    544562}
    545563
     
    14311449        {
    14321450            oldCount = [fTorrents count];
    1433             [self openFromSheet: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]];
     1451            [self openFiles: [NSArray arrayWithObject: [path stringByAppendingPathComponent: file]]];
    14341452           
    14351453            //import only actually happened if the torrent array is larger
  • trunk/macosx/English.lproj/MainMenu.nib/classes.nib

    r714 r716  
    5252                fNextInfoTabItem = NSMenuItem;
    5353                fNoFilterButton = BarButton;
     54                fOpenIgnoreDownloadFolder = NSMenuItem;
    5455                fOrderSortActionItem = NSMenuItem;
    5556                fOrderSortItem = NSMenuItem;
  • trunk/macosx/English.lproj/MainMenu.nib/info.nib

    r714 r716  
    1414                <string>337 545 477 67 0 0 1152 842 </string>
    1515                <key>29</key>
    16                 <string>207 725 451 44 0 0 1152 842 </string>
     16                <string>227 675 451 44 0 0 1152 842 </string>
    1717                <key>456</key>
    1818                <string>396 374 216 206 0 0 1152 842 </string>
Note: See TracChangeset for help on using the changeset viewer.