allowing pasting into the tracker table on 10.5

This commit is contained in:
Mitchell Livingston 2009-10-01 02:24:58 +00:00
parent ecea999554
commit 0796b7d977
1 changed files with 21 additions and 8 deletions

View File

@ -79,8 +79,9 @@
- (void) paste: (id) sender - (void) paste: (id) sender
{ {
if (!fTorrent) NSAssert(fTorrent != nil, @"no torrent but trying to paste; should not be able to call this method");
return;
BOOL added = NO;
if ([NSApp isOnSnowLeopardOrBetter]) if ([NSApp isOnSnowLeopardOrBetter])
{ {
@ -88,18 +89,26 @@
[NSArray arrayWithObject: [NSString class]] options: nil]; [NSArray arrayWithObject: [NSString class]] options: nil];
NSAssert(items != nil, @"no string items to paste; should not be able to call this method"); 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 * pbItem in items)
{ {
for (NSString * item in [pbItem componentsSeparatedByString: @"\n"]) for (NSString * item in [pbItem componentsSeparatedByString: @"\n"])
if ([fTorrent addTrackerToNewTier: item]) if ([fTorrent addTrackerToNewTier: item])
added = YES; 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 - (BOOL) validateMenuItem: (NSMenuItem *) menuItem
@ -110,7 +119,11 @@
return [self numberOfSelectedRows] > 0; return [self numberOfSelectedRows] > 0;
if (action == @selector(paste:)) 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; return YES;
} }