Changeset 4113


Ignore:
Timestamp:
Dec 9, 2007, 10:18:22 PM (14 years ago)
Author:
livings124
Message:

backport dragging bugfix

Location:
branches/0.9x
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9x/NEWS

    r4069 r4113  
    11NEWS file for Transmission <http://transmission.m0k.org/>
     2
     30.96 (2007/12/yy)
     4- OS X:
     5   + Fix bug where dragging non-torrent files over the main window could result in excessive memory usage
    26
    370.95 (2007/12/04)
  • branches/0.9x/macosx/Controller.m

    r3691 r4113  
    23432343        while ((file = [enumerator nextObject]))
    23442344        {
    2345             canAdd = tr_torrentParse(fLib, [file UTF8String], NULL, NULL);
    2346             if (canAdd == TR_OK)
     2345            if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
    23472346            {
    2348                 if (!fOverlayWindow)
    2349                     fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
    2350                 [fOverlayWindow setTorrents: files];
    2351                
    2352                 return NSDragOperationCopy;
     2347                switch (canAdd = tr_torrentParse(fLib, [file UTF8String], NULL, NULL))
     2348                {
     2349                    case TR_OK:
     2350                        if (!fOverlayWindow)
     2351                            fOverlayWindow = [[DragOverlayWindow alloc] initWithLib: fLib forWindow: fWindow];
     2352                        [fOverlayWindow setTorrents: files];
     2353                       
     2354                        return NSDragOperationCopy;
     2355                   
     2356                    case TR_EDUPLICATE:
     2357                        torrent = YES;
     2358                }
    23532359            }
    2354             else if (canAdd == TR_EDUPLICATE)
    2355                 torrent = YES;
    2356             else;
    23572360        }
    23582361       
     
    24012404        NSEnumerator * enumerator = [files objectEnumerator];
    24022405        NSString * file;
    2403         int canAdd;
    24042406        while ((file = [enumerator nextObject]))
    24052407        {
    2406             canAdd = tr_torrentParse(fLib, [file UTF8String], NULL, NULL);
    2407             if (canAdd == TR_OK)
     2408            if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
    24082409            {
    2409                 [filesToOpen addObject: file];
    2410                 torrent = YES;
     2410                switch(tr_torrentParse(fLib, [file UTF8String], NULL, NULL))
     2411                {
     2412                    case TR_OK:
     2413                        [filesToOpen addObject: file];
     2414                        torrent = YES;
     2415                        break;
     2416                       
     2417                    case TR_EDUPLICATE:
     2418                        torrent = YES;
     2419                }
    24112420            }
    2412             else if (canAdd == TR_EDUPLICATE)
    2413                 torrent = YES;
    2414             else;
    24152421        }
    24162422       
  • branches/0.9x/macosx/DragOverlayView.h

    r3083 r4113  
    2727@interface DragOverlayView : NSView
    2828{
    29     NSImage * fBadge, * fBackBadge, * fAppIcon;
     29    NSImage * fBadge, * fBackBadge;
    3030   
    3131    NSDictionary * fMainLineAttributes, * fSubLineAttributes;
  • branches/0.9x/macosx/DragOverlayView.m

    r3394 r4113  
    2727
    2828#define PADDING 10.0
     29#define ICON_WIDTH 64.0
    2930
    3031@implementation DragOverlayView
     
    7778{
    7879    [fBackBadge release];
    79    
    8080    [fBadge release];
    81     [fAppIcon release];
    8281   
    8382    [fMainLineAttributes release];
     
    9392    NSSize badgeSize = [fBadge size];
    9493   
    95     //get icon
    96     NSSize iconSize = NSMakeSize(64.0, 64.0);
    97     if (!icon)
    98     {
    99         if (!fAppIcon)
    100         {
    101             fAppIcon = [[NSImage imageNamed: @"TransmissionDocument.icns"] copy];
    102             [fAppIcon setScalesWhenResized: YES];
    103             [fAppIcon setSize: iconSize];
    104         }
    105         icon = [fAppIcon retain];
    106     }
    107     else
    108     {
    109         icon = [icon copy];
    110         [icon setScalesWhenResized: YES];
    111         [icon setSize: iconSize];
    112     }
    113    
    11494    [fBadge lockFocus];
    11595   
    11696    //place icon
    117     [icon compositeToPoint: NSMakePoint(PADDING, (badgeSize.height - iconSize.height) * 0.5)
    118                 operation: NSCompositeSourceOver];
    119     [icon release];
     97    [icon drawInRect: NSMakeRect(PADDING, (badgeSize.height - ICON_WIDTH) * 0.5, ICON_WIDTH, ICON_WIDTH) fromRect: NSZeroRect
     98            operation: NSCompositeSourceOver fraction: 1.0];
    12099   
    121100    //place main text
     
    123102    NSSize subLineSize = [subLine sizeWithAttributes: fSubLineAttributes];
    124103   
    125     NSRect lineRect = NSMakeRect(PADDING + iconSize.width + 5.0,
     104    NSRect lineRect = NSMakeRect(PADDING + ICON_WIDTH + 5.0,
    126105                        (badgeSize.height + (subLineSize.height + 2.0 - mainLineSize.height)) * 0.5,
    127                         badgeSize.width - (PADDING + iconSize.width + 2.0) - PADDING, mainLineSize.height);
     106                        badgeSize.width - (PADDING + ICON_WIDTH + 2.0) - PADDING, mainLineSize.height);
    128107    [mainLine drawInRect: lineRect withAttributes: fMainLineAttributes];
    129108   
  • branches/0.9x/macosx/DragOverlayWindow.m

    r3427 r4113  
    8686    while ((file = [enumerator nextObject]))
    8787    {
    88         if (tr_torrentParse(fLib, [file UTF8String], NULL, &info) == TR_OK)
     88        if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame
     89            && tr_torrentParse(fLib, [file UTF8String], NULL, &info) == TR_OK)
    8990        {
    9091            count++;
     
    106107   
    107108    //set strings and icon
    108     NSImage * icon = nil;
    109109    NSString * secondString = [NSString stringForFileSize: size];
    110110    if (count > 1 || folder)
     
    115115        else
    116116            fileString= [NSString stringWithFormat: NSLocalizedString(@"%d Files, ", "Drag overlay -> torrents"), fileCount];
    117          secondString = [fileString stringByAppendingString: secondString];
     117        secondString = [fileString stringByAppendingString: secondString];
    118118    }
    119119   
     120    NSImage * icon;
    120121    if (count == 1)
    121122        icon = [[NSWorkspace sharedWorkspace] iconForFileType: folder ? NSFileTypeForHFSTypeCode('fldr') : [name pathExtension]];
     
    124125        name = [NSString stringWithFormat: NSLocalizedString(@"%d Torrent Files", "Drag overlay -> torrents"), count];
    125126        secondString = [secondString stringByAppendingString: @" Total"];
     127        icon = [NSImage imageNamed: @"TransmissionDocument.icns"];
    126128    }
    127129   
     
    159161- (void) fadeOut
    160162{
     163    if ([self alphaValue] <= 0.0)
     164        return;
     165   
    161166    //stop other animation and set to same progress
    162167    if ([fFadeInAnimation isAnimating])
Note: See TracChangeset for help on using the changeset viewer.