OSDN Git Service

MacGui: End of encode/queue alerts and actions changes
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 21 Sep 2008 04:40:09 +0000 (04:40 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 21 Sep 2008 04:40:09 +0000 (04:40 +0000)
- Growl alerts and "Send to MetaX" actions occur as each encode comes finishes in the queue.
- The standard alert window, computer sleep and computer shutdown all occur at the end of encoding the entire queue, specifically when the encoding is done, and there aren't any other pending encodes to process.

git-svn-id: svn://localhost/HandBrake/trunk@1739 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.mm

index 2dd9450..f9dabba 100644 (file)
@@ -718,39 +718,58 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
              to determine if we should check for encode done notifications */
                        if( fEncodeState != 2 )
             {
+                NSString *pathOfFinishedEncode;
+                /* Get the output file name for the finished encode */
+                pathOfFinishedEncode = [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"DestinationPath"];
+                
+                /* Both the Growl Alert and Sending to MetaX can be done as encodes roll off the queue */
+                /* Growl alert */
+                [self showGrowlDoneNotification:pathOfFinishedEncode];
+                /* Send to MetaX */
+                [self sendToMetaX:pathOfFinishedEncode];
+                
                 /* since we have successfully completed an encode, we increment the queue counter */
-                [self incrementQueueItemDone:nil];
-                /* If Alert Window or Window and Growl has been selected */
-                               if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
-                   [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"] )
-                {
-                                       /*On Screen Notification*/
-                                       int status;
-                                       NSBeep();
-                                       status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake encode is done!", @"OK", nil, nil);
-                                       [NSApp requestUserAttention:NSCriticalRequest];
-                }
-                /* If sleep has been selected */
-                if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"] )
-                {
-                    /* Sleep */
-                    NSDictionary* errorDict;
-                    NSAppleEventDescriptor* returnDescriptor = nil;
-                    NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
-                                                   @"tell application \"Finder\" to sleep"];
-                    returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
-                    [scriptObject release];
-                }
-                /* If Shutdown has been selected */
-                if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"] )
+                [self incrementQueueItemDone:nil]; 
+                
+                /* all end of queue actions below need to be done after all queue encodes have finished 
+                 * and there are no pending jobs left to process
+                 */
+                if (fPendingCount == 0)
                 {
-                    /* Shut Down */
-                    NSDictionary* errorDict;
-                    NSAppleEventDescriptor* returnDescriptor = nil;
-                    NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
-                                                   @"tell application \"Finder\" to shut down"];
-                    returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
-                    [scriptObject release];
+                    /* If Alert Window or Window and Growl has been selected */
+                    if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
+                       [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"] )
+                    {
+                        /*On Screen Notification*/
+                        int status;
+                        NSBeep();
+                        status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake queue is done!", @"OK", nil, nil);
+                        [NSApp requestUserAttention:NSCriticalRequest];
+                    }
+                    
+                    /* If sleep has been selected */
+                    if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"] )
+                    {
+                        /* Sleep */
+                        NSDictionary* errorDict;
+                        NSAppleEventDescriptor* returnDescriptor = nil;
+                        NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
+                                                       @"tell application \"Finder\" to sleep"];
+                        returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+                        [scriptObject release];
+                    }
+                    /* If Shutdown has been selected */
+                    if( [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"] )
+                    {
+                        /* Shut Down */
+                        NSDictionary* errorDict;
+                        NSAppleEventDescriptor* returnDescriptor = nil;
+                        NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
+                                                       @"tell application \"Finder\" to shut down"];
+                        returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
+                        [scriptObject release];
+                    }
+                    
                 }
                 
                 
@@ -1051,7 +1070,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 
 -(void)showGrowlDoneNotification:(NSString *) filePath
 {
-    /* This is called from HBQueueController as jobs roll off of the queue in currentJobChanged */
+    /* This end of encode action is called as each encode rolls off of the queue */
     NSString * finishedEncode = filePath;
     /* strip off the path to just show the file name */
     finishedEncode = [finishedEncode lastPathComponent];
@@ -1072,7 +1091,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 }
 -(void)sendToMetaX:(NSString *) filePath
 {
-    /* This is called from HBQueueController as jobs roll off of the queue in currentJobChanged */
+    /* This end of encode action is called as each encode rolls off of the queue */
     if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
     {
         NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", filePath, @"\")"]];