Changeset 2137


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

Location:
branches/file_selection/macosx
Files:
5 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])
  • branches/file_selection/macosx/CreatorWindowController.h

    r2130 r2137  
    4545
    4646+ (void) createTorrentFile: (tr_handle_t *) handle;
     47+ (void) createTorrentFile: (tr_handle_t *) handle forFile: (NSString *) file;
    4748
    4849- (id) initWithWindowNibName: (NSString *) name handle: (tr_handle_t *) handle path: (NSString *) path;
  • branches/file_selection/macosx/CreatorWindowController.m

    r2134 r2137  
    5050}
    5151
     52+ (void) createTorrentFile: (tr_handle_t *) handle forFile: (NSString *) file
     53{
     54    CreatorWindowController * creator = [[self alloc] initWithWindowNibName: @"Creator" handle: handle path: file];
     55    [creator showWindow: nil];
     56}
     57
    5258- (id) initWithWindowNibName: (NSString *) name handle: (tr_handle_t *) handle path: (NSString *) path
    5359{
  • branches/file_selection/macosx/DragOverlayWindow.h

    r2136 r2137  
    3434
    3535- (id) initWithLib: (tr_handle_t *) lib forWindow: (NSWindow *) window;
     36
    3637- (void) setTorrents: (NSArray *) files;
     38- (void) setFile: (NSString *) file;
    3739- (void) setURL: (NSString *) url;
    3840
  • branches/file_selection/macosx/DragOverlayWindow.m

    r2136 r2137  
    143143}
    144144
     145- (void) setFile: (NSString *) file
     146{
     147       
     148    [[self contentView] setOverlay: [NSImage imageNamed: @"Create.png"]
     149        mainLine: NSLocalizedString(@"Create a Torrent File", "Drag overlay -> file") subLine: file];
     150   
     151    //stop other animation and set to same progress
     152    if ([fFadeOutAnimation isAnimating])
     153    {
     154        [fFadeOutAnimation stopAnimation];
     155        [fFadeInAnimation setCurrentProgress: 1.0 - [fFadeOutAnimation currentProgress]];
     156    }
     157    [self setFrame: [[self parentWindow] frame] display: YES];
     158    [fFadeInAnimation startAnimation];
     159}
     160
     161
    145162- (void) setURL: (NSString *) url
    146163{
Note: See TracChangeset for help on using the changeset viewer.