1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

allow torrent files not ending in .torrent to be opened by dragging to the window

This commit is contained in:
Mitchell Livingston 2007-05-17 23:14:53 +00:00
parent 12b3df53ef
commit 3a94e0b7b4
2 changed files with 22 additions and 8 deletions

View file

@ -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];
}

View file

@ -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];