]> granicus.if.org Git - transmission/commitdiff
allowing pasting into the tracker table on 10.5
authorMitchell Livingston <livings124@transmissionbt.com>
Thu, 1 Oct 2009 02:24:58 +0000 (02:24 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Thu, 1 Oct 2009 02:24:58 +0000 (02:24 +0000)
macosx/TrackerTableView.m

index cbdc2f58852e56ce8d1fd5ab11f8167f98e53ef2..f24d3891ee85008d2ff1f98407d408a78bb31468 100644 (file)
@@ -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])
     {
                             [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;
         }
+    }
+    else
+    {
+        NSString * pbItem =[[NSPasteboard generalPasteboard] stringForType: NSStringPboardType];
+        NSAssert(pbItem != nil, @"no string items to paste; should not be able to call this method");
         
-        //none added
-        if (!added)
-            NSBeep();
+        for (NSString * item in [pbItem componentsSeparatedByString: @"\n"])
+            if ([fTorrent addTrackerToNewTier: item])
+                added = YES;
     }
+    
+    //none added
+    if (!added)
+        NSBeep();
 }
 
 - (BOOL) validateMenuItem: (NSMenuItem *) menuItem
         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;
 }