diff --git a/data/locale/english.locale b/data/locale/english.locale index abb828ca6..ac1695e90 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -144,6 +144,8 @@ audiomenu.auto_lang Auto select audio audiomenu.auto_subs Auto select subtitles audiomenu.pref_lang_head Audio/EPG language preferences audiomenu.pref_lang Prefered language +audiomenu.pref_subs_head Subtitle language preferences +audiomenu.pref_subs Prefered subtitle language audioplayer.add Add audioplayer.artist_title Artist, Title audioplayer.building_search_index building search index diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index e1c19477e..64b1e8ba0 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -603,7 +603,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start widthl = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getRenderWidth(fromto); g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+40, sy+oy-3, widthl, fromto, COL_MENUHEAD); widthr = g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->getRenderWidth(epg_date); - g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+ox-40-widthr, sy+oy-3, widthr, epg_date, COL_MENUHEAD); + g_Font[SNeutrinoSettings::FONT_TYPE_EPG_DATE]->RenderString(sx+ox-40-widthr, sy+oy-3, widthr, epg_date, COL_MENUHEAD, 0, true); int showPos = 0; textCount = epgText.size(); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index d869a1a40..1208e5993 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -802,9 +802,12 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.audio_avs_Control = false; g_settings.auto_lang = configfile.getInt32( "auto_lang", 0 ); g_settings.auto_subs = configfile.getInt32( "auto_subs", 0 ); + for(int i = 0; i < 3; i++) { sprintf(cfg_key, "pref_lang_%d", i); strncpy(g_settings.pref_lang[i], configfile.getString(cfg_key, "").c_str(), 30); + sprintf(cfg_key, "pref_subs_%d", i); + strncpy(g_settings.pref_subs[i], configfile.getString(cfg_key, "").c_str(), 30); } g_settings.zap_cycle = configfile.getInt32( "zap_cycle", 1 ); g_settings.sms_channel = configfile.getInt32( "sms_channel", 0 ); @@ -1314,6 +1317,8 @@ void CNeutrinoApp::saveSetup(const char * fname) for(int i = 0; i < 3; i++) { sprintf(cfg_key, "pref_lang_%d", i); configfile.setString(cfg_key, g_settings.pref_lang[i]); + sprintf(cfg_key, "pref_subs_%d", i); + configfile.setString(cfg_key, g_settings.pref_subs[i]); } configfile.setString( "audio_PCMOffset", g_settings.audio_PCMOffset ); @@ -4874,10 +4879,10 @@ void CNeutrinoApp::SelectSubtitles() CZapitChannel * cc = channelList->getChannel(curnum); for(int i = 0; i < 3; i++) { - if(strlen(g_settings.pref_lang[i]) == 0) + if(strlen(g_settings.pref_subs[i]) == 0) continue; - std::string temp(g_settings.pref_lang[i]); + std::string temp(g_settings.pref_subs[i]); for(int j = 0 ; j < (int)cc->getSubtitleCount() ; j++) { CZapitAbsSub* s = cc->getChannelSub(j); diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 710392029..5e7916e46 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -1676,12 +1676,15 @@ void CNeutrinoApp::InitLanguageSettings(CMenuWidget &languageSettings) // languageSettings.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_PREF_LANG_HEAD)); + //audioSettings.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_PREF_LANG_HEAD)); CMenuWidget * prefMenu = new CMenuWidget(LOCALE_AUDIOMENU_PREF_LANG, NEUTRINO_ICON_LANGUAGE); - addMenueIntroItems(*prefMenu); + //addMenueIntroItems(*prefMenu); + prefMenu->addItem(GenericMenuSeparator); + prefMenu->addItem(GenericMenuBack); + prefMenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_PREF_LANG_HEAD)); prefMenu->addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AUTO_LANG, &g_settings.auto_lang, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL)); - prefMenu->addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AUTO_SUBS, &g_settings.auto_subs, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL)); CLangSelectNotifier * langNotifier = new CLangSelectNotifier(); for(int i = 0; i < 3; i++) { @@ -1692,6 +1695,18 @@ void CNeutrinoApp::InitLanguageSettings(CMenuWidget &languageSettings) } prefMenu->addItem(langSelect); } + + prefMenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_PREF_SUBS_HEAD)); + prefMenu->addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AUTO_SUBS, &g_settings.auto_subs, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, NULL)); + for(int i = 0; i < 3; i++) { + CMenuOptionStringChooser * langSelect = new CMenuOptionStringChooser(LOCALE_AUDIOMENU_PREF_SUBS, g_settings.pref_subs[i], true, NULL, CRCInput::RC_nokey, "", true); + std::map::const_iterator it; + for(it = iso639rev.begin(); it != iso639rev.end(); it++) { + langSelect->addOption(it->first.c_str()); + } + prefMenu->addItem(langSelect); + } + languageSettings.addItem(new CMenuForwarder(LOCALE_AUDIOMENU_PREF_LANG_HEAD, true, NULL, prefMenu, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW)); langNotifier->changeNotify(NONEXISTANT_LOCALE, NULL); } diff --git a/src/system/localize.cpp b/src/system/localize.cpp index 3f8cbb5fb..824d5d120 100644 --- a/src/system/localize.cpp +++ b/src/system/localize.cpp @@ -173,6 +173,12 @@ CLocaleManager::CLocaleManager() localeData = new char * [sizeof(locale_real_names)/sizeof(const char *)]; for (unsigned int i = 0; i < (sizeof(locale_real_names)/sizeof(const char *)); i++) localeData[i] = (char *)locale_real_names[i]; + + defaultData = new char * [sizeof(locale_real_names)/sizeof(const char *)]; + for (unsigned int i = 0; i < (sizeof(locale_real_names)/sizeof(const char *)); i++) + defaultData[i] = (char *)locale_real_names[i]; + + loadLocale("english", true); } CLocaleManager::~CLocaleManager() @@ -186,10 +192,11 @@ CLocaleManager::~CLocaleManager() const char * path[2] = {"/var/tuxbox/config/locale/", DATADIR "/neutrino/locale/"}; -CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const locale) +CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const locale, bool asdefault) { unsigned int i; FILE * fd; + char ** loadData = asdefault ? defaultData : localeData; //initialize_iso639_map(); @@ -210,12 +217,15 @@ CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const l return NO_SUCH_LOCALE; } - for (unsigned j = 0; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) - if (localeData[j] != locale_real_names[j]) - { - free(localeData[j]); - localeData[j] = (char *)locale_real_names[j]; + if(!asdefault) { + for (unsigned j = 0; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) { + if (loadData[j] != locale_real_names[j] && loadData[j] != defaultData[j]) + { + free(loadData[j]); + } + loadData[j] = (char *)locale_real_names[j]; } + } char buf[1000]; @@ -258,8 +268,8 @@ CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const l //printf("[%s] [%s]\n", buf,locale_real_names[i]); if(!strcmp(buf,locale_real_names[i])) { - if(localeData[i] == locale_real_names[i]) - localeData[i] = strdup(text.c_str()); + if(loadData[i] == locale_real_names[i]) + loadData[i] = strdup(text.c_str()); else printf("[%s.locale] dup entry: %s\n", locale, locale_real_names[i]); break; @@ -295,9 +305,11 @@ CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const l } fclose(fd); for (unsigned j = 1; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) - if (localeData[j] == locale_real_names[j]) + if (loadData[j] == locale_real_names[j]) { printf("[%s.locale] missing entry: %s\n", locale, locale_real_names[j]); + if(!asdefault) + loadData[j] = defaultData[j]; } return ( diff --git a/src/system/localize.h b/src/system/localize.h index 6e90cb5fe..9ed137ba5 100644 --- a/src/system/localize.h +++ b/src/system/localize.h @@ -50,6 +50,7 @@ class CLocaleManager { private: char * * localeData; + char * * defaultData; public: enum loadLocale_ret_t @@ -62,7 +63,7 @@ class CLocaleManager CLocaleManager(); ~CLocaleManager(); - loadLocale_ret_t loadLocale(const char * const locale); + loadLocale_ret_t loadLocale(const char * const locale, bool asdefault = false); const char * getText(const neutrino_locale_t keyName) const; diff --git a/src/system/locals.h b/src/system/locals.h index d5d0405a3..a976cb451 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -151,6 +151,8 @@ typedef enum { LOCALE_AUDIOMENU_AUTO_SUBS, LOCALE_AUDIOMENU_PREF_LANG_HEAD, LOCALE_AUDIOMENU_PREF_LANG, + LOCALE_AUDIOMENU_PREF_SUBS_HEAD, + LOCALE_AUDIOMENU_PREF_SUBS, LOCALE_AUDIOPLAYER_ADD, LOCALE_AUDIOPLAYER_ADD_IC, LOCALE_AUDIOPLAYER_ADD_LOC, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 9e1636a6e..0c70f856c 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -151,6 +151,8 @@ const char *locale_real_names[] = { "audiomenu.auto_subs", "audiomenu.pref_lang_head", "audiomenu.pref_lang", + "audiomenu.pref_subs_head", + "audiomenu.pref_subs", "audioplayer.add", "audioplayer.add_ic", "audioplayer.add_loc", diff --git a/src/system/settings.h b/src/system/settings.h index 07fd85ed8..203c046da 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -99,6 +99,7 @@ struct SNeutrinoSettings char timezone[150]; char pref_lang[3][30]; + char pref_subs[3][30]; // EPG int epg_save;