diff options
author | dynaflash <[email protected]> | 2007-04-27 15:53:56 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2007-04-27 15:53:56 +0000 |
commit | d61750f591c9979617e40dcba3a6f2d38d5b7be9 (patch) | |
tree | 0df8e3b8502c1f71abc90deb1a93664aaf82da8b /macosx/Controller.mm | |
parent | 73c2865afee53a5240b3fbff1f417e56a03b9551 (diff) |
macGui: Growl Support initial implementation
- include Growl.framework in xcode project
- Growl notify when encode is done
- fix cancelled encode finished bug
- may want a user pref to let them select if they want a notification and what type, on screen or grow. or both
- right now, its both.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@554 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/Controller.mm')
-rw-r--r-- | macosx/Controller.mm | 72 |
1 files changed, 62 insertions, 10 deletions
diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 8bfd7cb23..7caaf7fac 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -9,6 +9,10 @@ #define _(a) NSLocalizedString(a,NULL) + + + + static int FormatSettings[3][4] = { { HB_MUX_MP4 | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC, HB_MUX_MP4 | HB_VCODEC_X264 | HB_ACODEC_FAAC, @@ -37,13 +41,18 @@ static int FormatSettings[3][4] = - (void) applicationDidFinishLaunching: (NSNotification *) notification { + + int build; char * version; + /* Init libhb */ fHandle = hb_init( HB_DEBUG_NONE, [[NSUserDefaults standardUserDefaults] boolForKey:@"CheckForUpdates"] ); - + /* Set the Growl Delegate */ + HBController *hbGrowlDelegate = [[HBController alloc] init]; + [GrowlApplicationBridge setGrowlDelegate: hbGrowlDelegate]; /* Init others controllers */ [fScanController SetHandle: fHandle]; [fPictureController SetHandle: fHandle]; @@ -97,7 +106,9 @@ static int FormatSettings[3][4] = [self TranslateStrings]; - /* Init User Presets .plist */ + +//[self registrationDictionaryForGrowl]; +/* Init User Presets .plist */ /* We declare the default NSFileManager into fileManager */ NSFileManager * fileManager = [NSFileManager defaultManager]; //presetPrefs = [[NSUserDefaults standardUserDefaults] retain]; @@ -225,7 +236,18 @@ static int FormatSettings[3][4] = } +// register a test notification and make +// it enabled by default +#define SERVICE_NAME @"Encode Done" +- (NSDictionary *)registrationDictionaryForGrowl +{ +NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: +[NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL, +[NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT, +nil]; +return registrationDictionary; +} - (void) TranslateStrings { [fSrcDVD1Field setStringValue: _( @"DVD:" )]; @@ -543,15 +565,27 @@ static int FormatSettings[3][4] = hb_rem( fHandle, job ); } - /* Lets alert the user that the encode has finished */ - int status; - NSBeep(); - status = NSRunAlertPanel(@"Put down that cocktail...",@"your HandBrake encode is done!", @"OK", nil, nil); - if ( status == NSAlertDefaultReturn ) + if (fEncodeState != 2) // if the encode has not been cancelled + { + /* Lets alert the user that the encode has finished */ + /*Growl Notification*/ + [self showGrowlDoneNotification: NULL]; + /*On Screen Notification*/ + int status; + NSBeep(); + status = NSRunAlertPanel(@"Put down that cocktail...",@"your HandBrake encode is done!", @"OK", nil, nil); + //[NSApp requestUserAttention:NSInformationalRequest]; + [NSApp requestUserAttention:NSCriticalRequest]; + if ( status == NSAlertDefaultReturn ) + { + [self EnableUI: YES]; + } + } + else { - [self EnableUI: YES]; + [self EnableUI: YES]; } - break; + break; } } @@ -576,6 +610,20 @@ static int FormatSettings[3][4] = forMode: NSModalPanelRunLoopMode]; } +-(IBAction)showGrowlDoneNotification:(id)sender +{ + + + [GrowlApplicationBridge + notifyWithTitle:@"Put down that cocktail..." + description:@"Thank You for using HandBrake" + notificationName:SERVICE_NAME + iconData:nil + priority:0 + isSticky:1 + clickContext:nil]; +} + - (void) EnableUI: (bool) b { NSControl * controls[] = @@ -748,7 +796,7 @@ static int FormatSettings[3][4] = hb_title_t * title = (hb_title_t *) hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] ); hb_job_t * job = title->job; - int i; + //int i; /* Chapter selection */ job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1; @@ -1016,6 +1064,8 @@ static int FormatSettings[3][4] = { /* Let libhb do the job */ hb_start( fHandle ); + /*set the fEncodeState State */ + fEncodeState = 1; /* Disable interface */ [self EnableUI: NO]; @@ -1039,6 +1089,8 @@ static int FormatSettings[3][4] = hb_stop( fHandle ); [fPauseButton setEnabled: NO]; [fRipButton setEnabled: NO]; + /*set the fEncodeState State */ + fEncodeState = 2; } } |