From 0796b7d977a8b7d271d1706d570c56a6e3d83284 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 1 Oct 2009 02:24:58 +0000 Subject: [PATCH] allowing pasting into the tracker table on 10.5 --- macosx/TrackerTableView.m | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/macosx/TrackerTableView.m b/macosx/TrackerTableView.m index cbdc2f588..f24d3891e 100644 --- a/macosx/TrackerTableView.m +++ b/macosx/TrackerTableView.m @@ -79,8 +79,9 @@ - (void) paste: (id) sender { - if (!fTorrent) - return; + NSAssert(fTorrent != nil, @"no torrent but trying to paste; should not be able to call this method"); + + BOOL added = NO; if ([NSApp isOnSnowLeopardOrBetter]) { @@ -88,18 +89,26 @@ [NSArray arrayWithObject: [NSString class]] options: nil]; NSAssert(items != nil, @"no string items to paste; should not be able to call this method"); - BOOL added = NO; for (NSString * pbItem in items) { for (NSString * item in [pbItem componentsSeparatedByString: @"\n"]) if ([fTorrent addTrackerToNewTier: item]) added = YES; } - - //none added - if (!added) - NSBeep(); } + else + { + NSString * pbItem =[[NSPasteboard generalPasteboard] stringForType: NSStringPboardType]; + NSAssert(pbItem != nil, @"no string items to paste; should not be able to call this method"); + + for (NSString * item in [pbItem componentsSeparatedByString: @"\n"]) + if ([fTorrent addTrackerToNewTier: item]) + added = YES; + } + + //none added + if (!added) + NSBeep(); } - (BOOL) validateMenuItem: (NSMenuItem *) menuItem @@ -110,7 +119,11 @@ return [self numberOfSelectedRows] > 0; if (action == @selector(paste:)) - return [[NSPasteboard generalPasteboard] canReadObjectForClasses: [NSArray arrayWithObject: [NSString class]] options: nil]; + { + return fTorrent && ([NSApp isOnSnowLeopardOrBetter] + ? [[NSPasteboard generalPasteboard] canReadObjectForClasses: [NSArray arrayWithObject: [NSString class]] options: nil] + : [[NSPasteboard generalPasteboard] availableTypeFromArray: [NSArray arrayWithObject: NSStringPboardType]] != nil); + } return YES; }