From 08485e0ceb1477500971719cdea1d7f80eb9421c Mon Sep 17 00:00:00 2001 From: dynaflash Date: Tue, 12 Jan 2010 21:22:54 +0000 Subject: MacGui: Add the ability to send the finished encode to any application the user chooses instead of just "Send to MetaX". - Retains a checkbox to acivate sending the finished encode - Adds a file name textfield and a browse button so user can choose the app to send the finished encode to. - Defaults to MetaX as this would be the only app already existing in the users prefs. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3068 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/Controller.m | 12 +- macosx/English.lproj/Preferences.xib | 223 +++++++++++++++++++++++++++-------- macosx/HBPreferencesController.h | 6 +- macosx/HBPreferencesController.m | 51 +++++++- 4 files changed, 236 insertions(+), 56 deletions(-) (limited to 'macosx') diff --git a/macosx/Controller.m b/macosx/Controller.m index 4655a8792..7a093c25c 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1381,9 +1381,15 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* 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, @"\")"]]; - [myScript executeAndReturnError: nil]; - [myScript release]; + NSString *sendToApp = [[NSUserDefaults standardUserDefaults] objectForKey: @"SendCompletedEncodeToApp"]; + if (![sendToApp isEqualToString:@"None"]) + { + [self writeToActivityLog: "trying to send encode to: %s", [sendToApp UTF8String]]; + NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@%@%@", @"tell application \"",sendToApp,@"\" to open (POSIX file \"", filePath, @"\")"]]; + [myScript executeAndReturnError: nil]; + [myScript release]; + } + } } #pragma mark - diff --git a/macosx/English.lproj/Preferences.xib b/macosx/English.lproj/Preferences.xib index 85c1e68bd..6eea5da2b 100644 --- a/macosx/English.lproj/Preferences.xib +++ b/macosx/English.lproj/Preferences.xib @@ -2,17 +2,16 @@ 1050 - 10B504 + 10C540 732 - 1038.2 - 437.00 + 1038.25 + 458.00 com.apple.InterfaceBuilder.CocoaPlugin 732 YES - @@ -61,6 +60,10 @@ {1.79769e+308, 1.79769e+308} + + YES + SendCompletedEncodeToApp + YES @@ -68,6 +71,66 @@ 256 YES + + + 268 + {{345, 70}, {96, 16}} + + YES + + 67239424 + 134479872 + Browse ... + + LucidaGrande + 9 + 3614 + + + -2038284033 + 129 + + + 200 + 25 + + + + + 268 + {{209, 72}, {125, 14}} + + YES + + 68288064 + 272761856 + None + + LucidaGrande + 11 + 3100 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + 256 @@ -78,11 +141,7 @@ 67239424 131072 Use iPod/iTunes friendly (.m4v) file extension for MP4 - - LucidaGrande - 11 - 3100 - + 1211912703 2 @@ -149,24 +208,8 @@ When Done: - - 6 - System - controlColor - - 3 - MC42NjY2NjY2NjY3AA - - - - 6 - System - controlTextColor - - 3 - MAA - - + + @@ -193,13 +236,13 @@ 256 - {{123, 70}, {119, 18}} + {{123, 70}, {86, 18}} YES 67239424 131072 - Send file to MetaX + Send file to: 1211912703 @@ -529,7 +572,7 @@ NSControl - + 256 YES @@ -538,6 +581,7 @@ 268 {{34, 42}, {432, 17}} + YES 67239488 @@ -555,11 +599,13 @@ {496, 82} + + NSView NSResponder - + 256 YES @@ -910,14 +956,13 @@ {492, 91} - NSView NSResponder - + 256 YES @@ -926,7 +971,6 @@ 256 {{17, 203}, {280, 14}} - YES 67239424 @@ -943,7 +987,6 @@ 256 {{99, 169}, {198, 14}} - YES 67239424 @@ -960,7 +1003,6 @@ 256 {{137, 78}, {150, 14}} - YES 67239424 @@ -977,7 +1019,6 @@ 256 {{108, 100}, {27, 14}} - YES 67239424 @@ -994,7 +1035,6 @@ 256 {{70, 134}, {65, 14}} - YES 67239424 @@ -1011,7 +1051,6 @@ 256 {{137, 98}, {304, 18}} - YES 67239424 @@ -1033,7 +1072,6 @@ 256 {{137, 132}, {220, 18}} - YES 67239424 @@ -1055,7 +1093,6 @@ 256 {{137, 42}, {217, 18}} - YES 67239424 @@ -1077,7 +1114,6 @@ 268 {{299, 164}, {73, 22}} - YES -2076049856 @@ -1163,7 +1199,6 @@ 268 {{299, 198}, {76, 22}} - YES -2076049856 @@ -1239,7 +1274,6 @@ 268 {{289, 73}, {66, 22}} - YES -2076049856 @@ -1306,7 +1340,6 @@ 256 {{89, 44}, {46, 14}} - YES 67239424 @@ -1320,8 +1353,6 @@ {492, 237} - - NSView @@ -1670,6 +1701,54 @@ 434 + + + value: values.SendCompletedEncodeToApp + + + + + + value: values.SendCompletedEncodeToApp + value + values.SendCompletedEncodeToApp + 2 + + + 453 + + + + value: values.SendCompletedEncodeToApp + + + + + + value: values.SendCompletedEncodeToApp + value + values.SendCompletedEncodeToApp + 2 + + + 454 + + + + browseSendToApp: + + + + 455 + + + + fSendEncodeToAppField + + + + 456 + @@ -1730,6 +1809,8 @@ + + General @@ -2427,6 +2508,34 @@ + + 448 + + + YES + + + + + + 449 + + + + + 450 + + + YES + + + + + + 451 + + + @@ -2436,6 +2545,7 @@ -3.IBPluginDependency 233.IBEditorWindowLastContentRect 233.IBPluginDependency + 233.IBViewEditorWindowController.showingLayoutRectangles 233.ImportedFromIB2 233.editorWindowContentRectSynchronizationRect 234.IBEditorWindowLastContentRect @@ -2585,6 +2695,10 @@ 446.IBPluginDependency 446.ImportedFromIB2 447.IBPluginDependency + 448.IBPluginDependency + 449.IBPluginDependency + 450.IBPluginDependency + 451.IBPluginDependency 5.IBEditorWindowLastContentRect 5.IBPluginDependency 5.IBWindowTemplateEditedContentRect @@ -2601,8 +2715,9 @@ YES com.apple.InterfaceBuilder.CocoaPlugin - {{198, 532}, {492, 236}} + {{275, 582}, {492, 236}} com.apple.InterfaceBuilder.CocoaPlugin + {{0, 636}, {500, 209}} {{144, 376}, {496, 82}} @@ -2752,6 +2867,10 @@ com.apple.InterfaceBuilder.CocoaPlugin 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}} @@ -2782,7 +2901,7 @@ - 447 + 456 @@ -2790,6 +2909,10 @@ HBPreferencesController NSWindowController + + browseSendToApp: + id + YES @@ -2798,6 +2921,7 @@ fAudioView fGeneralView fPictureView + fSendEncodeToAppField YES @@ -2805,6 +2929,7 @@ NSView NSView NSView + NSTextField diff --git a/macosx/HBPreferencesController.h b/macosx/HBPreferencesController.h index 297fe5725..ca1ad5ab4 100644 --- a/macosx/HBPreferencesController.h +++ b/macosx/HBPreferencesController.h @@ -8,9 +8,13 @@ @interface HBPreferencesController : NSWindowController { IBOutlet NSView * fGeneralView, * fPictureView, * fAudioView, * fAdvancedView; + IBOutlet NSTextField * fSendEncodeToAppField; } + (void)registerUserDefaults; - (id)init; - +/* Manage the send encode to xxx.app windows and field */ +- (IBAction) browseSendToApp: (id) sender; +- (void) browseSendToAppDone: (NSOpenPanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo; @end diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m index 943cf3b28..9f1e38129 100644 --- a/macosx/HBPreferencesController.m +++ b/macosx/HBPreferencesController.m @@ -45,9 +45,9 @@ @"YES", @"CheckForUpdates", @"Open Source", @"LaunchSourceBehavior", @"English", @"DefaultLanguage", - @"YES", @"UseCoreAudio", + @"YES", @"UseCoreAudio", @"NO", @"DefaultMpegName", - @"YES", @"UseDvdNav", + @"YES", @"UseDvdNav", @"", @"DefAdvancedx264Flags", @"YES", @"DefaultPresetsDrawerShow", desktopDirectory, @"LastDestinationDirectory", @@ -60,7 +60,8 @@ @"10", @"PreviewsNumber", @"", @"Drawer Size", @"0.25", @"x264CqSliderFractional", - @"YES", @"AlertBuiltInPresetUpdate", + @"YES", @"AlertBuiltInPresetUpdate", + @"MetaX", @"SendCompletedEncodeToApp", nil]]; } @@ -147,6 +148,50 @@ TOOLBAR_AUDIO, TOOLBAR_ADVANCED, nil]; } +/* Manage the send encode to xxx.app windows and field */ +/*Opens the app browse window*/ +- (IBAction) browseSendToApp: (id) sender +{ + NSOpenPanel * panel; + + panel = [NSOpenPanel openPanel]; + [panel setAllowsMultipleSelection: NO]; + [panel setCanChooseFiles: YES]; + [panel setCanChooseDirectories: NO ]; + NSString * sendToAppDirectory; + if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSendToAppDirectory"]) + { + sendToAppDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSendToAppDirectory"]; + } + else + { + sendToAppDirectory = @"/Applications"; + } + [panel beginSheetForDirectory: sendToAppDirectory file: nil types: nil + modalForWindow: [self window] modalDelegate: self + didEndSelector: @selector( browseSendToAppDone:returnCode:contextInfo: ) + contextInfo: sender]; +} + +- (void) browseSendToAppDone: (NSOpenPanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo +{ + if( returnCode == NSOKButton ) + { + NSString *sendToAppPath = [[sheet filenames] objectAtIndex: 0]; + NSString *sendToAppDirectory = [sendToAppPath stringByDeletingLastPathComponent]; + [[NSUserDefaults standardUserDefaults] setObject:sendToAppDirectory forKey:@"LastSendToAppDirectory"]; + [sheet orderOut: self]; + NSString *sendToAppName; + sendToAppName = [[sendToAppPath lastPathComponent] stringByDeletingPathExtension]; + /* we set the name of the app to send to in the display field */ + [fSendEncodeToAppField setStringValue:sendToAppName]; + [[NSUserDefaults standardUserDefaults] setObject:[fSendEncodeToAppField stringValue] forKey:@"SendCompletedEncodeToApp"]; + + } +} + + @end @implementation HBPreferencesController (Private) -- cgit v1.2.3