diff options
author | eddyg <[email protected]> | 2007-08-27 03:46:08 +0000 |
---|---|---|
committer | eddyg <[email protected]> | 2007-08-27 03:46:08 +0000 |
commit | b399b95c674157b268c56b11064ad4874fde0ec7 (patch) | |
tree | dc44339e709c1d39dc3218c7d2aca16989775424 | |
parent | 62f2a3809bd4eb9cbacdacc7aa969976a61eeccd (diff) |
Added support to the mac gui for auto-selecting subtitles if the main audio language is not in your native language (via the new preferences box).
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@872 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/lang.h | 15 | ||||
-rw-r--r-- | macosx/Controller.mm | 32 |
2 files changed, 45 insertions, 2 deletions
diff --git a/libhb/lang.h b/libhb/lang.h index a1cab4d32..8b6283b4d 100644 --- a/libhb/lang.h +++ b/libhb/lang.h @@ -224,4 +224,19 @@ static iso639_lang_t * lang_for_code( int code ) return (iso639_lang_t*) languages; } +static iso639_lang_t * lang_for_english( const char * english ) +{ + iso639_lang_t * lang; + + for( lang = (iso639_lang_t*) languages; lang->eng_name; lang++ ) + { + if( !strcmp( lang->eng_name, english ) ) + { + return lang; + } + } + + return (iso639_lang_t*) languages; +} + #endif diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 4e281b388..18aa65d1c 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -6,6 +6,7 @@ #include "Controller.h" #include "a52dec/a52.h" +#include "lang.h" #import "HBOutputPanelController.h" #import "HBPreferencesController.h" @@ -1421,7 +1422,25 @@ list = hb_get_titles( fHandle ); job->grayscale = ( [fVidGrayscaleCheck state] == NSOnState ); - + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PreferredLanguageSubtitles"] == 1) + { + /* + * This user prefers to have subtitles when the default language + * is not their own. So set the native language seleector to their + * language. + * + * Unfortunatly for us the language in the GUI is not in the + * right ISO-639-3 format that native_language expects. + */ + NSString * language = [[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"]; + iso639_lang_t *lang_code = lang_for_english( [ language cString ] ); + if( lang_code ) + { + job->native_language = lang_code->iso639_2; + } else { + job->native_language = NULL; + } + } /* Subtitle settings */ job->subtitle = [fSubPopUp indexOfSelectedItem] - 2; @@ -1869,7 +1888,16 @@ list = hb_get_titles( fHandle ); [self addAllAudioTracksToPopUp: fAudLang2PopUp]; /* search for the first instance of our prefs default language for track 1, and set track 2 to "none" */ NSString * audioSearchPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"]; - [self selectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: audioSearchPrefix selectIndexIfNotFound: 1]; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PreferredLanguageSubtitles"] != 1) + { + [self selectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: audioSearchPrefix selectIndexIfNotFound: 1]; + } else { + /* + * We prefer to have subtitles and not change the audio language from the + * default (first one). + */ + [self selectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: NULL selectIndexIfNotFound: 1]; + } [self selectAudioTrackInPopUp: fAudLang2PopUp searchPrefixString: NULL selectIndexIfNotFound: 0]; /* changing the title may have changed the audio channels on offer, */ |