From 4b37c7f861efbf2e31685ffaba80f3e923a8a6c8 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Tue, 20 Jul 2010 15:47:16 +0000 Subject: [PATCH] * Remove direct access to ICU in locale preflet, use the locale kit instead. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37619 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/locale/LocaleRoster.h | 7 +++-- src/preferences/locale/Jamfile | 9 ++----- src/preferences/locale/LocaleWindow.cpp | 26 ++++++++++++++----- .../locale/TimeFormatSettingsView.cpp | 6 ++--- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/headers/os/locale/LocaleRoster.h b/headers/os/locale/LocaleRoster.h index 8f71ada3fb..895f435991 100644 --- a/headers/os/locale/LocaleRoster.h +++ b/headers/os/locale/LocaleRoster.h @@ -23,6 +23,7 @@ namespace BPrivate { class EditableCatalog; } + enum { B_LOCALE_CHANGED = '_LCC', }; @@ -33,16 +34,14 @@ class BLocaleRoster { BLocaleRoster(); ~BLocaleRoster(); -// status_t GetLocaleFor(const char *langCode, const char *countryCode); - status_t GetSystemCatalog(BCatalogAddOn **) const; status_t GetDefaultCollator(BCollator **) const; status_t GetDefaultLanguage(BLanguage **) const; status_t GetDefaultCountry(BCountry **) const; void SetDefaultCountry(BCountry *) const; - status_t GetLanguage(const char* languageCode, - BLanguage** _language) const; + status_t GetLanguage(const char* languageCode, BLanguage** _language) + const; status_t GetPreferredLanguages(BMessage *) const; status_t SetPreferredLanguages(BMessage *); diff --git a/src/preferences/locale/Jamfile b/src/preferences/locale/Jamfile index 0fcb4cb5db..dcb13555c9 100644 --- a/src/preferences/locale/Jamfile +++ b/src/preferences/locale/Jamfile @@ -11,15 +11,10 @@ local sources = TimeFormatSettingsView.cpp ; -SubDirSysHdrs $(HAIKU_ICU_HEADERS) ; -Includes [ FGristFiles $(sources) ] : $(HAIKU_ICU_HEADERS_DEPENDENCY) ; - # Dependency needed to trigger downloading/unzipping the package before - # compiling the files. - Preference Locale : $(sources) - : be $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) - libshared.a $(HAIKU_LOCALE_LIBS) $(HAIKU_ICU_LIBS) + : be $(TARGET_LIBSTDC++) $(TARGET_LIBSUPC++) libshared.a + $(HAIKU_LOCALE_LIBS) : Locale.rdef ; diff --git a/src/preferences/locale/LocaleWindow.cpp b/src/preferences/locale/LocaleWindow.cpp index 7aab0d2383..ed535fcfea 100644 --- a/src/preferences/locale/LocaleWindow.cpp +++ b/src/preferences/locale/LocaleWindow.cpp @@ -26,11 +26,6 @@ #include #include -#include - -#include -#include - #include "TimeFormatSettingsView.h" @@ -176,6 +171,25 @@ LocaleWindow::LocaleWindow() // get all available countries from ICU // Use DateFormat::getAvailableLocale so we get only the one we can // use. Maybe check the NumberFormat one and see if there is more. + BMessage countryList; + be_locale_roster->GetInstalledLanguages(&countryList); + BString countryCode; + + for (int i = 0; countryList.FindString("langs", i, &countryCode) == B_OK; + i++) { + BCountry country(countryCode); + BString countryName; + + country.Name(countryName); + + LanguageListItem* item + = new LanguageListItem(countryName, countryCode, + NULL); + listView->AddItem(item); + if (!strcmp(countryCode, defaultCountry->Code())) + listView->Select(listView->CountItems() - 1); + } + /* int32_t localeCount; const Locale* currentLocale = Locale::getAvailableLocales(localeCount); @@ -192,7 +206,7 @@ LocaleWindow::LocaleWindow() listView->AddItem(item); if (!strcmp(currentLocale[index].getName(), defaultCountry->Code())) listView->Select(listView->CountItems() - 1); - } + }*/ // TODO: find a real solution intead of this hack listView->SetExplicitMinSize( diff --git a/src/preferences/locale/TimeFormatSettingsView.cpp b/src/preferences/locale/TimeFormatSettingsView.cpp index fc41f2cf4f..77498cdac1 100644 --- a/src/preferences/locale/TimeFormatSettingsView.cpp +++ b/src/preferences/locale/TimeFormatSettingsView.cpp @@ -30,8 +30,6 @@ #include #include -#include - #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "TimeFormatSettings" @@ -613,10 +611,10 @@ FormatView::_UpdateExamples() fShortTimeExampleView->SetText(timeFormat); status_t Error = fCountry->FormatNumber(&timeFormat, 1234.5678); - if (Error == U_ZERO_ERROR) + if (Error == B_OK) fNumberFormatExampleView->SetText(timeFormat); else - fNumberFormatExampleView->SetText(u_errorName((UErrorCode)Error)); + fNumberFormatExampleView->SetText("ERROR"); }