* removed all BLocale-related getters from BLocaleRoster - they're available

in BLocale (which is accessible via be_locale)
* adjusted all users accordingly


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38459 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2010-08-30 19:58:19 +00:00
parent 9910e4f1bf
commit b7f609650b
14 changed files with 57 additions and 130 deletions
-4
View File
@@ -28,10 +28,6 @@ public:
BLocaleRoster(); BLocaleRoster();
~BLocaleRoster(); ~BLocaleRoster();
status_t GetDefaultCollator(BCollator* collator) const;
status_t GetDefaultLanguage(BLanguage* language) const;
status_t GetDefaultCountry(BCountry* country) const;
status_t GetDefaultLocale(BLocale* locale) const;
status_t GetDefaultTimeZone(BTimeZone* timezone) const; status_t GetDefaultTimeZone(BTimeZone* timezone) const;
status_t GetLanguage(const char* languageCode, status_t GetLanguage(const char* languageCode,
@@ -33,6 +33,8 @@ public:
MutableLocaleRoster(); MutableLocaleRoster();
~MutableLocaleRoster(); ~MutableLocaleRoster();
status_t GetDefaultLocale(BLocale* locale) const;
status_t SetDefaultCountry(const BCountry& country); status_t SetDefaultCountry(const BCountry& country);
status_t SetDefaultLocale(const BLocale& locale); status_t SetDefaultLocale(const BLocale& locale);
status_t SetDefaultTimeZone(const BTimeZone& zone); status_t SetDefaultTimeZone(const BTimeZone& zone);
+2 -4
View File
@@ -196,7 +196,7 @@ TranslationComparator(const void* left, const void* right)
rightName = rightTranslation->languageCode; rightName = rightTranslation->languageCode;
BCollator collator; BCollator collator;
be_locale_roster->GetDefaultCollator(&collator); be_locale->GetCollator(&collator);
return collator.Compare(leftName.String(), rightName.String()); return collator.Compare(leftName.String(), rightName.String());
} }
@@ -1114,9 +1114,7 @@ AboutView::_CreateCreditsView()
fCreditsView->Insert(langName); fCreditsView->Insert(langName);
fCreditsView->Insert("\n"); fCreditsView->Insert("\n");
fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey); fCreditsView->SetFontAndColor(be_plain_font, B_FONT_ALL, &kDarkGrey);
fCreditsView->Insert( fCreditsView->Insert(translation.names);
translation.names
);
} }
fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange); fCreditsView->SetFontAndColor(&font, B_FONT_ALL, &kHaikuOrange);
+1 -4
View File
@@ -13,7 +13,6 @@
#include <GroupLayoutBuilder.h> #include <GroupLayoutBuilder.h>
#include <GroupView.h> #include <GroupView.h>
#include <Locale.h> #include <Locale.h>
#include <LocaleRoster.h>
#include <Screen.h> #include <Screen.h>
#include <SpaceLayoutItem.h> #include <SpaceLayoutItem.h>
#include <String.h> #include <String.h>
@@ -89,10 +88,8 @@ CalendarMenuWindow::CalendarMenuWindow(BPoint where)
fCalendarView(NULL), fCalendarView(NULL),
fSuppressFirstClose(true) fSuppressFirstClose(true)
{ {
BLocale locale;
be_locale_roster->GetDefaultLocale(&locale);
BPrivate::week_start startOfWeek BPrivate::week_start startOfWeek
= (BPrivate::week_start)locale.StartOfWeek(); = (BPrivate::week_start)be_locale->StartOfWeek();
RemoveShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY); RemoveShortcut('H', B_COMMAND_KEY | B_CONTROL_KEY);
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
+3 -4
View File
@@ -41,7 +41,6 @@ All rights reserved.
#include <Country.h> #include <Country.h>
#include <Debug.h> #include <Debug.h>
#include <Locale.h> #include <Locale.h>
#include <LocaleRoster.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include <PopUpMenu.h> #include <PopUpMenu.h>
@@ -91,7 +90,7 @@ TTimeView::TTimeView(float maxWidth, float height, bool showSeconds,
fLastDateStr[0] = 0; fLastDateStr[0] = 0;
fNeedToUpdate = true; fNeedToUpdate = true;
be_locale_roster->GetDefaultLocale(&fLocale); fLocale = *be_locale;
} }
@@ -105,7 +104,7 @@ TTimeView::TTimeView(BMessage* data)
data->FindBool("interval", &fInterval); data->FindBool("interval", &fInterval);
fShowingDate = false; fShowingDate = false;
be_locale_roster->GetDefaultCountry(&fLocale); fLocale = *be_locale;
} }
#endif #endif
@@ -461,7 +460,7 @@ TTimeView::AllowFullDate(bool allow)
void void
TTimeView::Update() TTimeView::Update()
{ {
be_locale_roster->GetDefaultLocale(&fLocale); fLocale = *be_locale;
GetCurrentTime(); GetCurrentTime();
GetCurrentDate(); GetCurrentDate();
+1 -5
View File
@@ -9,7 +9,6 @@
#include <Catalog.h> #include <Catalog.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <Locale.h> #include <Locale.h>
#include <LocaleRoster.h>
#include <MessageRunner.h> #include <MessageRunner.h>
#include <Roster.h> #include <Roster.h>
#include <String.h> #include <String.h>
@@ -84,10 +83,7 @@ TimedAlert::GetLabel(BString &string)
time(&t); time(&t);
localtime_r(&t, &tm); localtime_r(&t, &tm);
BLocale here; be_locale->FormatTime(timestring, 15, t, false);
be_locale_roster->GetDefaultLocale(&here);
here.FormatTime(timestring, 15, t, false);
string += " "; string += " ";
string += timestring; string += timestring;
-64
View File
@@ -78,70 +78,6 @@ BLocaleRoster::Refresh()
} }
status_t
BLocaleRoster::GetDefaultCollator(BCollator* collator) const
{
if (!collator)
return B_BAD_VALUE;
BAutolock lock(gRosterData.fLock);
if (!lock.IsLocked())
return B_ERROR;
gRosterData.fDefaultLocale.GetCollator(collator);
return B_OK;
}
status_t
BLocaleRoster::GetDefaultLanguage(BLanguage* language) const
{
if (!language)
return B_BAD_VALUE;
BAutolock lock(gRosterData.fLock);
if (!lock.IsLocked())
return B_ERROR;
gRosterData.fDefaultLocale.GetLanguage(language);
return B_OK;
}
status_t
BLocaleRoster::GetDefaultCountry(BCountry* country) const
{
if (!country)
return B_BAD_VALUE;
BAutolock lock(gRosterData.fLock);
if (!lock.IsLocked())
return B_ERROR;
gRosterData.fDefaultLocale.GetCountry(country);
return B_OK;
}
status_t
BLocaleRoster::GetDefaultLocale(BLocale* locale) const
{
if (!locale)
return B_BAD_VALUE;
BAutolock lock(gRosterData.fLock);
if (!lock.IsLocked())
return B_ERROR;
*locale = gRosterData.fDefaultLocale;
return B_OK;
}
status_t status_t
BLocaleRoster::GetDefaultTimeZone(BTimeZone* timezone) const BLocaleRoster::GetDefaultTimeZone(BTimeZone* timezone) const
{ {
+25
View File
@@ -555,6 +555,15 @@ RosterData::_SetDefaultCountry(const BCountry& newCountry)
{ {
fDefaultLocale.SetCountry(newCountry); fDefaultLocale.SetCountry(newCountry);
UErrorCode icuError = U_ZERO_ERROR;
Locale icuLocale = Locale::createCanonical(newCountry.Code());
if (icuLocale.isBogus())
return B_ERROR;
Locale::setDefault(icuLocale, icuError);
if (!U_SUCCESS(icuError))
return B_ERROR;
return B_OK; return B_OK;
} }
@@ -709,6 +718,22 @@ MutableLocaleRoster::SetPreferredLanguages(const BMessage* languages)
} }
status_t
MutableLocaleRoster::GetDefaultLocale(BLocale* locale) const
{
if (!locale)
return B_BAD_VALUE;
BAutolock lock(gRosterData.fLock);
if (!lock.IsLocked())
return B_ERROR;
*locale = gRosterData.fDefaultLocale;
return B_OK;
}
status_t status_t
MutableLocaleRoster::GetSystemCatalog(BCatalogAddOn** catalog) const MutableLocaleRoster::GetSystemCatalog(BCatalogAddOn** catalog) const
{ {
+5 -9
View File
@@ -215,7 +215,7 @@ TruncFileSizeBase(BString *result, int64 value, const View *view, float width)
// ToDo: // ToDo:
// if slow, replace float divisions with shifts // if slow, replace float divisions with shifts
// if fast enough, try fitting more decimal places // if fast enough, try fitting more decimal places
// TODO: reuse libshared's string_for_size // TODO: reuse libshared's string_for_size
// format file size value // format file size value
@@ -292,15 +292,11 @@ TruncTimeBase(BString *result, int64 value, const View *view, float width)
time_t timeValue = (time_t)value; time_t timeValue = (time_t)value;
BLocale here; if (be_locale->FormatDateTime(buffer, 256, timeValue, true) == B_OK)
be_locale_roster->GetDefaultLocale(&here);
if (here.FormatDateTime(buffer, 256, timeValue, true) == B_OK) {
resultWidth = view->StringWidth(buffer); resultWidth = view->StringWidth(buffer);
}
if (resultWidth > width
if (resultWidth > width && here.FormatDateTime(buffer, 256, timeValue, && be_locale->FormatDateTime(buffer, 256, timeValue, false) == B_OK) {
false) == B_OK) {
resultWidth = view->StringWidth(buffer); resultWidth = view->StringWidth(buffer);
} }
@@ -503,9 +503,7 @@ FormatView::SetDefaults()
settings.SetClockTo24Hr(false); settings.SetClockTo24Hr(false);
*/ */
BLocale defaultLocale; fLocale = *be_locale;
be_locale_roster->GetDefaultLocale(&defaultLocale);
fLocale = defaultLocale;
// We work on a copy of the default country and set the changes when // We work on a copy of the default country and set the changes when
// closing the preflet // closing the preflet
_UpdateExamples(); _UpdateExamples();
+5 -7
View File
@@ -78,32 +78,30 @@ LocaleSettings::UpdateFrom(BMessage* message)
gMutableLocaleRoster->SetPreferredLanguages(message); gMutableLocaleRoster->SetPreferredLanguages(message);
} }
BLocale defaultLocale; BLocale locale(*be_locale);
gMutableLocaleRoster->GetDefaultLocale(&defaultLocale);
bool countryChanged = false; bool countryChanged = false;
if (message->FindString("country", &messageContent) == B_OK) { if (message->FindString("country", &messageContent) == B_OK) {
fMessage.ReplaceString("country", messageContent); fMessage.ReplaceString("country", messageContent);
fMessage.RemoveName("shortTimeFormat"); fMessage.RemoveName("shortTimeFormat");
fMessage.RemoveName("longTimeFormat"); fMessage.RemoveName("longTimeFormat");
defaultLocale = BLocale(messageContent.String()); locale = BLocale(messageContent.String());
countryChanged = true; countryChanged = true;
} }
if (message->FindString("shortTimeFormat", &messageContent) == B_OK) { if (message->FindString("shortTimeFormat", &messageContent) == B_OK) {
fMessage.RemoveName("shortTimeFormat"); fMessage.RemoveName("shortTimeFormat");
fMessage.AddString("shortTimeFormat", messageContent); fMessage.AddString("shortTimeFormat", messageContent);
defaultLocale.SetTimeFormat(messageContent, false); locale.SetTimeFormat(messageContent, false);
countryChanged = true; countryChanged = true;
} }
if (message->FindString("longTimeFormat", &messageContent) == B_OK) { if (message->FindString("longTimeFormat", &messageContent) == B_OK) {
fMessage.RemoveName("longTimeFormat"); fMessage.RemoveName("longTimeFormat");
fMessage.AddString("longTimeFormat", messageContent); fMessage.AddString("longTimeFormat", messageContent);
defaultLocale.SetTimeFormat(messageContent, true); locale.SetTimeFormat(messageContent, true);
countryChanged = true; countryChanged = true;
} }
if (countryChanged) if (countryChanged)
gMutableLocaleRoster->SetDefaultLocale(defaultLocale); gMutableLocaleRoster->SetDefaultLocale(locale);
} }
+2 -5
View File
@@ -76,9 +76,6 @@ LocaleWindow::LocaleWindow()
BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE
| B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{ {
BLocale defaultLocale;
be_locale_roster->GetDefaultLocale(&defaultLocale);
SetLayout(new BGroupLayout(B_HORIZONTAL)); SetLayout(new BGroupLayout(B_HORIZONTAL));
float spacing = be_control_look->DefaultItemSpacing(); float spacing = be_control_look->DefaultItemSpacing();
@@ -199,7 +196,7 @@ LocaleWindow::LocaleWindow()
= new LanguageListItem(countryName, countryCode, = new LanguageListItem(countryName, countryCode,
NULL); NULL);
listView->AddItem(item); listView->AddItem(item);
if (!strcmp(countryCode, defaultLocale.Code())) if (!strcmp(countryCode, be_locale->Code()))
currentItem = item; currentItem = item;
} }
@@ -211,7 +208,7 @@ LocaleWindow::LocaleWindow()
listView->SetExplicitMinSize( listView->SetExplicitMinSize(
BSize(25 * be_plain_font->Size(), B_SIZE_UNSET)); BSize(25 * be_plain_font->Size(), B_SIZE_UNSET));
fFormatView = new FormatView(defaultLocale); fFormatView = new FormatView(*be_locale);
countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, spacing) countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, spacing)
.AddGroup(B_VERTICAL, 3) .AddGroup(B_VERTICAL, 3)
+4 -11
View File
@@ -17,7 +17,6 @@
#include <List.h> #include <List.h>
#include <Locale.h> #include <Locale.h>
#include <LocaleRoster.h>
#include <String.h> #include <String.h>
#include <Window.h> #include <Window.h>
@@ -277,12 +276,9 @@ TTimeEdit::BuildDispatch(BMessage* message)
void void
TTimeEdit::_UpdateFields() TTimeEdit::_UpdateFields()
{ {
BLocale locale;
be_locale_roster->GetDefaultLocale(&locale);
time_t time = fTime.Time_t(); time_t time = fTime.Time_t();
locale.FormatTime(&fText, fFieldPositions, fFieldPosCount, time, true); be_locale->FormatTime(&fText, fFieldPositions, fFieldPosCount, time, true);
locale.GetTimeFields(fFields, fFieldCount, true); be_locale->GetTimeFields(fFields, fFieldCount, true);
} }
@@ -678,12 +674,9 @@ TDateEdit::BuildDispatch(BMessage* message)
void void
TDateEdit::_UpdateFields() TDateEdit::_UpdateFields()
{ {
BLocale locale;
be_locale_roster->GetDefaultLocale(&locale);
time_t time = BDateTime(fDate, BTime()).Time_t(); time_t time = BDateTime(fDate, BTime()).Time_t();
locale.FormatDate(&fText, fFieldPositions, fFieldPosCount, time, false); be_locale->FormatDate(&fText, fFieldPositions, fFieldPosCount, time, false);
locale.GetDateFields(fFields, fFieldCount, false); be_locale->GetDateFields(fFields, fFieldCount, false);
} }
+6 -10
View File
@@ -183,13 +183,11 @@ TimeZoneView::GetToolTipAt(BPoint point, BToolTip** _tip)
return false; return false;
BString nowInTimeZone; BString nowInTimeZone;
BLocale locale;
be_locale_roster->GetDefaultLocale(&locale);
time_t now = time(NULL); time_t now = time(NULL);
locale.FormatTime(&nowInTimeZone, now, false, &item->TimeZone()); be_locale->FormatTime(&nowInTimeZone, now, false, &item->TimeZone());
BString dateInTimeZone; BString dateInTimeZone;
locale.FormatDate(&dateInTimeZone, now, false, &item->TimeZone()); be_locale->FormatDate(&dateInTimeZone, now, false, &item->TimeZone());
BString toolTip = item->Text(); BString toolTip = item->Text();
toolTip << '\n' << item->TimeZone().ShortName() << " / " toolTip << '\n' << item->TimeZone().ShortName() << " / "
@@ -278,8 +276,8 @@ TimeZoneView::_BuildZoneMenu()
BTimeZone defaultTimeZone; BTimeZone defaultTimeZone;
be_locale_roster->GetDefaultTimeZone(&defaultTimeZone); be_locale_roster->GetDefaultTimeZone(&defaultTimeZone);
BLanguage defaultLanguage; BLanguage language;
be_locale_roster->GetDefaultLanguage(&defaultLanguage); be_locale->GetLanguage(&language);
BMessage countryList; BMessage countryList;
be_locale_roster->GetAvailableCountries(&countryList); be_locale_roster->GetAvailableCountries(&countryList);
@@ -352,7 +350,7 @@ TimeZoneView::_BuildZoneMenu()
zoneMap[region] = regionItem; zoneMap[region] = regionItem;
} }
BTimeZone* timeZone = new BTimeZone(zoneID, &defaultLanguage); BTimeZone* timeZone = new BTimeZone(zoneID, &language);
BString tzName = timeZone->Name(); BString tzName = timeZone->Name();
if (tzName == "GMT+00:00") if (tzName == "GMT+00:00")
tzName = "GMT"; tzName = "GMT";
@@ -524,8 +522,6 @@ TimeZoneView::_FormatTime(const BTimeZone& timeZone)
{ {
BString result; BString result;
BLocale locale;
be_locale_roster->GetDefaultLocale(&locale);
time_t now = time(NULL); time_t now = time(NULL);
bool rtcIsGMT; bool rtcIsGMT;
_kern_get_real_time_clock_is_gmt(&rtcIsGMT); _kern_get_real_time_clock_is_gmt(&rtcIsGMT);
@@ -536,7 +532,7 @@ TimeZoneView::_FormatTime(const BTimeZone& timeZone)
: 0; : 0;
now -= timeZone.OffsetFromGMT() - currentOffset; now -= timeZone.OffsetFromGMT() - currentOffset;
} }
locale.FormatTime(&result, now, false, &timeZone); be_locale->FormatTime(&result, now, false, &timeZone);
return result; return result;
} }