Support for showing localized app entries in Deskbar. Just the app entries so far, and not yet the items in the leaf menu. Please review.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40796 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -26,3 +26,8 @@ DoCatalogs CodyCam :
|
|||||||
SftpClient.cpp
|
SftpClient.cpp
|
||||||
VideoConsumer.cpp
|
VideoConsumer.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
|
AddCatalogEntryAttribute CodyCam
|
||||||
|
:
|
||||||
|
"x-vnd.Haiku.CodyCam:CodyCam:CodyCam"
|
||||||
|
;
|
||||||
|
|||||||
@@ -635,8 +635,12 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* sig, entry_ref* ref)
|
|||||||
BFile file(ref, B_READ_ONLY);
|
BFile file(ref, B_READ_ONLY);
|
||||||
BAppFileInfo appMime(&file);
|
BAppFileInfo appMime(&file);
|
||||||
|
|
||||||
|
BString name;
|
||||||
|
if (GetLocalizedFileName(*ref, name) != B_OK)
|
||||||
|
name = ref->name;
|
||||||
|
|
||||||
BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
|
||||||
new BBitmap(kIconSize, kIconFormat), strdup(ref->name));
|
new BBitmap(kIconSize, kIconFormat), strdup(name.String()));
|
||||||
|
|
||||||
barInfo->teams->AddItem((void*)team);
|
barInfo->teams->AddItem((void*)team);
|
||||||
if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK)
|
if (appMime.GetIcon(barInfo->icon, B_MINI_ICON) != B_OK)
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ All rights reserved.
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Catalog.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
@@ -1469,6 +1470,80 @@ GetFileIconFromAttr(BNode *file, BBitmap *result, icon_size size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
GetLocalizedFileName(entry_ref& ref, BString& localizedFileName, bool traverse)
|
||||||
|
{
|
||||||
|
// Looks up a localized filename, by reading a catalog signature,
|
||||||
|
// context and string to be translated, from an attribute on the
|
||||||
|
// entry_ref, and using these to look up a translation in the catalog
|
||||||
|
// of the top preferred language.
|
||||||
|
|
||||||
|
// Attribute format: "signature:context:string"
|
||||||
|
// (no colon in any of signature, context and string)
|
||||||
|
|
||||||
|
// It fails when a comment is present in the catalog.
|
||||||
|
|
||||||
|
status_t status;
|
||||||
|
|
||||||
|
BEntry entry(&ref, traverse);
|
||||||
|
if (!entry.Exists())
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
BNode node(&entry);
|
||||||
|
status = node.InitCheck();
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
attr_info attr;
|
||||||
|
ssize_t bytes = 0;
|
||||||
|
|
||||||
|
status = node.GetAttrInfo("SYS:NAME", &attr);
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
char attribute[attr.size + 1];
|
||||||
|
bytes = node.ReadAttr("SYS:NAME", B_MIME_TYPE, 0, &attribute, attr.size);
|
||||||
|
|
||||||
|
if (bytes < 0)
|
||||||
|
return bytes;
|
||||||
|
|
||||||
|
if (bytes == 0 || bytes != attr.size)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
attribute[bytes] = '\0';
|
||||||
|
|
||||||
|
char* signature = attribute;
|
||||||
|
char* context = NULL;
|
||||||
|
char* string = NULL;
|
||||||
|
|
||||||
|
ssize_t i = 0;
|
||||||
|
for (; i < bytes; i++) {
|
||||||
|
if (signature[i] == ':') {
|
||||||
|
signature[i] = '\0';
|
||||||
|
context = &signature[i + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; i < bytes; i++) {
|
||||||
|
if (signature[i] == ':') {
|
||||||
|
signature[i] = '\0';
|
||||||
|
string = &signature[i + 1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BCatalog catalog(signature);
|
||||||
|
|
||||||
|
const char* temp = catalog.GetString(string, context);
|
||||||
|
if (temp == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
localizedFileName = temp;
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintToStream(rgb_color color)
|
PrintToStream(rgb_color color)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -523,6 +523,8 @@ status_t GetAppSignatureFromAttr(BFile *, char *);
|
|||||||
status_t GetAppIconFromAttr(BFile *, BBitmap *, icon_size);
|
status_t GetAppIconFromAttr(BFile *, BBitmap *, icon_size);
|
||||||
status_t GetFileIconFromAttr(BNode *, BBitmap *, icon_size);
|
status_t GetFileIconFromAttr(BNode *, BBitmap *, icon_size);
|
||||||
|
|
||||||
|
status_t GetLocalizedFileName(entry_ref& ref, BString& localizedFileName,
|
||||||
|
bool traverse = false);
|
||||||
|
|
||||||
// debugging
|
// debugging
|
||||||
void HexDump(const void *buffer, int32 length);
|
void HexDump(const void *buffer, int32 length);
|
||||||
|
|||||||
Reference in New Issue
Block a user