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