[haiku-commits] haiku: hrev44563 - in src: kits/tracker kits/locale apps/deskbar

  • From: leavengood@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 20 Aug 2012 03:30:42 +0200 (CEST)

hrev44563 adds 3 changesets to branch 'master'
old head: d7f6b4c18c23ab908555645449f1f6cd7436a1e6
new head: eb89cc6b0b676d270e15b84dee3eadd65e1cc658

----------------------------------------------------------------------------

379dcaa: Look up the entry_ref for a signature for localized file names.
  
  Fixes #8124.

d6c852e: Actually cache something when CacheLocalizedName is called.
  
  Before its name was a lie, since nothing was cached.
  
  Another boolean was added because getting the localized name could fail, and 
we
  don't want to pointlessly try again, so relying on fHasLocalizedName won't 
work
  for that.
  
  Since in my tests this was getting called up to 4 times per application when
  opening the Deskbar Application menu, this caching should speed that up a bit,
  at least when this file name translation feature is turned on.

eb89cc6: Deskbar: You know, we should actually use the translated name.
  
  If this ever worked before, I don't know how.

                                  [ Ryan Leavengood <leavengood@xxxxxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 34 insertions(+), 12 deletions(-)
src/apps/deskbar/BarApp.cpp      |    2 +-
src/kits/locale/LocaleRoster.cpp |   15 ++++++++++++++-
src/kits/tracker/Model.cpp       |   28 ++++++++++++++++++----------
src/kits/tracker/Model.h         |    1 +

############################################################################

Commit:      379dcaa1f6ab63603aa6436ef4b43efb7eb3ca07
URL:         http://cgit.haiku-os.org/haiku/commit/?id=379dcaa
Author:      Ryan Leavengood <leavengood@xxxxxxxxx>
Date:        Mon Aug 20 01:21:30 2012 UTC

Ticket:      https://dev.haiku-os.org/ticket/8124

Look up the entry_ref for a signature for localized file names.

Fixes #8124.

----------------------------------------------------------------------------

diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp
index adb4e35..d13b614 100644
--- a/src/kits/locale/LocaleRoster.cpp
+++ b/src/kits/locale/LocaleRoster.cpp
@@ -32,6 +32,7 @@
 #include <MutableLocaleRoster.h>
 #include <Node.h>
 #include <Path.h>
+#include <Roster.h>
 #include <String.h>
 #include <TimeZone.h>
 
@@ -514,7 +515,19 @@ BLocaleRoster::GetLocalizedFileName(BString& 
localizedFileName,
        if (status != B_OK)
                return status;
 
-       BCatalog catalog(ref);
+       // Try to get entry_ref for signature from above
+       BRoster roster;
+       entry_ref catalogRef;
+       // The signature is missing application/
+       signature.Prepend("application/");
+       status = roster.FindApp(signature, &catalogRef);
+       if (status != B_OK) {
+               log_team(LOG_ERR, "Could not find the entry_ref for signature 
%s"
+                               " to load a catalog.", signature.String());
+               return status;
+       }
+
+       BCatalog catalog(catalogRef);
        const char* temp = catalog.GetString(string, context);
 
        if (temp == NULL)

############################################################################

Commit:      d6c852ec49df1af8400a62ab7a2eb950b50f1de0
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d6c852e
Author:      Ryan Leavengood <leavengood@xxxxxxxxx>
Date:        Mon Aug 20 01:25:43 2012 UTC

Actually cache something when CacheLocalizedName is called.

Before its name was a lie, since nothing was cached.

Another boolean was added because getting the localized name could fail, and we
don't want to pointlessly try again, so relying on fHasLocalizedName won't work
for that.

Since in my tests this was getting called up to 4 times per application when
opening the Deskbar Application menu, this caching should speed that up a bit,
at least when this file name translation feature is turned on.

----------------------------------------------------------------------------

diff --git a/src/kits/tracker/Model.cpp b/src/kits/tracker/Model.cpp
index c0f2d28..1cf77c8 100644
--- a/src/kits/tracker/Model.cpp
+++ b/src/kits/tracker/Model.cpp
@@ -96,7 +96,8 @@ Model::Model()
        fWritable(false),
        fNode(NULL),
        fStatus(B_NO_INIT),
-       fHasLocalizedName(false)
+       fHasLocalizedName(false),
+       fLocalizedNameIsCached(false)
 {
 }
 
@@ -111,7 +112,8 @@ Model::Model(const Model &cloneThis)
        fWritable(false),
        fNode(NULL),
        fLocalizedName(cloneThis.fLocalizedName),
-       fHasLocalizedName(cloneThis.fHasLocalizedName)
+       fHasLocalizedName(cloneThis.fHasLocalizedName),
+       fLocalizedNameIsCached(cloneThis.fLocalizedNameIsCached)
 {
        fStatBuf.st_dev = cloneThis.NodeRef()->device;
        fStatBuf.st_ino = cloneThis.NodeRef()->node;
@@ -137,7 +139,8 @@ Model::Model(const node_ref* dirNode, const node_ref* node, 
const char* name,
        fPreferredAppName(NULL),
        fWritable(false),
        fNode(NULL),
-       fHasLocalizedName(false)
+       fHasLocalizedName(false),
+       fLocalizedNameIsCached(false)
 {
        SetTo(dirNode, node, name, open, writable);
 }
@@ -148,7 +151,8 @@ Model::Model(const BEntry* entry, bool open, bool writable)
        fPreferredAppName(NULL),
        fWritable(false),
        fNode(NULL),
-       fHasLocalizedName(false)
+       fHasLocalizedName(false),
+       fLocalizedNameIsCached(false)
 {
        SetTo(entry, open, writable);
 }
@@ -161,7 +165,8 @@ Model::Model(const entry_ref* ref, bool traverse, bool 
open, bool writable)
        fIconFrom(kUnknownSource),
        fWritable(false),
        fNode(NULL),
-       fHasLocalizedName(false)
+       fHasLocalizedName(false),
+       fLocalizedNameIsCached(false)
 {
        BEntry entry(ref, traverse);
        fStatus = entry.InitCheck();
@@ -569,11 +574,14 @@ Model::SetupBaseType()
 void
 Model::CacheLocalizedName()
 {
-       if (BLocaleRoster::Default()->GetLocalizedFileName(
-                       fLocalizedName, fEntryRef, true) == B_OK)
-               fHasLocalizedName = true;
-       else
-               fHasLocalizedName = false;
+       if (!fLocalizedNameIsCached) {
+               fLocalizedNameIsCached = true;
+               if (BLocaleRoster::Default()->GetLocalizedFileName(
+                               fLocalizedName, fEntryRef, true) == B_OK)
+                       fHasLocalizedName = true;
+               else
+                       fHasLocalizedName = false;
+       }
 }
 
 
diff --git a/src/kits/tracker/Model.h b/src/kits/tracker/Model.h
index 1a872a7..92307a7 100644
--- a/src/kits/tracker/Model.h
+++ b/src/kits/tracker/Model.h
@@ -262,6 +262,7 @@ class Model {
                status_t fStatus;
                BString fLocalizedName;
                bool fHasLocalizedName;
+               bool fLocalizedNameIsCached;
 };
 
 

############################################################################

Revision:    hrev44563
Commit:      eb89cc6b0b676d270e15b84dee3eadd65e1cc658
URL:         http://cgit.haiku-os.org/haiku/commit/?id=eb89cc6
Author:      Ryan Leavengood <leavengood@xxxxxxxxx>
Date:        Mon Aug 20 01:29:28 2012 UTC

Deskbar: You know, we should actually use the translated name.

If this ever worked before, I don't know how.

----------------------------------------------------------------------------

diff --git a/src/apps/deskbar/BarApp.cpp b/src/apps/deskbar/BarApp.cpp
index 4008406..f5080da 100644
--- a/src/apps/deskbar/BarApp.cpp
+++ b/src/apps/deskbar/BarApp.cpp
@@ -749,7 +749,7 @@ TBarApp::AddTeam(team_id team, uint32 flags, const char* 
sig, entry_ref* ref)
        }
 
        BarTeamInfo* barInfo = new BarTeamInfo(new BList(), flags, strdup(sig),
-               new BBitmap(IconRect(), kIconColorSpace), strdup(ref->name));
+               new BBitmap(IconRect(), kIconColorSpace), 
strdup(name.String()));
 
        if ((barInfo->flags & B_BACKGROUND_APP) == 0
                && strcasecmp(barInfo->sig, kDeskbarSignature) != 0) {


Other related posts:

  • » [haiku-commits] haiku: hrev44563 - in src: kits/tracker kits/locale apps/deskbar - leavengood