From e079903f520ac42a150ec4b9661433d0c10dc306 Mon Sep 17 00:00:00 2001 From: dynaflash Date: Mon, 26 Jul 2010 20:43:30 +0000 Subject: [PATCH] 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://localhost/HandBrake/trunk@3461 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/Controller.m | 100 ++++++++------- macosx/English.lproj/Preferences.xib | 242 +++++++++++++++++++++++++++++------ macosx/HBPreferencesController.m | 1 + 3 files changed, 254 insertions(+), 89 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index 47303dfc..d0b5c9dd 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 diff --git a/macosx/English.lproj/Preferences.xib b/macosx/English.lproj/Preferences.xib index b38c3761..60c6a733 100644 --- a/macosx/English.lproj/Preferences.xib +++ b/macosx/English.lproj/Preferences.xib @@ -2,17 +2,17 @@ 1050 - 10C540 - 740 - 1038.25 - 458.00 + 10F569 + 788 + 1038.29 + 461.00 com.apple.InterfaceBuilder.CocoaPlugin - 740 + 788 YES - + YES @@ -63,14 +63,45 @@ YES - + 256 YES + + + 256 + {{123, 90}, {313, 18}} + + YES + + -2080244224 + 131072 + Play System Alert Sound + + LucidaGrande + 11 + 3100 + + + 1211912703 + 2 + + NSImage + NSSwitch + + + NSSwitch + + + + 200 + 25 + + 268 - {{345, 70}, {96, 16}} + {{345, 71}, {96, 16}} YES @@ -94,18 +125,14 @@ 268 - {{209, 72}, {125, 14}} + {{209, 73}, {125, 14}} YES 68288064 272761856 None - - LucidaGrande - 11 - 3100 - + 6 @@ -130,7 +157,7 @@ 256 - {{123, 18}, {311, 18}} + {{125, 18}, {311, 18}} YES @@ -141,9 +168,7 @@ 1211912703 2 - - NSSwitch - + 200 @@ -153,7 +178,7 @@ 256 - {{123, 200}, {133, 18}} + {{123, 220}, {133, 18}} YES @@ -174,7 +199,7 @@ 256 - {{123, 38}, {303, 18}} + {{125, 38}, {303, 18}} YES @@ -195,7 +220,7 @@ 256 - {{52, 97}, {69, 14}} + {{52, 117}, {69, 14}} YES @@ -211,7 +236,7 @@ 256 - {{123, 155}, {194, 18}} + {{123, 175}, {194, 18}} YES @@ -232,7 +257,7 @@ 256 - {{123, 70}, {86, 18}} + {{123, 71}, {86, 18}} YES @@ -243,10 +268,7 @@ 1211912703 2 - - NSImage - NSSwitch - + @@ -257,7 +279,7 @@ 256 - {{62, 202}, {59, 14}} + {{62, 222}, {59, 14}} YES @@ -273,7 +295,7 @@ 256 - {{141, 179}, {95, 14}} + {{141, 199}, {95, 14}} YES @@ -289,7 +311,7 @@ 256 - {{50, 40}, {71, 14}} + {{52, 40}, {71, 14}} YES @@ -305,7 +327,7 @@ 256 - {{123, 90}, {189, 22}} + {{123, 110}, {189, 22}} YES @@ -419,7 +441,7 @@ 256 - {{141, 128}, {102, 22}} + {{141, 148}, {102, 22}} YES @@ -493,7 +515,7 @@ 256 - {{238, 174}, {205, 22}} + {{238, 194}, {205, 22}} YES @@ -562,7 +584,8 @@ - {492, 236} + {460, 256} + NSView NSControl @@ -597,7 +620,7 @@ NSResponder - + 256 YES @@ -938,7 +961,7 @@ 1211912703 130 - + @@ -948,7 +971,6 @@ {492, 91} - NSView @@ -1742,6 +1764,22 @@ 456 + + + value: values.AlertWhenDoneSound + + + + + + value: values.AlertWhenDoneSound + value + values.AlertWhenDoneSound + 2 + + + 460 + @@ -1790,20 +1828,21 @@ YES - - - + + + + General @@ -2529,6 +2568,20 @@ + + 457 + + + YES + + + + + + 458 + + + @@ -2692,6 +2745,9 @@ 449.IBPluginDependency 450.IBPluginDependency 451.IBPluginDependency + 457.IBPluginDependency + 457.ImportedFromIB2 + 458.IBPluginDependency 5.IBEditorWindowLastContentRect 5.IBPluginDependency 5.IBWindowTemplateEditedContentRect @@ -2708,7 +2764,7 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{275, 582}, {492, 236}} + {{275, 562}, {460, 256}} com.apple.InterfaceBuilder.CocoaPlugin @@ -2864,6 +2920,9 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + + com.apple.InterfaceBuilder.CocoaPlugin {{69, 656}, {500, 200}} com.apple.InterfaceBuilder.CocoaPlugin {{69, 656}, {500, 200}} @@ -2894,7 +2953,7 @@ - 456 + 461 @@ -2906,6 +2965,13 @@ browseSendToApp: id + + browseSendToApp: + + browseSendToApp: + id + + YES @@ -2925,6 +2991,40 @@ NSTextField + + YES + + YES + fAdvancedView + fAudioView + fGeneralView + fPictureView + fSendEncodeToAppField + + + YES + + fAdvancedView + NSView + + + fAudioView + NSView + + + fGeneralView + NSView + + + fPictureView + NSView + + + fSendEncodeToAppField + NSTextField + + + IBProjectSource HBPreferencesController.h @@ -2937,6 +3037,13 @@ runModal: id + + runModal: + + runModal: + id + + IBUserSource @@ -2966,10 +3073,24 @@ checkForUpdates: id + + checkForUpdates: + + checkForUpdates: + id + + delegate id + + delegate + + delegate + id + + @@ -3606,6 +3727,13 @@ showWindow: id + + showWindow: + + showWindow: + id + + IBFrameworkSource AppKit.framework/Headers/NSWindowController.h @@ -3618,15 +3746,30 @@ checkForUpdates: id + + checkForUpdates: + + checkForUpdates: + id + + delegate id + + delegate + + delegate + id + + 0 + IBCocoaFramework com.apple.InterfaceBuilder.CocoaPlugin.macosx @@ -3638,5 +3781,20 @@ YES ../HandBrake.xcodeproj 3 + + YES + + YES + NSMenuCheckmark + NSMenuMixedState + NSSwitch + + + YES + {9, 8} + {7, 2} + {15, 15} + + diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 3e701850..aa5d6478 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -55,6 +55,7 @@ @"NO", @"DefaultAutoNaming", @"NO", @"DisableDvdAutoDetect", @"Alert Window", @"AlertWhenDone", + @"YES", @"AlertWhenDoneSound", @"1", @"LoggingLevel", @"NO", @"EncodeLogLocation", @"10", @"PreviewsNumber", -- 2.11.0