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

when dragging a non-torrent file onto the window, display an overlay to create a torrent file

File:
1 edited

Legend:

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

    r2136 r2137  
    21282128    if ([[pasteboard types] containsObject: NSFilenamesPboardType])
    21292129    {
    2130         //check if any files can be added
     2130        //check if any torrent files can be added
    21312131        NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
    21322132        NSEnumerator * enumerator = [files objectEnumerator];
    21332133        NSString * file;
    21342134        tr_torrent_t * tempTor;
     2135        BOOL torrent = NO;
    21352136        while ((file = [enumerator nextObject]))
    21362137        {
     
    21462147                return NSDragOperationCopy;
    21472148            }
     2149            else
     2150            {
     2151                if (error == TR_EUNSUPPORTED || error == TR_EDUPLICATE)
     2152                    torrent = YES;
     2153            }
     2154        }
     2155       
     2156        //create a torrent file if a single file
     2157        if (!torrent && [files count] == 1)
     2158        {
     2159            if (!fOverlayWindow)
     2160                fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
     2161            [fOverlayWindow setFile: [[files objectAtIndex: 0] lastPathComponent]];
     2162           
     2163            return NSDragOperationCopy;
    21482164        }
    21492165    }
     
    21752191    if ([[pasteboard types] containsObject: NSFilenamesPboardType])
    21762192    {
     2193        BOOL torrent = NO, accept = YES;
     2194       
    21772195        //create an array of files that can be opened
    21782196        NSMutableArray * filesToOpen = [[NSMutableArray alloc] init];
    2179         NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator];
     2197        NSArray * files = [pasteboard propertyListForType: NSFilenamesPboardType];
     2198        NSEnumerator * enumerator = [files objectEnumerator];
    21802199        NSString * file;
    21812200        tr_torrent_t * tempTor;
     
    21872206                tr_torrentClose(tempTor);
    21882207                [filesToOpen addObject: file];
     2208               
     2209                torrent = YES;
    21892210            }
    2190         }
    2191        
    2192         [self application: NSApp openFiles: filesToOpen];
     2211            else
     2212            {
     2213                if (error == TR_EUNSUPPORTED || error == TR_EDUPLICATE)
     2214                    torrent = YES;
     2215            }
     2216        }
     2217       
     2218        if ([filesToOpen count] > 0)
     2219            [self application: NSApp openFiles: filesToOpen];
     2220        else
     2221        {
     2222            if (!torrent && [files count] == 1)
     2223                [CreatorWindowController createTorrentFile: fLib forFile: [files objectAtIndex: 0]];
     2224            else
     2225                accept = NO;
     2226        }
    21932227        [filesToOpen release];
    21942228       
    2195         return YES;
     2229        return accept;
    21962230    }
    21972231    else if ([[pasteboard types] containsObject: NSURLPboardType])
Note: See TracChangeset for help on using the changeset viewer.