Localization support for filesystem entries in Tracker and Deskbar (leaf menu). (It appears to work, but is likely incomplete and quite possibly incorrect.) Fix issue with RosterData::Refresh() resulting in a B_LOCALE_CHANGED broadcast, and Deskbar looping. Add a global boolean gLocalizedNamePreferred to avoid calling BLocaleRoster::Default()->IsFilesystemTranslationPreferred() too often from Model instances. Following Tracker code style in libtracker, so as to not mix in too much clean-up.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40922 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -154,6 +154,8 @@ private:
|
||||
const BFormattingConventions& conventions);
|
||||
status_t _SetDefaultTimeZone(const BTimeZone& zone);
|
||||
status_t _SetPreferredLanguages(const BMessage* msg);
|
||||
void _SetFilesystemTranslationPreferred(
|
||||
bool preferred);
|
||||
|
||||
status_t _AddDefaultFormattingConventionsToMessage(
|
||||
BMessage* message) const;
|
||||
|
||||
@@ -61,6 +61,7 @@ All rights reserved.
|
||||
#include "PublicCommands.h"
|
||||
#include "ResourceSet.h"
|
||||
#include "Switcher.h"
|
||||
#include "Utilities.h"
|
||||
|
||||
|
||||
BLocker TBarApp::sSubscriberLock;
|
||||
@@ -96,6 +97,9 @@ TBarApp::TBarApp()
|
||||
|
||||
be_roster->StartWatching(this);
|
||||
|
||||
gLocalizedNamePreferred
|
||||
= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();
|
||||
|
||||
sBarTeamInfoList.MakeEmpty();
|
||||
|
||||
BList teamList;
|
||||
@@ -496,6 +500,10 @@ TBarApp::MessageReceived(BMessage* message)
|
||||
{
|
||||
BLocaleRoster::Default()->Refresh();
|
||||
|
||||
bool localize;
|
||||
if (message->FindBool("filesys", &localize) == B_OK)
|
||||
gLocalizedNamePreferred = localize;
|
||||
|
||||
BMessenger(fBarWindow->FindView("_deskbar_tv_")).SendMessage(
|
||||
message);
|
||||
// Notify the TimeView that the format has changed and it should
|
||||
@@ -611,8 +619,7 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
||||
BAppFileInfo appMime(&file);
|
||||
|
||||
BString name;
|
||||
if (!BLocaleRoster::Default()->IsFilesystemTranslationPreferred()
|
||||
|| GetLocalizedFileName(*ref, name) != B_OK)
|
||||
if (!gLocalizedNamePreferred || GetLocalizedFileName(*ref, name) != B_OK)
|
||||
name = ref->name;
|
||||
|
||||
BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
||||
|
||||
@@ -306,7 +306,7 @@ RosterData::SetFilesystemTranslationPreferred(bool preferred)
|
||||
if (!lock.IsLocked())
|
||||
return B_ERROR;
|
||||
|
||||
fIsFilesystemTranslationPreferred = preferred;
|
||||
_SetFilesystemTranslationPreferred(preferred);
|
||||
|
||||
status_t status = _SaveLocaleSettings();
|
||||
|
||||
@@ -510,7 +510,7 @@ RosterData::_LoadLocaleSettings()
|
||||
|
||||
bool preferred;
|
||||
if (settings.FindBool(kTranslateFilesystemField, &preferred) == B_OK)
|
||||
SetFilesystemTranslationPreferred(preferred);
|
||||
_SetFilesystemTranslationPreferred(preferred);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
@@ -672,6 +672,13 @@ RosterData::_SetPreferredLanguages(const BMessage* languages)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RosterData::_SetFilesystemTranslationPreferred(bool preferred)
|
||||
{
|
||||
fIsFilesystemTranslationPreferred = preferred;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RosterData::_AddDefaultFormattingConventionsToMessage(BMessage* message) const
|
||||
{
|
||||
|
||||
@@ -95,7 +95,8 @@ Model::Model()
|
||||
fIconFrom(kUnknownSource),
|
||||
fWritable(false),
|
||||
fNode(NULL),
|
||||
fStatus(B_NO_INIT)
|
||||
fStatus(B_NO_INIT),
|
||||
fHasLocalizedName(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -108,7 +109,9 @@ Model::Model(const Model &cloneThis)
|
||||
fBaseType(cloneThis.fBaseType),
|
||||
fIconFrom(cloneThis.fIconFrom),
|
||||
fWritable(false),
|
||||
fNode(NULL)
|
||||
fNode(NULL),
|
||||
fLocalizedName(cloneThis.fLocalizedName),
|
||||
fHasLocalizedName(cloneThis.fHasLocalizedName)
|
||||
{
|
||||
fStatBuf.st_dev = cloneThis.NodeRef()->device;
|
||||
fStatBuf.st_ino = cloneThis.NodeRef()->node;
|
||||
@@ -133,7 +136,8 @@ Model::Model(const node_ref *dirNode, const node_ref *node, const char *name,
|
||||
:
|
||||
fPreferredAppName(NULL),
|
||||
fWritable(false),
|
||||
fNode(NULL)
|
||||
fNode(NULL),
|
||||
fHasLocalizedName(false)
|
||||
{
|
||||
SetTo(dirNode, node, name, open, writable);
|
||||
}
|
||||
@@ -143,7 +147,8 @@ Model::Model(const BEntry *entry, bool open, bool writable)
|
||||
:
|
||||
fPreferredAppName(NULL),
|
||||
fWritable(false),
|
||||
fNode(NULL)
|
||||
fNode(NULL),
|
||||
fHasLocalizedName(false)
|
||||
{
|
||||
SetTo(entry, open, writable);
|
||||
}
|
||||
@@ -155,7 +160,8 @@ Model::Model(const entry_ref *ref, bool traverse, bool open, bool writable)
|
||||
fBaseType(kUnknownNode),
|
||||
fIconFrom(kUnknownSource),
|
||||
fWritable(false),
|
||||
fNode(NULL)
|
||||
fNode(NULL),
|
||||
fHasLocalizedName(false)
|
||||
{
|
||||
BEntry entry(ref, traverse);
|
||||
fStatus = entry.InitCheck();
|
||||
@@ -355,7 +361,11 @@ Model::Name() const
|
||||
break;
|
||||
|
||||
}
|
||||
return fEntryRef.name;
|
||||
|
||||
if (fHasLocalizedName && gLocalizedNamePreferred)
|
||||
return fLocalizedName.String();
|
||||
else
|
||||
return fEntryRef.name;
|
||||
}
|
||||
|
||||
|
||||
@@ -482,6 +492,9 @@ Model::OpenNodeCommon(bool writable)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gLocalizedNamePreferred)
|
||||
CacheLocalizedName();
|
||||
|
||||
return fStatus;
|
||||
}
|
||||
|
||||
@@ -551,6 +564,16 @@ Model::SetupBaseType()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Model::CacheLocalizedName()
|
||||
{
|
||||
if (GetLocalizedFileName(fEntryRef, fLocalizedName, true) == B_OK)
|
||||
fHasLocalizedName = true;
|
||||
else
|
||||
fHasLocalizedName = false;
|
||||
}
|
||||
|
||||
|
||||
static bool
|
||||
HasVectorIconHint(BNode *node)
|
||||
{
|
||||
|
||||
@@ -209,6 +209,7 @@ class Model {
|
||||
void SetupBaseType();
|
||||
void FinishSettingUpType();
|
||||
void DeletePreferredAppVolumeNameLinkTo();
|
||||
void CacheLocalizedName();
|
||||
|
||||
status_t FetchOneQuery(const BQuery *, BHandler *target,
|
||||
BObjectList<BQuery>*, BVolume *);
|
||||
@@ -251,6 +252,8 @@ class Model {
|
||||
bool fWritable;
|
||||
BNode *fNode;
|
||||
status_t fStatus;
|
||||
BString fLocalizedName;
|
||||
bool fHasLocalizedName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -226,6 +226,9 @@ TTracker::TTracker()
|
||||
setrlimit(RLIMIT_NOFILE, &rl);
|
||||
|
||||
fNodeMonitorCount = DEFAULT_MON_NUM;
|
||||
|
||||
gLocalizedNamePreferred
|
||||
= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();
|
||||
|
||||
#ifdef CHECK_OPEN_MODEL_LEAKS
|
||||
InitOpenModelDumping();
|
||||
@@ -505,6 +508,15 @@ TTracker::MessageReceived(BMessage *message)
|
||||
gPeriodicUpdatePoses.DoPeriodicUpdate(true);
|
||||
break;
|
||||
|
||||
case B_LOCALE_CHANGED:
|
||||
{
|
||||
BLocaleRoster::Default()->Refresh();
|
||||
bool localize;
|
||||
if (message->FindBool("filesys", &localize) == B_OK)
|
||||
gLocalizedNamePreferred = localize;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
_inherited::MessageReceived(message);
|
||||
break;
|
||||
|
||||
@@ -1470,6 +1470,9 @@ GetFileIconFromAttr(BNode *file, BBitmap *result, icon_size size)
|
||||
}
|
||||
|
||||
|
||||
bool gLocalizedNamePreferred;
|
||||
|
||||
|
||||
/*! \brief Looks up a localized filename in a catalog, using attribute data
|
||||
on the entry.
|
||||
\param ref An entry_ref with an attribute holding data for catalog lookup.
|
||||
|
||||
@@ -523,6 +523,8 @@ status_t GetAppSignatureFromAttr(BFile *, char *);
|
||||
status_t GetAppIconFromAttr(BFile *, BBitmap *, icon_size);
|
||||
status_t GetFileIconFromAttr(BNode *, BBitmap *, icon_size);
|
||||
|
||||
extern bool gLocalizedNamePreferred;
|
||||
|
||||
status_t GetLocalizedFileName(entry_ref& ref, BString& localizedFileName,
|
||||
bool traverse = false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user