summaryrefslogtreecommitdiffstats
path: root/macosx/Controller.mm
diff options
context:
space:
mode:
authordynaflash <[email protected]>2008-09-21 04:40:09 +0000
committerdynaflash <[email protected]>2008-09-21 04:40:09 +0000
commit93c1d51aeac30926091a3fc3d38a9849a5efdf7a (patch)
tree27bc92b9118f70bfeb08b04510d636fdd9cc4c5f /macosx/Controller.mm
parent6cd5027aaa8bef98849db687f39d11ae2cf63869 (diff)
MacGui: End of encode/queue alerts and actions changes
- 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://svn.handbrake.fr/HandBrake/trunk@1739 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/Controller.mm')
-rw-r--r--macosx/Controller.mm85
1 files changed, 52 insertions, 33 deletions
diff --git a/macosx/Controller.mm b/macosx/Controller.mm
index 2dd945002..f9dabba4a 100644
--- a/macosx/Controller.mm
+++ b/macosx/Controller.mm
@@ -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, @"\")"]];