allowing pasting into the tracker table on 10.5
This commit is contained in:
parent
ecea999554
commit
0796b7d977
|
@ -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,19 +89,27 @@
|
||||||
[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;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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
|
//none added
|
||||||
if (!added)
|
if (!added)
|
||||||
NSBeep();
|
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue