From dcef8bbc31158e9a5bcd6ca3c549965c4075f159 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Fri, 7 Jul 2006 22:31:30 +0000 Subject: [PATCH] dragging onto the window will now work for files with the extension "torrent" regardless of its case --- macosx/Controller.m | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 076a2f17a..d7ea747f9 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1216,12 +1216,15 @@ static void sleepCallBack(void * controller, io_service_t y, NSPasteboard * pasteboard = [info draggingPasteboard]; if ([[pasteboard types] containsObject: NSFilenamesPboardType]) { - if ([[[pasteboard propertyListForType: NSFilenamesPboardType] - pathsMatchingExtensions: [NSArray arrayWithObject: @"torrent"]] count] > 0) - { - [fTableView setDropRow: -1 dropOperation: NSTableViewDropOn]; - return NSDragOperationGeneric; - } + //check if any files to add have "torrent" as an extension + NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator]; + NSString * file; + while ((file = [enumerator nextObject])) + if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame) + { + [fTableView setDropRow: -1 dropOperation: NSTableViewDropOn]; + return NSDragOperationGeneric; + } } else if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) { @@ -1238,8 +1241,18 @@ static void sleepCallBack(void * controller, io_service_t y, { NSPasteboard * pasteboard = [info draggingPasteboard]; if ([[pasteboard types] containsObject: NSFilenamesPboardType]) - [self application: NSApp openFiles: [[[info draggingPasteboard] propertyListForType: NSFilenamesPboardType] - pathsMatchingExtensions: [NSArray arrayWithObject: @"torrent"]]]; + { + //create an array of files with the "torrent" extension + NSMutableArray * filesToOpen = [[NSMutableArray alloc] init]; + NSEnumerator * enumerator = [[pasteboard propertyListForType: NSFilenamesPboardType] objectEnumerator]; + NSString * file; + while ((file = [enumerator nextObject])) + if ([[file pathExtension] caseInsensitiveCompare: @"torrent"] == NSOrderedSame) + [filesToOpen addObject: file]; + + [self application: NSApp openFiles: filesToOpen]; + [filesToOpen release]; + } else { //remember selected rows if needed