]> granicus.if.org Git - handbrake/commitdiff
MacGui: use NSWorkspace to open an encoded file in the external app. It doesn't block...
authorritsuka <damiog@gmail.com>
Sat, 4 Jul 2015 07:02:19 +0000 (07:02 +0000)
committerritsuka <damiog@gmail.com>
Sat, 4 Jul 2015 07:02:19 +0000 (07:02 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7337 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBQueueController.m

index 406611df7abfae614d85a67a8425bb5996dfdd34..241dd64f0737d26a3c18583807c31031ed1c4c7d 100644 (file)
 - (void)sendToExternalApp:(NSURL *)fileURL
 {
     // This end of encode action is called as each encode rolls off of the queue
-    if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
+    if ([[NSUserDefaults standardUserDefaults] boolForKey:@"sendToMetaX"] == YES)
     {
-        NSString *sendToApp = [[NSUserDefaults standardUserDefaults] objectForKey:@"SendCompletedEncodeToApp"];
-        if (![sendToApp isEqualToString:@"None"])
+        NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
+        NSString *sendToApp = [workspace fullPathForApplication:[[NSUserDefaults standardUserDefaults] objectForKey:@"SendCompletedEncodeToApp"]];
+
+        if (sendToApp)
+        {
+            if (![workspace openFile:fileURL.path withApplication:sendToApp])
+            {
+                [HBUtilities writeToActivityLog:"Failed to send file to: %s", sendToApp];
+            }
+        }
+        else
         {
-            [HBUtilities writeToActivityLog: "trying to send encode to: %s", [sendToApp UTF8String]];
-            NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@%@%@", @"tell application \"",sendToApp,@"\" to open (POSIX file \"", fileURL.path, @"\")"]];
-            [myScript executeAndReturnError: nil];
+            [HBUtilities writeToActivityLog:"Send file to: app not found"];
         }
     }
 }