From bfa9efc9f30c38349ff9251ca9add029f1d4842c Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Thu, 1 May 2008 02:20:53 +0000 Subject: [PATCH] #902 pasting a link into transmission will open the url --- macosx/InfoWindowController.m | 4 ++-- macosx/TorrentTableView.h | 2 ++ macosx/TorrentTableView.m | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 8f499abf8..3f9342827 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -394,8 +394,8 @@ typedef enum ? [[torrent publicTorrentLocation] stringByAbbreviatingWithTildeInPath] : NSLocalizedString(@"Transmission Support Folder", "Torrent -> location when deleting original")]; if (publicTorrent) - [fTorrentLocationField setToolTip: [NSString stringWithFormat: @"%@\n\n%@", - [torrent publicTorrentLocation], [torrent torrentLocation]]]; + [fTorrentLocationField setToolTip: [[torrent publicTorrentLocation] stringByAppendingFormat: @"\n\n%@", + [torrent torrentLocation]]]; else [fTorrentLocationField setToolTip: [torrent torrentLocation]]; diff --git a/macosx/TorrentTableView.h b/macosx/TorrentTableView.h index d07191b8f..8733c9a9a 100644 --- a/macosx/TorrentTableView.h +++ b/macosx/TorrentTableView.h @@ -66,6 +66,8 @@ - (NSArray *) selectedValues; - (NSArray *) selectedTorrents; +- (void) paste: (id) sender; + - (void) toggleControlForTorrent: (Torrent *) torrent; - (void) displayTorrentMenuForEvent: (NSEvent *) event; diff --git a/macosx/TorrentTableView.m b/macosx/TorrentTableView.m index 28fe7d993..52ce65096 100644 --- a/macosx/TorrentTableView.m +++ b/macosx/TorrentTableView.m @@ -528,6 +528,23 @@ [super keyDown: event]; } +- (void) paste: (id) sender +{ + NSURL * url; + if ((url = [NSURL URLFromPasteboard: [NSPasteboard generalPasteboard]])) + [fController openURL: url]; +} + +- (BOOL) validateMenuItem: (NSMenuItem *) menuItem +{ + SEL action = [menuItem action]; + + if (action == @selector(paste:)) + return [[[NSPasteboard generalPasteboard] types] containsObject: NSURLPboardType]; + + return YES; +} + - (void) toggleControlForTorrent: (Torrent *) torrent { if ([torrent isActive])