From 274f5110475910530e04e547d7349070873986f9 Mon Sep 17 00:00:00 2001 From: ritsuka Date: Mon, 28 Jul 2008 17:22:52 +0000 Subject: [PATCH] MacGui: - Implement automatic extension switching for mp4/m4v. - Disable http mp4 checkbox when an ac3 track is present. - Disable autonaming if there is only one title in the source. git-svn-id: svn://localhost/HandBrake/trunk@1587 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/Controller.h | 1 + macosx/Controller.mm | 157 ++++++++++++++++++-------------------- macosx/English.lproj/MainMenu.xib | 114 ++++++++++++++------------- 3 files changed, 139 insertions(+), 133 deletions(-) diff --git a/macosx/Controller.h b/macosx/Controller.h index 91f6b322..4df14f94 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -259,6 +259,7 @@ BOOL fIsDragging; - (IBAction) formatPopUpChanged: (id) sender; - (IBAction) videoEncoderPopUpChanged: (id) sender; - (IBAction) autoSetM4vExtension: (id) sender; +- (void) shouldEnableHttpMp4CheckBox: (id) sender; - (IBAction) twoPassCheckboxChanged: (id) sender; - (IBAction) videoFrameRateChanged: (id) sender; - (IBAction) audioAddAudioTrackCodecs: (id)sender; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 3240026b..c1a589bd 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -355,6 +355,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It [self setEnabledStateOfAudioMixdownControls:nil]; /* we also call calculatePictureSizing here to sense check if we already have vfr selected */ [self calculatePictureSizing:nil]; + [self shouldEnableHttpMp4CheckBox: nil]; } else { @@ -622,7 +623,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* Check to see if the encode state has not been cancelled to determine if we should check for encode done notifications */ if (fEncodeState != 2) { - /* If Alert Window or Window and Growl has been selected */ + /* 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"]) { @@ -631,45 +632,32 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It NSBeep(); status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake encode is done!", @"OK", nil, nil); [NSApp requestUserAttention:NSCriticalRequest]; - if ( status == NSAlertDefaultReturn ) - { - [self enableUI: YES]; - } + } - else - { - [self enableUI: YES]; - } - /* If sleep has been selected */ - if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"]) + + /* 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]; - [self enableUI: YES]; + /* 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"]) + /* 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]; - [self enableUI: YES]; + /* Shut Down */ + NSDictionary* errorDict; + NSAppleEventDescriptor* returnDescriptor = nil; + NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource: + @"tell application \"Finder\" to shut down"]; + returnDescriptor = [scriptObject executeAndReturnError: &errorDict]; + [scriptObject release]; } - } - else - { - [self enableUI: YES]; - } break; } } @@ -1452,12 +1440,12 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */ - if ([fDstFormatPopUp indexOfSelectedItem] == 0) + if( [fDstFormatPopUp indexOfSelectedItem] == 0 ) { /* We set the largeFileSize (64 bit formatting) variable here to allow for > 4gb files based on the format being mpeg4 and the checkbox being checked *Note: this will break compatibility with some target devices like iPod, etc.!!!!*/ - if ([fDstMp4LargeFileCheck state] == NSOnState) + if( [fDstMp4LargeFileCheck state] == NSOnState ) { job->largeFileSize = 1; } @@ -1466,7 +1454,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It job->largeFileSize = 0; } /* We set http optimized mp4 here */ - if ([fDstMp4HttpOptFileCheck state] == NSOnState) + if( [fDstMp4HttpOptFileCheck state] == NSOnState && [fDstMp4HttpOptFileCheck isEnabled] ) { job->mp4_optimize = 1; } @@ -1475,7 +1463,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It job->mp4_optimize = 0; } } - if ([fDstFormatPopUp indexOfSelectedItem] == 0 || [fDstFormatPopUp indexOfSelectedItem] == 1) + if( [fDstFormatPopUp indexOfSelectedItem] == 0 || [fDstFormatPopUp indexOfSelectedItem] == 1 ) { /* We set the chapter marker extraction here based on the format being mpeg4 or mkv and the checkbox being checked */ @@ -2109,15 +2097,15 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It hb_list_t * list = hb_get_titles( fHandle ); hb_title_t * title = (hb_title_t*) hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] ); - - + + /* If Auto Naming is on. We create an output filename of dvd name - title number */ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"] > 0) + if( [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"] > 0 && ( hb_list_count( list ) > 1 ) ) { [fDstFile2Field setStringValue: [NSString stringWithFormat: @"%@/%@-%d.%@", [[fDstFile2Field stringValue] stringByDeletingLastPathComponent], - browsedSourceDisplayName, - title->index, + [browsedSourceDisplayName stringByDeletingPathExtension], + title->index, [[fDstFile2Field stringValue] pathExtension]]]; } @@ -2362,27 +2350,18 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It break; } [fVidEncoderPopUp selectItemAtIndex: 0]; - + [self audioAddAudioTrackCodecs: fAudTrack1CodecPopUp]; [self audioAddAudioTrackCodecs: fAudTrack2CodecPopUp]; [self audioAddAudioTrackCodecs: fAudTrack3CodecPopUp]; [self audioAddAudioTrackCodecs: fAudTrack4CodecPopUp]; - - /* FIX ME: we need to restore changing the file extension as pwer */ - - if( [string characterAtIndex: [string length] - 4] == '.' ) - { - [fDstFile2Field setStringValue: [NSString stringWithFormat: - @"%@.%s", [string substringToIndex: [string length] - 4], - ext]]; - } - else - { - [fDstFile2Field setStringValue: [NSString stringWithFormat: - @"%@.%s", string, ext]]; - } - - if ( SuccessfulScan ) + + if( format == 0 ) + [self autoSetM4vExtension: sender]; + else + [fDstFile2Field setStringValue: [NSString stringWithFormat:@"%@.%s", [string stringByDeletingPathExtension], ext]]; + + if( SuccessfulScan ) { /* Add/replace to the correct extension */ [self audioTrackPopUpChanged: fAudLang1PopUp]; @@ -2390,7 +2369,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It [self audioTrackPopUpChanged: fAudLang3PopUp]; [self audioTrackPopUpChanged: fAudLang4PopUp]; - if ( [fVidEncoderPopUp selectedItem] == nil ) + if( [fVidEncoderPopUp selectedItem] == nil ) { [fVidEncoderPopUp selectItemAtIndex:0]; @@ -2399,38 +2378,47 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* changing the format may mean that we can / can't offer mono or 6ch, */ /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */ - - /* We call the method to properly enable/disable turbo 2 pass */ [self twoPassCheckboxChanged: sender]; /* We call method method to change UI to reflect whether a preset is used or not*/ } } - - /* Lets check to see if we want to auto set the .m4v extension for mp4 */ - [self autoSetM4vExtension: sender]; [self customSettingUsed: sender]; } +- (IBAction) autoSetM4vExtension: (id) sender +{ + if ( [fDstFormatPopUp indexOfSelectedItem] ) + return; + NSString * extension = @"mp4"; - /* if MP4 format and [fDstCodecsPopUp indexOfSelectedItem] > 1 we know that the audio is going to be - * either aac + ac3 passthru, or just ac3 passthru so we need to make sure the output file extension is m4v - * otherwise Quicktime will not play it at all */ -- (IBAction) autoSetM4vExtension: (id) sender + if( [[fAudTrack1CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack2CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || + [[fAudTrack3CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || + [[fAudTrack4CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || + [fCreateChapterMarkers state] == NSOnState || + [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0 ) + { + extension = @"m4v"; + } + + if( [extension isEqualTo: [[fDstFile2Field stringValue] pathExtension]] ) + return; + else + [fDstFile2Field setStringValue: [NSString stringWithFormat:@"%@.%@", + [[fDstFile2Field stringValue] stringByDeletingPathExtension], extension]]; +} + +- (void) shouldEnableHttpMp4CheckBox: (id) sender { - /*FIX ME: for this to work, we will now have to iterate through the audio list to see if ac3 in an mp4 is chosen - * for now just comment it out. - */ - /* - if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [fDstCodecsPopUp indexOfSelectedItem] > 1) - { - NSString *newpath = [[[fDstFile2Field stringValue] stringByDeletingPathExtension] stringByAppendingPathExtension: @"m4v"]; - [fDstFile2Field setStringValue: [NSString stringWithFormat: - @"%@", newpath]]; - } - */ + if( [[fAudTrack1CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack2CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || + [[fAudTrack3CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || + [[fAudTrack4CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 ) + [fDstMp4HttpOptFileCheck setEnabled: NO]; + else + [fDstMp4HttpOptFileCheck setEnabled: YES]; } + /* Method to determine if we should change the UI To reflect whether or not a Preset is being used or if the user is using "Custom" settings by determining the sender*/ @@ -3374,8 +3362,13 @@ the user is using "Custom" settings by determining the sender*/ } } - + if( [fDstFormatPopUp indexOfSelectedItem] == 0 ) + { + [self autoSetM4vExtension: sender]; + [self shouldEnableHttpMp4CheckBox: sender]; + } } + - (IBAction) audioTrackMixdownChanged: (id) sender { diff --git a/macosx/English.lproj/MainMenu.xib b/macosx/English.lproj/MainMenu.xib index 75e1d609..a0621005 100644 --- a/macosx/English.lproj/MainMenu.xib +++ b/macosx/English.lproj/MainMenu.xib @@ -8,7 +8,8 @@ 352.00 YES - + + YES @@ -99,7 +100,7 @@ 1 - + 256 YES @@ -279,7 +280,7 @@ 256 - {{17, 103}, {93, 17}} + {{14, 119}, {93, 17}} YES @@ -299,7 +300,7 @@ 256 - {{17, 83}, {96, 14}} + {{14, 99}, {96, 14}} YES @@ -315,7 +316,7 @@ 256 - {{17, 61}, {96, 14}} + {{14, 77}, {96, 14}} YES @@ -331,7 +332,7 @@ 256 - {{249, 83}, {100, 14}} + {{246, 99}, {100, 14}} YES @@ -347,7 +348,7 @@ 256 - {{357, 83}, {47, 14}} + {{354, 99}, {47, 14}} YES @@ -363,7 +364,7 @@ 256 - {{118, 109}, {579, 5}} + {{115, 125}, {582, 5}} {0, 0} @@ -385,7 +386,7 @@ 256 - {{17, 39}, {96, 14}} + {{14, 55}, {96, 14}} YES @@ -401,7 +402,7 @@ -2147483392 - {{122, 22}, {37, 14}} + {{119, 38}, {37, 14}} YES @@ -417,11 +418,11 @@ 256 - {{580, 76}, {122, 28}} + {{580, 95}, {122, 28}} YES - 67239424 + -2080244224 134348800 UGljdHVyZSBTZXR0aW5nc+KApg @@ -440,7 +441,7 @@ 256 - {{315, 61}, {34, 14}} + {{312, 77}, {34, 14}} YES @@ -456,7 +457,7 @@ 256 - {{357, 60}, {47, 14}} + {{354, 76}, {47, 14}} YES @@ -472,7 +473,7 @@ 256 - {{506, 63}, {56, 14}} + {{503, 79}, {56, 14}} YES @@ -488,7 +489,7 @@ 256 - {{506, 44}, {56, 14}} + {{503, 60}, {56, 14}} YES @@ -504,7 +505,7 @@ 256 - {{430, 83}, {68, 14}} + {{427, 99}, {68, 14}} YES @@ -520,7 +521,7 @@ 256 - {{506, 24}, {56, 14}} + {{503, 40}, {56, 14}} YES @@ -536,7 +537,7 @@ 256 - {{430, 24}, {68, 14}} + {{427, 40}, {68, 14}} YES @@ -552,7 +553,7 @@ 256 - {{506, 83}, {56, 14}} + {{503, 99}, {56, 14}} YES @@ -568,7 +569,7 @@ 256 - {{430, 63}, {68, 14}} + {{427, 79}, {68, 14}} YES @@ -584,7 +585,7 @@ 256 - {{430, 44}, {68, 14}} + {{427, 60}, {68, 14}} YES @@ -600,7 +601,7 @@ 256 - {{122, 83}, {99, 14}} + {{119, 99}, {99, 14}} YES @@ -616,7 +617,7 @@ 256 - {{122, 61}, {99, 14}} + {{119, 77}, {99, 14}} YES @@ -632,7 +633,7 @@ 256 - {{122, 39}, {155, 14}} + {{119, 55}, {155, 14}} YES @@ -851,7 +852,7 @@ 256 - {{506, 5}, {140, 14}} + {{503, 21}, {140, 14}} YES @@ -867,7 +868,7 @@ 256 - {{431, 1}, {68, 17}} + {{428, 17}, {68, 17}} YES @@ -882,7 +883,6 @@ {{10, 25}, {714, 305}} - Video @@ -891,7 +891,7 @@ 2 - + 256 YES @@ -2379,6 +2379,7 @@ {{10, 25}, {714, 305}} + QXVkaW8gJiBTdWJ0aXRsZXM @@ -2645,14 +2646,14 @@ - + 134217728 YES YES YES - + @@ -4019,8 +4020,8 @@ - {270, 550} - {50, 50} + {240, 550} + {100, 50} {280, 550} 2 0.000000e+00 @@ -4029,7 +4030,7 @@ - + 256 YES @@ -4134,6 +4135,7 @@ {{1, 1}, {247, 506}} + 4 @@ -4161,6 +4163,7 @@ {{4, 31}, {260, 508}} + 18 @@ -4292,6 +4295,7 @@ {270, 550} + NSView NSResponder @@ -6544,6 +6548,14 @@ 5139 + + + autoSetM4vExtension: + + + + 5152 + @@ -6679,7 +6691,6 @@ - @@ -6706,6 +6717,7 @@ + @@ -6891,37 +6903,37 @@ - - + + + + + + + - - - + - + + + - - - - - - - + + @@ -11015,10 +11027,10 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{40, 306}, {760, 550}} + {{231, 306}, {760, 550}} com.apple.InterfaceBuilder.CocoaPlugin - {{40, 306}, {760, 550}} + {{231, 306}, {760, 550}} {{65, 541}, {760, 550}} @@ -11376,7 +11388,7 @@ - 5151 + 5152 -- 2.11.0