diff options
author | dynaflash <[email protected]> | 2010-07-26 20:43:30 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2010-07-26 20:43:30 +0000 |
commit | 4b5662c9864e4cfc667de3137b1fba382ed74dc2 (patch) | |
tree | c2b8bccee032d5bd5f7f35a27fded8db81bc8287 /macosx/Controller.m | |
parent | 324483418fb3049f992999b1dd8881235f35116b (diff) |
MacGui: Rework how we get encode and queue done alerts.
- Add separate checkbox for system alert sound in Preferences > General > When Done (previously it was automatic only when "When Done" included the alert panel")
- System alert sound will play whenever the specified Alert When Done event occurs if its checked (this includes the Growl alerts which come up as encodes roll off of the queue) which addresses the sound part of this forum thread http://forum.handbrake.fr/viewtopic.php?f=22&t=17347#p80456. Thanks to BradleyS for the suggestion.
- Also fix an issue introduced in the multi instance queue commmit (ref 3450) where the Alert Window would come up one encode too early instead of at the end of the queue if you use the alert window for when queue is completed. This addresses forum thread http://forum.handbrake.fr/viewtopic.php?f=12&t=17367 thanks to noved for picking up on it.
- Get rid of a touch of commented code from rev 3450 which is worthless.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3461 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/Controller.m')
-rw-r--r-- | macosx/Controller.m | 100 |
1 files changed, 53 insertions, 47 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index 47303dfc9..d0b5c9dd2 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -85,11 +85,6 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]]; [self writeToActivityLog: "%s", [versionStringFull UTF8String]]; - /* Get the PID number for this hb instance, used in multi instance encoding */ - //pidNum = [self getThisHBInstancePID]; - /* Report this pid to the activity log */ - //[self writeToActivityLog: "Pid for this instance:%d", pidNum]; - return self; } @@ -1015,46 +1010,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* since we have successfully completed an encode, we increment the queue counter */ [self incrementQueueItemDone:currentQueueEncodeIndex]; - - /* 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) - { - /* 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]; - } - } + } break; @@ -1426,6 +1382,13 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It -(void)showGrowlDoneNotification:(NSString *) filePath { /* This end of encode action is called as each encode rolls off of the queue */ + + /* If Play System Alert has been selected in Preferences */ + if( [[NSUserDefaults standardUserDefaults] boolForKey:@"AlertWhenDoneSound"] == YES ) + { + NSBeep(); + } + /* Setup the Growl stuff ... */ NSString * finishedEncode = filePath; /* strip off the path to just show the file name */ finishedEncode = [finishedEncode lastPathComponent]; @@ -1460,6 +1423,49 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It } } + +- (void) queueCompletedAlerts +{ + /* If Play System Alert has been selected in Preferences */ + if( [[NSUserDefaults standardUserDefaults] boolForKey:@"AlertWhenDoneSound"] == YES ) + { + NSBeep(); + } + + /* 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; + 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]; + } +} + #pragma mark - #pragma mark Get New Source @@ -2524,6 +2530,8 @@ fWorkingCount = 0; else { [self writeToActivityLog: "incrementQueueItemDone there are no more pending encodes"]; + /*Since there are no more items to encode, go to queueCompletedAlerts for user specified alerts after queue completed*/ + [self queueCompletedAlerts]; } } @@ -2707,8 +2715,6 @@ fWorkingCount = 0; [self doRip]; } - - #pragma mark - #pragma mark Queue Item Editing |