allow torrent files not ending in .torrent to be opened by dragging to the window
This commit is contained in:
parent
12b3df53ef
commit
3a94e0b7b4
|
@ -124,8 +124,8 @@
|
|||
* uploadRateString = checkUpload && uploadRate >= 0.1 ? [NSString stringForSpeedAbbrev: uploadRate] : nil;
|
||||
|
||||
NSImage * dockIcon = nil;
|
||||
BOOL speedBadge;
|
||||
if (speedBadge = (uploadRateString || downloadRateString))
|
||||
BOOL speedChange;
|
||||
if (speedChange = (uploadRateString || downloadRateString))
|
||||
{
|
||||
dockIcon = [fDockIcon copy];
|
||||
|
||||
|
@ -171,14 +171,15 @@
|
|||
}
|
||||
|
||||
//update dock badge
|
||||
if (baseChange || fSpeedBadge || speedBadge)
|
||||
if (baseChange || fSpeedBadge || speedChange)
|
||||
{
|
||||
if (!dockIcon)
|
||||
dockIcon = [fDockIcon retain];
|
||||
[NSApp setApplicationIconImage: dockIcon];
|
||||
[dockIcon release];
|
||||
|
||||
fSpeedBadge = speedChange;
|
||||
}
|
||||
fSpeedBadge = speedBadge;
|
||||
|
||||
[fLock unlock];
|
||||
}
|
||||
|
|
|
@ -2007,15 +2007,21 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
NSPasteboard * pasteboard = [info draggingPasteboard];
|
||||
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
||||
{
|
||||
//check if any files to add have "torrent" as an extension
|
||||
//check if any files can be added
|
||||
NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator];
|
||||
NSString * file;
|
||||
while ((file = [enumerator nextObject]))
|
||||
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
|
||||
{
|
||||
tr_torrent_t * tempTor;
|
||||
int error;
|
||||
if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error)))
|
||||
{
|
||||
tr_torrentClose(fLib, tempTor);
|
||||
|
||||
[fTableView setDropRow: -1 dropOperation: NSTableViewDropOn];
|
||||
return NSDragOperationGeneric;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ([[pasteboard types] containsObject: NSURLPboardType])
|
||||
{
|
||||
|
@ -2038,13 +2044,20 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
NSPasteboard * pasteboard = [info draggingPasteboard];
|
||||
if ([[pasteboard types] containsObject: NSFilenamesPboardType])
|
||||
{
|
||||
//create an array of files with the "torrent" extension
|
||||
//create an array of files that can be opened
|
||||
NSMutableArray * filesToOpen = [[NSMutableArray alloc] init];
|
||||
NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator];
|
||||
NSString * file;
|
||||
while ((file = [enumerator nextObject]))
|
||||
if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame)
|
||||
{
|
||||
tr_torrent_t * tempTor;
|
||||
int error;
|
||||
if ((tempTor = tr_torrentInit(fLib, [file UTF8String], NULL, 0, &error)))
|
||||
{
|
||||
tr_torrentClose(fLib, tempTor);
|
||||
[filesToOpen addObject: file];
|
||||
}
|
||||
}
|
||||
|
||||
[self application: NSApp openFiles: filesToOpen];
|
||||
[filesToOpen release];
|
||||
|
|
Loading…
Reference in New Issue