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 { class BAboutMenuItem : public BMenuItem {
public: public:
BAboutMenuItem(const char* appName); BAboutMenuItem();
}; };

View File

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

View File

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