Simplifying the BAboutMenuItem and adding it properly to the locale kit's DoCatalogs list.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40967 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström 2011-03-15 21:00:16 +00:00
parent 5732d3822b
commit d7f342e8a3
3 changed files with 16 additions and 4 deletions

View File

@ -11,7 +11,7 @@
class BAboutMenuItem : public BMenuItem {
public:
BAboutMenuItem(const char* appName);
BAboutMenuItem();
};

View File

@ -63,14 +63,16 @@ StaticLibrary liblocalestub.a
: CatalogStub.cpp
;
SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ;
SEARCH on [ FGristFiles AboutMenuItem.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ;
SEARCH on [ FGristFiles AboutWindow.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ;
SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ;
SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ;
SEARCH on [ FGristFiles TextView.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ;
DoCatalogs liblocale.so
: system
:
AboutMenuItem.cpp
AboutWindow.cpp
ColorControl.cpp
StringForSize.cpp

View File

@ -9,8 +9,10 @@
#include <AboutMenuItem.h>
#include <Application.h>
#include <Catalog.h>
#include <LocaleBackend.h>
#include <Roster.h>
#include <String.h>
@ -22,10 +24,15 @@ using BPrivate::LocaleBackend;
#define B_TRANSLATE_CONTEXT "AboutMenuItem"
BAboutMenuItem::BAboutMenuItem(const char* appName)
BAboutMenuItem::BAboutMenuItem()
:
BMenuItem("", new BMessage(B_ABOUT_REQUESTED))
{
app_info info;
const char* name = NULL;
if (be_app != NULL && be_app->GetAppInfo(&info) == B_OK)
name = B_TRANSLATE_NOCOLLECT_APP_NAME(info.ref.name);
// we need to translate some strings, and in order to do so, we need
// to use the LocaleBackend to reach liblocale.so
if (gLocaleBackend == NULL)
@ -37,6 +44,9 @@ BAboutMenuItem::BAboutMenuItem(const char* appName)
}
BString label = string;
label.ReplaceFirst("%app%", appName);
if (name != NULL)
label.ReplaceFirst("%app%", name);
else
label.ReplaceFirst("%app%", "(NULL)");
SetLabel(label.String());
}