1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-01-31 03:12:44 +00:00

#3006 Allow Trackers to be copied in Create Window

This commit is contained in:
Mitchell Livingston 2010-04-23 02:13:54 +00:00
parent 3b38ec9205
commit fec2a18dd3
2 changed files with 22 additions and 0 deletions

View file

@ -60,6 +60,7 @@
- (void) addRemoveTracker: (id) sender;
- (void) copy: (id) sender;
- (void) paste: (id) sender;
@end

View file

@ -322,10 +322,31 @@
[fTrackerAddRemoveControl setEnabled: [fTrackerTable numberOfSelectedRows] > 0 forSegment: TRACKER_REMOVE_TAG];
}
- (void) copy: (id) sender
{
NSArray * addresses = [fTrackers objectsAtIndexes: [fTrackerTable selectedRowIndexes]];
NSString * text = [addresses componentsJoinedByString: @"\n"];
NSPasteboard * pb = [NSPasteboard generalPasteboard];
if ([NSApp isOnSnowLeopardOrBetter])
{
[pb clearContents];
[pb writeObjects: [NSArray arrayWithObject: text]];
}
else
{
[pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: nil];
[pb setString: text forType: NSStringPboardType];
}
}
- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
{
const SEL action = [menuItem action];
if (action == @selector(copy:))
return [[self window] firstResponder] == fTrackerTable && [fTrackerTable numberOfSelectedRows] > 0;
if (action == @selector(paste:))
return [[self window] firstResponder] == fTrackerTable
&& ([NSApp isOnSnowLeopardOrBetter]