From 541ff51a6ef4c47f8ab105ba6ff895cdbba83aca Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Sun, 15 Apr 2012 19:04:02 +0200 Subject: [PATCH] Cleanup BCatalogAddOn. * rename BCatalogAddOn to BCatalogData, since it doesn't represent an add-on, but rather the catalog data provided by an add-on * move BCatalogData out of Catalog.{h,cpp} into its own header and implementation file * drop BCatalogData::MarkForTranslation() methods, they're not needed * drop BCatalog::GetNoAutoCollectString() methods, they're not being used anywhere * cleanup the B_TRANSLATE_... macros somewhat * add versions of the B_TRANSLATE_MARK_... macros that are meant to be used in void context (when the string isn't being used by the program, just meant to be picked up by collectcatkeys). * adjust several apps to use B_TRANSLATE_MARK_..._VOID where needed * adjust users of BCatalogAddOn accordingly --- headers/os/locale/Catalog.h | 249 +++++------------- headers/os/locale/CatalogData.h | 113 ++++++++ headers/private/locale/DefaultCatalog.h | 4 +- headers/private/locale/EditableCatalog.h | 2 +- headers/private/locale/HashMapCatalog.h | 8 +- headers/private/locale/MutableLocaleRoster.h | 19 +- headers/private/locale/PlainTextCatalog.h | 2 +- .../locale/catalogs/plaintext/Catalog.cpp | 6 +- src/add-ons/screen_savers/flurry/Flurry.cpp | 4 +- .../screen_savers/simpleclock/SimpleClock.cpp | 38 +-- .../slideshowsaver/SlideShowSaver.cpp | 100 +++---- src/apps/aboutsystem/AboutSystem.cpp | 2 +- src/apps/devices/Device.cpp | 24 +- src/apps/people/PeopleApp.cpp | 2 +- src/apps/showimage/ShowImageApp.cpp | 4 +- src/apps/stylededit/StyledEditApp.cpp | 4 +- src/apps/tracker/main.cpp | 6 +- src/apps/tv/MainWin.cpp | 160 +++++------ src/apps/webwatch/WatchApp.cpp | 36 +-- src/bin/locale/dumpcatalog.cpp | 2 +- src/bin/locale/linkcatkeys.cpp | 4 +- src/kits/locale/Catalog.cpp | 193 ++------------ src/kits/locale/CatalogData.cpp | 160 +++++++++++ src/kits/locale/DefaultCatalog.cpp | 4 +- src/kits/locale/EditableCatalog.cpp | 59 +++-- src/kits/locale/HashMapCatalog.cpp | 2 +- src/kits/locale/Jamfile | 1 + src/kits/locale/MutableLocaleRoster.cpp | 22 +- src/preferences/cpufrequency/StatusView.cpp | 22 +- .../deskbar/DeskbarPreferences.cpp | 4 +- .../tracker/TrackerPreferences.cpp | 16 +- src/tools/locale/Catalog.cpp | 198 ++------------ src/tools/locale/CatalogData.cpp | 158 +++++++++++ src/tools/locale/DefaultCatalog.cpp | 4 +- src/tools/locale/Jamfile | 2 + src/tools/locale/PlainTextCatalog.cpp | 9 +- 36 files changed, 833 insertions(+), 810 deletions(-) create mode 100644 headers/os/locale/CatalogData.h create mode 100644 src/kits/locale/CatalogData.cpp create mode 100644 src/tools/locale/CatalogData.cpp diff --git a/headers/os/locale/Catalog.h b/headers/os/locale/Catalog.h index 0eef2859eb..4096016a9a 100644 --- a/headers/os/locale/Catalog.h +++ b/headers/os/locale/Catalog.h @@ -12,7 +12,7 @@ #include -class BCatalogAddOn; +class BCatalogData; class BLocale; class BMessage; struct entry_ref; @@ -31,11 +31,6 @@ public: const char* comment = NULL); const char* GetString(uint32 id); - const char* GetNoAutoCollectString(const char* string, - const char* context = NULL, - const char* comment = NULL); - const char* GetNoAutoCollectString(uint32 id); - status_t GetData(const char* name, BMessage* msg); status_t GetData(uint32 id, BMessage* msg); @@ -55,7 +50,7 @@ protected: const BCatalog& operator= (const BCatalog&); // hide assignment and copy-constructor - BCatalogAddOn* fCatalog; + BCatalogData* fCatalogData; mutable BLocker fLock; private: @@ -122,12 +117,13 @@ private: #undef B_TRANSLATE_SYSTEM_NAME #define B_TRANSLATE_SYSTEM_NAME(string) \ BLocaleRoster::Default()->IsFilesystemTranslationPreferred() \ - ? BLocaleRoster::Default()->GetCatalog()->GetString((string), \ - B_TRANSLATE_SYSTEM_NAME_CONTEXT) : (string) + ? BLocaleRoster::Default()->GetCatalog()->GetString((string), \ + B_TRANSLATE_SYSTEM_NAME_CONTEXT) \ + : (string) // Translation markers which can be used to mark static strings/IDs which -// are used as key for translation requests (at other places in the code): -/* example: +// are used as key for translation requests (at other places in the code). +/* Example: #define B_TRANSLATE_CONTEXT "MyDecentApp-Menu" static const char* choices[] = { @@ -137,7 +133,8 @@ private: B_TRANSLATE_MARK("down") }; - void MyClass::AddChoices(BMenu* menu) { + void MyClass::AddChoices(BMenu* menu) + { for (char** ch = choices; *ch != '\0'; ++ch) { menu->AddItem( new BMenuItem( @@ -149,46 +146,57 @@ private: } */ #undef B_TRANSLATE_MARK -#define B_TRANSLATE_MARK(str) \ - BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, "") +#define B_TRANSLATE_MARK(string) (string) #undef B_TRANSLATE_MARK_COMMENT -#define B_TRANSLATE_MARK_COMMENT(str, cmt) \ - BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, (cmt)) +#define B_TRANSLATE_MARK_COMMENT(string, comment) (string) #undef B_TRANSLATE_MARK_ALL -#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \ - BCatalogAddOn::MarkForTranslation((str), (ctx), (cmt)) +#define B_TRANSLATE_MARK_ALL(string, context, comment) (string) #undef B_TRANSLATE_MARK_ID -#define B_TRANSLATE_MARK_ID(id) \ - BCatalogAddOn::MarkForTranslation((id)) +#define B_TRANSLATE_MARK_ID(id) (id) #undef B_TRANSLATE_MARK_SYSTEM_NAME -#define B_TRANSLATE_MARK_SYSTEM_NAME(str) \ - BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "") +#define B_TRANSLATE_MARK_SYSTEM_NAME(string) (string) + +// the same for void contexts: +#undef B_TRANSLATE_MARK_VOID +#define B_TRANSLATE_MARK_VOID(string) + +#undef B_TRANSLATE_MARK_COMMENT_VOID +#define B_TRANSLATE_MARK_COMMENT_VOID(string, comment) + +#undef B_TRANSLATE_MARK_ALL_VOID +#define B_TRANSLATE_MARK_ALL_VOID(string, context, comment) + +#undef B_TRANSLATE_MARK_ID_VOID +#define B_TRANSLATE_MARK_ID_VOID(id) + +#undef B_TRANSLATE_MARK_SYSTEM_NAME_VOID +#define B_TRANSLATE_MARK_SYSTEM_NAME_VOID(string) // Translation macros which do not let collectcatkeys try to collect the key // (useful in combination with the marking macros above): #undef B_TRANSLATE_NOCOLLECT -#define B_TRANSLATE_NOCOLLECT(str) \ - B_TRANSLATE(str) +#define B_TRANSLATE_NOCOLLECT(string) \ + B_TRANSLATE(string) #undef B_TRANSLATE_NOCOLLECT_COMMENT -#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \ - B_TRANSLATE_COMMENT(str, cmt) +#define B_TRANSLATE_NOCOLLECT_COMMENT(string, comment) \ + B_TRANSLATE_COMMENT(string, comment) #undef B_TRANSLATE_NOCOLLECT_ALL -#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \ - B_TRANSLATE_ALL(str, ctx, cmt) +#define B_TRANSLATE_NOCOLLECT_ALL(string, context, comment) \ + B_TRANSLATE_ALL(string, context, comment) #undef B_TRANSLATE_NOCOLLECT_ID #define B_TRANSLATE_NOCOLLECT_ID(id) \ B_TRANSLATE_ID(id) #undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME -#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(str) \ - B_TRANSLATE_SYSTEM_NAME(str) +#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(string) \ + B_TRANSLATE_SYSTEM_NAME(string) #endif /* B_AVOID_TRANSLATION_MACROS */ @@ -226,176 +234,61 @@ private: B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT) #undef B_TRANSLATE_MARK -#define B_TRANSLATE_MARK(str) \ - B_CATKEY((str), B_TRANSLATE_CONTEXT) +#define B_TRANSLATE_MARK(string) \ + B_CATKEY((string), B_TRANSLATE_CONTEXT) #undef B_TRANSLATE_MARK_COMMENT -#define B_TRANSLATE_MARK_COMMENT(str, cmt) \ - B_CATKEY((str), B_TRANSLATE_CONTEXT, (cmt)) +#define B_TRANSLATE_MARK_COMMENT(string, comment) \ + B_CATKEY((string), B_TRANSLATE_CONTEXT, (comment)) #undef B_TRANSLATE_MARK_ALL -#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \ - B_CATKEY((str), (ctx), (cmt)) +#define B_TRANSLATE_MARK_ALL(string, context, comment) \ + B_CATKEY((string), (context), (comment)) #undef B_TRANSLATE_MARK_ID #define B_TRANSLATE_MARK_ID(id) \ B_CATKEY((id)) #undef B_TRANSLATE_MARK_SYSTEM_NAME -#define B_TRANSLATE_MARK_SYSTEM_NAME(str) \ - B_CATKEY((str), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "") +#define B_TRANSLATE_MARK_SYSTEM_NAME(string) \ + B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "") + +#undef B_TRANSLATE_MARK_VOID +#define B_TRANSLATE_MARK_VOID(string) \ + B_CATKEY((string), B_TRANSLATE_CONTEXT) + +#undef B_TRANSLATE_MARK_COMMENT_VOID +#define B_TRANSLATE_MARK_COMMENT_VOID(string, comment) \ + B_CATKEY((string), B_TRANSLATE_CONTEXT, (comment)) + +#undef B_TRANSLATE_MARK_ALL_VOID +#define B_TRANSLATE_MARK_ALL_VOID(string, context, comment) \ + B_CATKEY((string), (context), (comment)) + +#undef B_TRANSLATE_MARK_ID_VOID +#define B_TRANSLATE_MARK_ID_VOID(id) \ + B_CATKEY((id)) + +#undef B_TRANSLATE_MARK_SYSTEM_NAME_VOID +#define B_TRANSLATE_MARK_SYSTEM_NAME_VOID(string) \ + B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "") #undef B_TRANSLATE_NOCOLLECT -#define B_TRANSLATE_NOCOLLECT(str) \ - (void) +#define B_TRANSLATE_NOCOLLECT(string) #undef B_TRANSLATE_NOCOLLECT_COMMENT -#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \ - (void) +#define B_TRANSLATE_NOCOLLECT_COMMENT(string, comment) #undef B_TRANSLATE_NOCOLLECT_ALL -#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \ - (void) +#define B_TRANSLATE_NOCOLLECT_ALL(string, context, comment) #undef B_TRANSLATE_NOCOLLECT_ID -#define B_TRANSLATE_NOCOLLECT_ID(id) \ - (void) +#define B_TRANSLATE_NOCOLLECT_ID(id) #undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME -#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(str) \ - (void) +#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(string) #endif /* B_COLLECTING_CATKEYS */ -/************************************************************************/ -// For BCatalog add-on implementations: -// TODO: should go into another header - -class BCatalogAddOn { -public: - BCatalogAddOn(const char* signature, - const char* language, - uint32 fingerprint); - virtual ~BCatalogAddOn(); - - virtual const char* GetString(const char* string, - const char* context = NULL, - const char* comment = NULL) = 0; - virtual const char* GetString(uint32 id) = 0; - - status_t InitCheck() const; - BCatalogAddOn* Next(); - - // the following could be used to localize non-textual data (e.g. - // icons), but these will only be implemented if there's demand for such - // a feature: - virtual bool CanHaveData() const; - virtual status_t GetData(const char* name, BMessage* msg); - virtual status_t GetData(uint32 id, BMessage* msg); - - // interface for catalog-editor-app and testing apps: - virtual status_t SetString(const char* string, - const char* translated, - const char* context = NULL, - const char* comment = NULL); - virtual status_t SetString(int32 id, const char* translated); - - virtual bool CanWriteData() const; - virtual status_t SetData(const char* name, BMessage* msg); - virtual status_t SetData(uint32 id, BMessage* msg); - - virtual status_t ReadFromFile(const char* path = NULL); - virtual status_t ReadFromAttribute( - const entry_ref& appOrAddOnRef); - virtual status_t ReadFromResource( - const entry_ref& appOrAddOnRef); - virtual status_t WriteToFile(const char* path = NULL); - virtual status_t WriteToAttribute( - const entry_ref& appOrAddOnRef); - virtual status_t WriteToResource( - const entry_ref& appOrAddOnRef); - - virtual void MakeEmpty(); - virtual int32 CountItems() const; - - // magic marker functions which are used to mark a string/id - // which will be translated elsewhere in the code (where it can - // not be found since it is references by a variable): - static const char* MarkForTranslation(const char* string, - const char* context, const char* comment); - static int32 MarkForTranslation(int32 id); - - void SetNext(BCatalogAddOn* next); - -protected: - virtual void UpdateFingerprint(); - -protected: - friend class BCatalog; - friend status_t get_add_on_catalog(BCatalog*, const char*); - - status_t fInitCheck; - BString fSignature; - BString fLanguageName; - uint32 fFingerprint; - BCatalogAddOn* fNext; -}; - -// every catalog-add-on should export these symbols... -// ...the function that instantiates a catalog for this add-on-type... -extern "C" -BCatalogAddOn* instantiate_catalog(const char* signature, const char* language, - uint32 fingerprint); - -// ...the function that creates an empty catalog for this add-on-type... -extern "C" -BCatalogAddOn* create_catalog(const char* signature, const char* language); - -// ...and the priority which will be used to order the catalog-add-ons: -extern uint8 gCatalogAddOnPriority; - - -/* - * BCatalog - inlines for trivial accessors: - */ -inline const char* -BCatalog::GetNoAutoCollectString(const char* string, const char* context, - const char* comment) -{ - return GetString(string, context, comment); -} - - -inline const char* -BCatalog::GetNoAutoCollectString(uint32 id) -{ - return GetString(id); -} - - -/* - * BCatalogAddOn - inlines for trivial accessors: - */ -inline BCatalogAddOn* -BCatalogAddOn::Next() -{ - return fNext; -} - -inline const char* -BCatalogAddOn::MarkForTranslation(const char* str, const char* /* context */, - const char* /* comment */) -{ - return str; -} - - -inline int32 -BCatalogAddOn::MarkForTranslation(int32 id) -{ - return id; -} - - #endif /* _CATALOG_H_ */ diff --git a/headers/os/locale/CatalogData.h b/headers/os/locale/CatalogData.h new file mode 100644 index 0000000000..5c6d91ba1d --- /dev/null +++ b/headers/os/locale/CatalogData.h @@ -0,0 +1,113 @@ +/* + * Copyright 2003-2012, Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef _CATALOG_DATA_H_ +#define _CATALOG_DATA_H_ + + +#include +#include + + +class BCatalog; +class BMessage; +struct entry_ref; + + +/** + * Base class for the catalog-data provided by every catalog add-on. An instance + * of this class represents (the data of) a single catalog. Several of these + * catalog data objects may be chained together in order to represent + * variations of a specific language. If for instance the catalog data 'en_uk' + * is chained to the data for 'en', a BCatalog using this catalog data chain + * will prefer any entries in the 'en_uk' catalog, but fallback onto 'en' for + * entries missing in the former. + */ +class BCatalogData { +public: + BCatalogData(const char* signature, + const char* language, + uint32 fingerprint); + virtual ~BCatalogData(); + + virtual const char* GetString(const char* string, + const char* context = NULL, + const char* comment = NULL) = 0; + virtual const char* GetString(uint32 id) = 0; + + status_t InitCheck() const; + BCatalogData* Next(); + + // the following could be used to localize non-textual data (e.g. + // icons), but these will only be implemented if there's demand for such + // a feature: + virtual bool CanHaveData() const; + virtual status_t GetData(const char* name, BMessage* msg); + virtual status_t GetData(uint32 id, BMessage* msg); + + // interface for catalog-editor-app and testing apps: + virtual status_t SetString(const char* string, + const char* translated, + const char* context = NULL, + const char* comment = NULL); + virtual status_t SetString(int32 id, const char* translated); + + virtual bool CanWriteData() const; + virtual status_t SetData(const char* name, BMessage* msg); + virtual status_t SetData(uint32 id, BMessage* msg); + + virtual status_t ReadFromFile(const char* path = NULL); + virtual status_t ReadFromAttribute( + const entry_ref& appOrAddOnRef); + virtual status_t ReadFromResource( + const entry_ref& appOrAddOnRef); + virtual status_t WriteToFile(const char* path = NULL); + virtual status_t WriteToAttribute( + const entry_ref& appOrAddOnRef); + virtual status_t WriteToResource( + const entry_ref& appOrAddOnRef); + + virtual void MakeEmpty(); + virtual int32 CountItems() const; + + void SetNext(BCatalogData* next); + +protected: + virtual void UpdateFingerprint(); + +protected: + friend class BCatalog; + friend status_t get_add_on_catalog(BCatalog*, const char*); + + status_t fInitCheck; + BString fSignature; + BString fLanguageName; + uint32 fFingerprint; + BCatalogData* fNext; +}; + + +inline BCatalogData* +BCatalogData::Next() +{ + return fNext; +} + + +// every catalog-add-on should export the following three symbols: +// +// 1. the function that instantiates a catalog for this add-on-type +extern "C" +BCatalogData* instantiate_catalog(const char* signature, const char* language, + uint32 fingerprint); + +// 2. the function that creates an empty catalog for this add-on-type +extern "C" +BCatalogData* create_catalog(const char* signature, const char* language); + +// 3. the priority which will be used to order the catalog add-ons +extern uint8 gCatalogAddOnPriority; + + +#endif /* _CATALOG_DATA_H_ */ diff --git a/headers/private/locale/DefaultCatalog.h b/headers/private/locale/DefaultCatalog.h index 5afb733f31..0cfab3f7ce 100644 --- a/headers/private/locale/DefaultCatalog.h +++ b/headers/private/locale/DefaultCatalog.h @@ -46,9 +46,9 @@ class DefaultCatalog : public HashMapCatalog { status_t SetRawString(const CatKey& key, const char *translated); void SetSignature(const entry_ref &catalogOwner); - static BCatalogAddOn *Instantiate(const entry_ref& catalogOwner, + static BCatalogData *Instantiate(const entry_ref& catalogOwner, const char *language, uint32 fingerprint); - static BCatalogAddOn *Create(const char *signature, + static BCatalogData *Create(const char *signature, const char *language); static const uint8 kDefaultCatalogAddOnPriority; diff --git a/headers/private/locale/EditableCatalog.h b/headers/private/locale/EditableCatalog.h index ad8bb31fae..7842610ca3 100644 --- a/headers/private/locale/EditableCatalog.h +++ b/headers/private/locale/EditableCatalog.h @@ -46,7 +46,7 @@ public: void MakeEmpty(); - BCatalogAddOn* CatalogAddOn(); + BCatalogData* CatalogData(); private: EditableCatalog(); diff --git a/headers/private/locale/HashMapCatalog.h b/headers/private/locale/HashMapCatalog.h index a189f35440..09d18f341e 100644 --- a/headers/private/locale/HashMapCatalog.h +++ b/headers/private/locale/HashMapCatalog.h @@ -15,7 +15,7 @@ #include -#include +#include #include #include @@ -61,7 +61,7 @@ class CatKey { }; -class HashMapCatalog: public BCatalogAddOn { +class HashMapCatalog: public BCatalogData { protected: uint32 ComputeFingerprint() const; typedef HashMap CatMap; @@ -72,7 +72,7 @@ class HashMapCatalog: public BCatalogAddOn { uint32 fingerprint); // Constructor for normal use // - // overrides of BCatalogAddOn: + // overrides of BCatalogData: const char *GetString(const char *string, const char *context = NULL, const char *comment = NULL); const char *GetString(uint32 id); @@ -132,7 +132,7 @@ class HashMapCatalog: public BCatalogAddOn { inline HashMapCatalog::HashMapCatalog(const char* signature, const char* language, uint32 fingerprint) : - BCatalogAddOn(signature, language, fingerprint) + BCatalogData(signature, language, fingerprint) { } diff --git a/headers/private/locale/MutableLocaleRoster.h b/headers/private/locale/MutableLocaleRoster.h index 44dec1223f..4eb072b4ec 100644 --- a/headers/private/locale/MutableLocaleRoster.h +++ b/headers/private/locale/MutableLocaleRoster.h @@ -1,5 +1,5 @@ /* - * Copyright 2010, Haiku. All rights reserved. + * Copyright 2010-2012, Haiku. All rights reserved. * Distributed under the terms of the MIT license. */ #ifndef _MUTABLE_LOCALE_ROSTER_H_ @@ -21,7 +21,7 @@ class BLocale; class BCatalog; -class BCatalogAddOn; +class BCatalogData; struct entry_ref; @@ -44,28 +44,29 @@ public: // the message contains one or more // 'language'-string-fields which // contain the language-name(s) - status_t SetFilesystemTranslationPreferred(bool preferred); + status_t SetFilesystemTranslationPreferred( + bool preferred); status_t LoadSystemCatalog(BCatalog* catalog) const; - BCatalogAddOn* LoadCatalog(const entry_ref& catalogOwner, + BCatalogData* LoadCatalog(const entry_ref& catalogOwner, const char* language = NULL, int32 fingerprint = 0) const; - status_t UnloadCatalog(BCatalogAddOn* addOn); + status_t UnloadCatalog(BCatalogData* catalogData); - BCatalogAddOn* CreateCatalog(const char* type, + BCatalogData* CreateCatalog(const char* type, const char* signature, const char* language); }; -typedef BCatalogAddOn* (*InstantiateCatalogFunc)(const entry_ref& catalogOwner, +typedef BCatalogData* (*InstantiateCatalogFunc)(const entry_ref& catalogOwner, const char* language, uint32 fingerprint); -typedef BCatalogAddOn* (*CreateCatalogFunc)(const char* name, +typedef BCatalogData* (*CreateCatalogFunc)(const char* name, const char* language); -typedef BCatalogAddOn* (*InstantiateEmbeddedCatalogFunc)( +typedef BCatalogData* (*InstantiateEmbeddedCatalogFunc)( entry_ref* appOrAddOnRef); typedef status_t (*GetAvailableLanguagesFunc)(BMessage*, const char*, diff --git a/headers/private/locale/PlainTextCatalog.h b/headers/private/locale/PlainTextCatalog.h index 154e79fb66..b31031b120 100644 --- a/headers/private/locale/PlainTextCatalog.h +++ b/headers/private/locale/PlainTextCatalog.h @@ -33,7 +33,7 @@ class PlainTextCatalog : public HashMapCatalog { status_t ReadFromFile(const char *path = NULL); status_t WriteToFile(const char *path = NULL); - static BCatalogAddOn *Instantiate(const char *signature, + static BCatalogData *Instantiate(const char *signature, const char *language, uint32 fingerprint); static const char *kCatMimeType; diff --git a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp index e2dedb0d82..8c924258a0 100644 --- a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp +++ b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp @@ -396,7 +396,7 @@ PlainTextCatalog::UpdateAttributes(const char* path) } -BCatalogAddOn * +BCatalogData * PlainTextCatalog::Instantiate(const char *signature, const char *language, uint32 fingerprint) { @@ -410,7 +410,7 @@ PlainTextCatalog::Instantiate(const char *signature, const char *language, } -extern "C" BCatalogAddOn * +extern "C" BCatalogData * instantiate_catalog(const char *signature, const char *language, uint32 fingerprint) { @@ -424,7 +424,7 @@ instantiate_catalog(const char *signature, const char *language, } -extern "C" BCatalogAddOn * +extern "C" BCatalogData * create_catalog(const char *signature, const char *language) { PlainTextCatalog *catalog diff --git a/src/add-ons/screen_savers/flurry/Flurry.cpp b/src/add-ons/screen_savers/flurry/Flurry.cpp index 31c6a153ab..04b360ae1c 100644 --- a/src/add-ons/screen_savers/flurry/Flurry.cpp +++ b/src/add-ons/screen_savers/flurry/Flurry.cpp @@ -59,8 +59,8 @@ FlurryView::FlurryView(BRect bounds) fOldFrameTime(-1.0), fFlurryInfo_t(NULL) { - B_TRANSLATE_MARK_SYSTEM_NAME("Flurry"); - + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("Flurry"); + fWidth = bounds.Width(); fHeight = bounds.Height(); fStartTime = _CurrentTime(); diff --git a/src/add-ons/screen_savers/simpleclock/SimpleClock.cpp b/src/add-ons/screen_savers/simpleclock/SimpleClock.cpp index 1eb3f48264..d4d82870ba 100644 --- a/src/add-ons/screen_savers/simpleclock/SimpleClock.cpp +++ b/src/add-ons/screen_savers/simpleclock/SimpleClock.cpp @@ -1,4 +1,4 @@ -/* +/* ** ** A simple analog clock screensaver. ** @@ -28,7 +28,7 @@ public: Clock(BMessage *message, image_id id); void StartConfig(BView *view); status_t StartSaver(BView *v, bool preview); - void Draw(BView *v, int32 frame); + void Draw(BView *v, int32 frame); BStringView *tview; private: void DrawBlock(BView *view, float x, float y, float a, float size); @@ -50,7 +50,7 @@ Clock::Clock(BMessage *message, image_id image) : BScreenSaver(message, image) { - B_TRANSLATE_MARK_SYSTEM_NAME("SimpleClock"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("SimpleClock"); } @@ -77,37 +77,37 @@ void Clock::DrawBlock(BView *view, float x, float y, float a, float size) points[i].x= x+size*cos(angles[i]); points[i].y= y+size*sin(angles[i]); } - view->FillPolygon(&points[0],4); - + view->FillPolygon(&points[0],4); + } void Clock::DrawArrow(BView *view, float xc, float yc, float a, float len, float k, float width) { - float g = width/len; - + float g = width/len; + float x = xc+(len)*cos(a); float y = yc+(len)*sin(a); - + float size = len*k; float angles[4]={a-g,a+g,a+(M_PI)-g,a+(M_PI)+g}; - + BPoint points[4]; for(int i=0;i<4;i++) { points[i].x= x+size*cos(angles[i]); points[i].y= y+size*sin(angles[i]); } - view->FillPolygon(&points[0],4); + view->FillPolygon(&points[0],4); } void Clock::Draw(BView *view, int32) -{ +{ BScreen screen; BBitmap buffer(view->Bounds(), screen.ColorSpace(), true); BView offscreen(view->Bounds(), NULL, 0, 0); buffer.AddChild(&offscreen); buffer.Lock(); - + int n; float a,R; float width = view->Bounds().Width(); @@ -122,23 +122,23 @@ void Clock::Draw(BView *view, int32) todayhour = TodayTime->tm_hour + (todayminute/60.0); rgb_color bg_color = {0,0,0}; - offscreen.SetHighColor(bg_color); + offscreen.SetHighColor(bg_color); offscreen.SetLowColor(bg_color); offscreen.FillRect(offscreen.Bounds()); - + offscreen.SetHighColor(200,200,200); - + for(n=0,a=0,R=510*zoom;n<60;n++,a+=(2*M_PI)/60) { float x = width/2 + R * cos(a); - float y = height/2 + R * sin(a); + float y = height/2 + R * sin(a); DrawBlock(&offscreen,x,y,a,14*zoom); } offscreen.SetHighColor(255,255,255); - + for(n=0,a=0,R=500*zoom;n<12;n++,a+=(2*M_PI)/12) { float x = width/2 + R * cos(a); - float y = height/2 + R * sin(a); + float y = height/2 + R * sin(a); DrawBlock(&offscreen,x,y,a,32*zoom); } @@ -147,7 +147,7 @@ void Clock::Draw(BView *view, int32) DrawArrow(&offscreen, width/2,height/2, ( ((2*M_PI)/12) * todayhour) - (M_PI/2), 140*zoom, 1, 14*zoom); offscreen.FillEllipse(BPoint(width/2,height/2),24*zoom,24*zoom); offscreen.SetHighColor(250,20,20); - DrawArrow(&offscreen, width/2,height/2, ( ((2*M_PI)/60) * todaysecond) - (M_PI/2), 240*zoom, 1, 4*zoom); + DrawArrow(&offscreen, width/2,height/2, ( ((2*M_PI)/60) * todaysecond) - (M_PI/2), 240*zoom, 1, 4*zoom); offscreen.FillEllipse(BPoint(width/2,height/2),20*zoom,20*zoom); offscreen.Sync(); diff --git a/src/add-ons/screen_savers/slideshowsaver/SlideShowSaver.cpp b/src/add-ons/screen_savers/slideshowsaver/SlideShowSaver.cpp index 7caee44f75..cb029a9404 100644 --- a/src/add-ons/screen_savers/slideshowsaver/SlideShowSaver.cpp +++ b/src/add-ons/screen_savers/slideshowsaver/SlideShowSaver.cpp @@ -11,18 +11,18 @@ // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // -// The above copyright notice and this permission notice shall be included +// The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. /*****************************************************************************/ @@ -62,11 +62,11 @@ ent_is_dir(const entry_ref *ref) BEntry ent(ref); if (ent.InitCheck() != B_OK) return B_ERROR; - + struct stat st; if (ent.GetStat(&st) != B_OK) return B_ERROR; - + return S_ISDIR(st.st_mode) ? (B_OK + 1) : B_OK; } @@ -94,18 +94,18 @@ SlideShowSaver::SlideShowSaver(BMessage *archive, image_id image) : BScreenSaver(archive, image), fLock("SlideShow Lock") { - B_TRANSLATE_MARK_SYSTEM_NAME("SlideShowSaver"); - + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("SlideShowSaver"); + fNewDirectory = true; fBitmap = NULL; fShowBorder = true; fShowCaption = true; - + fSettings = new LiveSettings("SlideShowSaver_Settings", gDefaultSettings, sizeof(gDefaultSettings) / sizeof(LiveSetting)); fSettings->LoadSettings(); // load settings from the settings file - + fSettings->AddObserver(this); } @@ -113,8 +113,8 @@ SlideShowSaver::~SlideShowSaver() { delete fBitmap; fBitmap = NULL; - - fSettings->RemoveObserver(this); + + fSettings->RemoveObserver(this); fSettings->Release(); } @@ -152,7 +152,7 @@ SlideShowSaver::UpdateTickSize() bigtime_t ticks = static_cast (fSettings->SetGetInt32(SAVER_SETTING_DELAY)) * 1000; SetTickSize(ticks); - + return B_OK; } @@ -174,23 +174,23 @@ status_t SlideShowSaver::UpdateDirectory() { status_t result = B_OK; - + fLock.Lock(); - + BString strDirectory; fSettings->GetString(SAVER_SETTING_DIRECTORY, strDirectory); BDirectory dir(strDirectory.String()); if (dir.InitCheck() != B_OK || dir.GetNextRef(&fCurrentRef) != B_OK) result = B_ERROR; - // Use ShowNextImage to find which translatable image is + // Use ShowNextImage to find which translatable image is // alphabetically first in the given directory, and load it if (result == B_OK && ShowNextImage(true, true) == false) result = B_ERROR; - + fNewDirectory = true; - + fLock.Unlock(); - + return result; } @@ -207,25 +207,25 @@ SlideShowSaver::StartSaver(BView *view, bool preview) { UpdateShowCaption(); UpdateShowBorder(); - + if (UpdateDirectory() != B_OK) return B_ERROR; - + // Read ticksize setting and set it as the delay UpdateTickSize(); - - return B_OK; -} + + return B_OK; +} void SlideShowSaver::Draw(BView *view, int32 frame) { fLock.Lock(); - + view->SetLowColor(0, 0, 0); view->SetHighColor(192, 192, 192); view->SetViewColor(192, 192, 192); - + bool bResult = false; if (fNewDirectory == true) { // Already have a bitmap on the first frame @@ -234,10 +234,10 @@ SlideShowSaver::Draw(BView *view, int32 frame) bResult = ShowNextImage(true, false); // try rewinding to beginning if (bResult == false) - bResult = ShowNextImage(true, true); + bResult = ShowNextImage(true, true); } fNewDirectory = false; - + if (bResult == true && fBitmap != NULL) { BRect destRect(0, 0, fBitmap->Bounds().Width(), fBitmap->Bounds().Height()), vwBounds = view->Bounds(); @@ -248,7 +248,7 @@ SlideShowSaver::Draw(BView *view, int32 frame) if (destRect.Height() < vwBounds.Height()) { destRect.OffsetBy(0, (vwBounds.Height() - destRect.Height()) / 2); } - + BRect border = destRect, bounds = view->Bounds(); // top view->FillRect(BRect(0, 0, bounds.right, border.top-1), B_SOLID_LOW); @@ -258,19 +258,19 @@ SlideShowSaver::Draw(BView *view, int32 frame) view->FillRect(BRect(border.right+1, border.top, bounds.right, border.bottom), B_SOLID_LOW); // bottom view->FillRect(BRect(0, border.bottom+1, bounds.right, bounds.bottom), B_SOLID_LOW); - + if (fShowBorder == true) { BRect strokeRect = destRect; strokeRect.InsetBy(-1, -1); view->StrokeRect(strokeRect); } - + view->DrawBitmap(fBitmap, fBitmap->Bounds(), destRect); - + if (fShowCaption == true) DrawCaption(view); } - + fLock.Unlock(); } @@ -303,7 +303,7 @@ SlideShowSaver::SetImage(const entry_ref *pref) if (proster->Identify(&file, &ioExtension, &info, 0, NULL, B_TRANSLATOR_BITMAP) != B_OK) return B_ERROR; - + // Translate image data and create a new ShowImage window BBitmapStream outstream; if (proster->Translate(&file, &info, &ioExtension, &outstream, @@ -312,15 +312,15 @@ SlideShowSaver::SetImage(const entry_ref *pref) BBitmap *newBitmap = NULL; if (outstream.DetachBitmap(&newBitmap) != B_OK) return B_ERROR; - + // Now that I've successfully loaded the new bitmap, - // I can be sure it is safe to delete the old one, + // I can be sure it is safe to delete the old one, // and clear everything delete fBitmap; fBitmap = newBitmap; newBitmap = NULL; fCurrentRef = ref; - + // Get path to use in caption fCaption = "<< Unable to read the path >>"; BEntry entry(&fCurrentRef); @@ -340,7 +340,7 @@ SlideShowSaver::ShowNextImage(bool next, bool rewind) { bool found; entry_ref curRef, imgRef; - + curRef = fCurrentRef; found = FindNextImage(&curRef, &imgRef, next, rewind); if (found) { @@ -367,7 +367,7 @@ SlideShowSaver::IsImage(const entry_ref *pref) { if (!pref) return false; - + if (ent_is_dir(pref) != B_OK) // if ref is erroneous or a directory, return false return false; @@ -379,7 +379,7 @@ SlideShowSaver::IsImage(const entry_ref *pref) BTranslatorRoster *proster = BTranslatorRoster::Default(); if (!proster) return false; - + BMessage ioExtension; if (ioExtension.AddInt32("/documentIndex", 1) != B_OK) return false; @@ -389,7 +389,7 @@ SlideShowSaver::IsImage(const entry_ref *pref) if (proster->Identify(&file, &ioExtension, &info, 0, NULL, B_TRANSLATOR_BITMAP) != B_OK) return false; - + return true; } @@ -405,7 +405,7 @@ SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool BList entries; bool found = false; int32 cur; - + if (curImage.GetParent(&parent) != B_OK) return false; @@ -417,15 +417,15 @@ SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool entries.AddItem(in_current); } } - + entries.SortItems(CompareEntries); - + cur = entries.IndexOf(in_current); // ASSERT(cur >= 0); // remove it so FreeEntries() does not delete it entries.RemoveItem(in_current); - + if (next) { // find the next image in the list if (rewind) cur = 0; // start with first @@ -461,7 +461,7 @@ SlideShowSaver::FreeEntries(BList *entries) const int32 n = entries->CountItems(); for (int32 i = 0; i < n; i ++) { entry_ref *ref = (entry_ref *)entries->ItemAt(i); - delete ref; + delete ref; } entries->MakeEmpty(); } @@ -480,20 +480,20 @@ SlideShowSaver::LayoutCaption(BView *view, BFont &font, BPoint &pos, BRect &rect pos.x = (bounds.left + bounds.right - width)/2; // flush bottom pos.y = bounds.bottom - fontHeight.descent - 5; - + // background rectangle rect.Set(0, 0, (width-1)+2, (height-1)+2+1); // 2 for border and 1 for text shadow rect.OffsetTo(pos); rect.OffsetBy(-1, -1-fontHeight.ascent); // -1 for border } - + void SlideShowSaver::DrawCaption(BView *view) { BFont font; BPoint pos; BRect rect; - LayoutCaption(view, font, pos, rect); + LayoutCaption(view, font, pos, rect); view->PushState(); // draw background diff --git a/src/apps/aboutsystem/AboutSystem.cpp b/src/apps/aboutsystem/AboutSystem.cpp index 08c1fdcca7..b43075b2c1 100644 --- a/src/apps/aboutsystem/AboutSystem.cpp +++ b/src/apps/aboutsystem/AboutSystem.cpp @@ -389,7 +389,7 @@ private: AboutApp::AboutApp() : BApplication("application/x-vnd.Haiku-About") { - B_TRANSLATE_MARK_SYSTEM_NAME("AboutSystem"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("AboutSystem"); AboutWindow *window = new(std::nothrow) AboutWindow(); if (window) diff --git a/src/apps/devices/Device.cpp b/src/apps/devices/Device.cpp index fc1bab570f..92fd3852d9 100644 --- a/src/apps/devices/Device.cpp +++ b/src/apps/devices/Device.cpp @@ -41,15 +41,13 @@ const char* kCategoryString[] = { }; // This list is only used to translate Device properties -static const char* kTranslateMarkString[] = { - B_TRANSLATE_MARK("unknown"), - B_TRANSLATE_MARK("Device"), - B_TRANSLATE_MARK("Computer"), - B_TRANSLATE_MARK("ACPI bus"), - B_TRANSLATE_MARK("PCI bus"), - B_TRANSLATE_MARK("ISA bus"), - B_TRANSLATE_MARK("Unknown device") -}; +B_TRANSLATE_MARK_VOID("unknown"); +B_TRANSLATE_MARK_VOID("Device"); +B_TRANSLATE_MARK_VOID("Computer"); +B_TRANSLATE_MARK_VOID("ACPI bus"); +B_TRANSLATE_MARK_VOID("PCI bus"); +B_TRANSLATE_MARK_VOID("ISA bus"); +B_TRANSLATE_MARK_VOID("Unknown device"); Device::Device(Device* physicalParent, BusType busType, Category category, @@ -150,8 +148,8 @@ Device::GetBasicStrings() "Manufacturer\t\t\t: %Manufacturer%\n" "Driver used\t\t\t\t: %DriverUsed%\n" "Device paths\t: %DevicePaths%")); - - str.ReplaceFirst("%Name%", GetName()); + + str.ReplaceFirst("%Name%", GetName()); str.ReplaceFirst("%Manufacturer%", GetManufacturer()); str.ReplaceFirst("%DriverUsed%", GetDriverUsed()); str.ReplaceFirst("%DevicePaths%", GetDevPathsPublished()); @@ -168,8 +166,8 @@ Device::GetBusStrings() BString Device::GetBusTabName() -{ - return B_TRANSLATE("Bus Information"); +{ + return B_TRANSLATE("Bus Information"); } diff --git a/src/apps/people/PeopleApp.cpp b/src/apps/people/PeopleApp.cpp index 8f9ff8eba5..2f4ba5b019 100644 --- a/src/apps/people/PeopleApp.cpp +++ b/src/apps/people/PeopleApp.cpp @@ -73,7 +73,7 @@ TPeopleApp::TPeopleApp() fWindowCount(0), fAttributes(20, true) { - B_TRANSLATE_MARK_SYSTEM_NAME("People"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("People"); fPosition.Set(6, TITLE_BAR_HEIGHT, 6 + WIND_WIDTH, TITLE_BAR_HEIGHT + WIND_HEIGHT); diff --git a/src/apps/showimage/ShowImageApp.cpp b/src/apps/showimage/ShowImageApp.cpp index 3272bcbd7d..00b45a1533 100644 --- a/src/apps/showimage/ShowImageApp.cpp +++ b/src/apps/showimage/ShowImageApp.cpp @@ -39,7 +39,7 @@ ShowImageApp::ShowImageApp() fPulseStarted(false), fLastWindowFrame(BRect(30, 30, 430, 330)) { - B_TRANSLATE_MARK_SYSTEM_NAME("ShowImage"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("ShowImage"); _UpdateLastWindowFrame(); // BBitmap can be created after there is a BApplication instance. init_tool_bar_icons(); @@ -198,7 +198,7 @@ ShowImageApp::_Open(const entry_ref& ref, const BMessenger& trackerMessenger) fLastWindowFrame.OffsetBy(20, 20); if (!BScreen(B_MAIN_SCREEN_ID).Frame().Contains(fLastWindowFrame)) fLastWindowFrame.OffsetTo(50, 50); - + new ShowImageWindow(fLastWindowFrame, ref, trackerMessenger); } diff --git a/src/apps/stylededit/StyledEditApp.cpp b/src/apps/stylededit/StyledEditApp.cpp index 7db87603cd..8aae8dc98b 100644 --- a/src/apps/stylededit/StyledEditApp.cpp +++ b/src/apps/stylededit/StyledEditApp.cpp @@ -89,8 +89,8 @@ StyledEditApp::StyledEditApp() BApplication(APP_SIGNATURE), fOpenPanel(NULL) { - B_TRANSLATE_MARK_SYSTEM_NAME("StyledEdit"); - + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("StyledEdit"); + fOpenPanel = new BFilePanel(); fOpenAsEncoding = 0; diff --git a/src/apps/tracker/main.cpp b/src/apps/tracker/main.cpp index c822f5e524..d23c132170 100644 --- a/src/apps/tracker/main.cpp +++ b/src/apps/tracker/main.cpp @@ -52,7 +52,7 @@ All rights reserved. int main(int , char **) { -#ifdef PROFILE +#ifdef PROFILE PROFILE_INIT(1024); #endif @@ -60,12 +60,12 @@ int main(int , char **) SetNewLeakChecking(true); SetMallocLeakChecking(true); #endif - B_TRANSLATE_MARK_SYSTEM_NAME("Tracker"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("Tracker"); TTracker tracker; tracker.Run(); -#ifdef PROFILE +#ifdef PROFILE PROFILE_DUMP("/boot/home/Desktop/trackerProfile"); #endif diff --git a/src/apps/tv/MainWin.cpp b/src/apps/tv/MainWin.cpp index 81dd427df0..ebe0b9d986 100644 --- a/src/apps/tv/MainWin.cpp +++ b/src/apps/tv/MainWin.cpp @@ -46,9 +46,9 @@ #undef B_TRANSLATE_CONTEXT #define B_TRANSLATE_CONTEXT "MainWin" -static const char* fLocalizedName = B_TRANSLATE_MARK("TV"); -static const char* fLocalizedRevision = B_TRANSLATE_MARK("unknown"); -static const char* fLocalizedInfo1 = B_TRANSLATE_MARK("DVB - Digital Video Broadcasting TV"); +B_TRANSLATE_MARK_VOID("TV"); +B_TRANSLATE_MARK_VOID("unknown"); +B_TRANSLATE_MARK_VOID("DVB - Digital Video Broadcasting TV"); enum { @@ -85,7 +85,7 @@ enum MainWin::MainWin(BRect frame_rect) : - BWindow(frame_rect, B_TRANSLATE_SYSTEM_NAME(NAME), B_TITLED_WINDOW, + BWindow(frame_rect, B_TRANSLATE_SYSTEM_NAME(NAME), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */) , fController(new Controller) , fIsFullscreen(false) @@ -103,9 +103,9 @@ MainWin::MainWin(BRect frame_rect) , fFrameResizedCalled(true) { BRect rect = Bounds(); - + // background - fBackground = new BView(rect, "background", B_FOLLOW_ALL, + fBackground = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); fBackground->SetViewColor(0,0,0); AddChild(fBackground); @@ -120,14 +120,14 @@ MainWin::MainWin(BRect frame_rect) // video view BRect video_rect = BRect(0, fMenuBarHeight, rect.right, rect.bottom); - fVideoView = new VideoView(video_rect, "video display", B_FOLLOW_ALL, + fVideoView = new VideoView(video_rect, "video display", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); fBackground->AddChild(fVideoView); fVideoView->MakeFocus(); // SetSizeLimits(fControlViewMinWidth - 1, 32767, -// fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight +// fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight // + fControlViewHeight - 1); // SetSizeLimits(320 - 1, 32767, 240 + fMenuBarHeight - 1, 32767); @@ -174,40 +174,40 @@ MainWin::CreateMenu() fMenuBar->AddItem(fSettingsMenu); fMenuBar->AddItem(fDebugMenu); - fFileMenu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), + fFileMenu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY)); /* - fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"), + fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"), new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY)); - fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"), + fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"), new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY)); fChannelMenu->AddSeparatorItem(); - fChannelMenu->AddItem(new BMenuItem("RTL", new BMessage(M_DUMMY), '0', + fChannelMenu->AddItem(new BMenuItem("RTL", new BMessage(M_DUMMY), '0', B_COMMAND_KEY)); - fChannelMenu->AddItem(new BMenuItem("Pro7", new BMessage(M_DUMMY), '1', + fChannelMenu->AddItem(new BMenuItem("Pro7", new BMessage(M_DUMMY), '1', B_COMMAND_KEY)); - fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none"), + fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none"), new BMessage(M_DUMMY))); - fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 1"), + fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 1"), new BMessage(M_DUMMY))); - fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 2"), + fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 2"), new BMessage(M_DUMMY))); */ - fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"), + fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"), new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY)); - fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Full screen"), + fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Full screen"), new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY)); fSettingsMenu->AddSeparatorItem(); - fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No menu"), + fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No menu"), new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY)); - fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No border"), + fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("No border"), new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY)); - fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Always on top"), + fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Always on top"), new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY)); - fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Keep aspect ratio"), + fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Keep aspect ratio"), new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY)); fSettingsMenu->AddSeparatorItem(); fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Settings"B_UTF8_ELLIPSIS) @@ -216,28 +216,28 @@ MainWin::CreateMenu() const char* pixel_ratio = B_TRANSLATE("pixel aspect ratio"); BString str1 = pixel_ratio; str1 << " 1.00000:1"; - fDebugMenu->AddItem(new BMenuItem(str1.String(), + fDebugMenu->AddItem(new BMenuItem(str1.String(), new BMessage(M_ASPECT_100000_1))); BString str2 = pixel_ratio; str2 << " 1.06666:1"; - fDebugMenu->AddItem(new BMenuItem(str2.String(), + fDebugMenu->AddItem(new BMenuItem(str2.String(), new BMessage(M_ASPECT_106666_1))); BString str3 = pixel_ratio; str3 << " 1.09091:1"; - fDebugMenu->AddItem(new BMenuItem(str3.String(), + fDebugMenu->AddItem(new BMenuItem(str3.String(), new BMessage(M_ASPECT_109091_1))); BString str4 = pixel_ratio; str4 << " 1.41176:1"; - fDebugMenu->AddItem(new BMenuItem(str4.String(), + fDebugMenu->AddItem(new BMenuItem(str4.String(), new BMessage(M_ASPECT_141176_1))); fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( - "force 720 x 576, display aspect 4:3"), + "force 720 x 576, display aspect 4:3"), new BMessage(M_ASPECT_720_576))); fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( - "force 704 x 576, display aspect 4:3"), + "force 704 x 576, display aspect 4:3"), new BMessage(M_ASPECT_704_576))); fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( - "force 544 x 576, display aspect 4:3"), + "force 544 x 576, display aspect 4:3"), new BMessage(M_ASPECT_544_576))); fSettingsMenu->ItemAt(1)->SetMarked(fIsFullscreen); @@ -255,7 +255,7 @@ MainWin::SetupInterfaceMenu() { fInterfaceMenu->RemoveItems(0, fInterfaceMenu->CountItems(), true); - fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), + fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), new BMessage(M_SELECT_INTERFACE))); int count = gDeviceRoster->DeviceCount(); @@ -264,9 +264,9 @@ MainWin::SetupInterfaceMenu() fInterfaceMenu->AddSeparatorItem(); for (int i = 0; i < count; i++) { - // 1 gets subtracted in MessageReceived, so -1 is Interface None, + // 1 gets subtracted in MessageReceived, so -1 is Interface None, // and 0 == Interface 0 in SelectInterface() - fInterfaceMenu->AddItem(new BMenuItem(gDeviceRoster->DeviceName(i), + fInterfaceMenu->AddItem(new BMenuItem(gDeviceRoster->DeviceName(i), new BMessage(M_SELECT_INTERFACE + i + 1))); } } @@ -283,12 +283,12 @@ MainWin::SetupChannelMenu() int channels = fController->ChannelCount(); if (channels == 0) { - fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), + fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), new BMessage(M_DUMMY))); } else { - fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"), + fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Next channel"), new BMessage(M_CHANNEL_NEXT), '+', B_COMMAND_KEY)); - fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"), + fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("Previous channel"), new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY)); fChannelMenu->AddSeparatorItem(); } @@ -405,7 +405,7 @@ MainWin::SelectInitialInterface() int count = gDeviceRoster->DeviceCount(); for (int i = 0; i < count; i++) { - if (fController->IsInterfaceAvailable(i) + if (fController->IsInterfaceAvailable(i) && B_OK == fController->ConnectInterface(i)) { printf("MainWin::SelectInitialInterface connected to interface " "%d\n", i); @@ -431,7 +431,7 @@ MainWin::MouseDown(BMessage *msg) BPoint screen_where; uint32 buttons = msg->FindInt32("buttons"); - // On Zeta, only "screen_where" is relyable, "where" and "be:view_where" + // On Zeta, only "screen_where" is relyable, "where" and "be:view_where" // seem to be broken if (B_OK != msg->FindPoint("screen_where", &screen_where)) { // Workaround for BeOS R5, it has no "screen_where" @@ -444,7 +444,7 @@ MainWin::MouseDown(BMessage *msg) // if (1 == msg->FindInt32("buttons") && msg->FindInt32("clicks") == 1) { if (1 == buttons && msg->FindInt32("clicks") % 2 == 0) { - BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, + BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1); if (r.Contains(fMouseDownMousePos)) { PostMessage(M_TOGGLE_FULLSCREEN); @@ -453,7 +453,7 @@ MainWin::MouseDown(BMessage *msg) } if (2 == buttons && msg->FindInt32("clicks") % 2 == 0) { - BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, + BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1); if (r.Contains(fMouseDownMousePos)) { PostMessage(M_TOGGLE_NO_BORDER_NO_MENU); @@ -471,7 +471,7 @@ MainWin::MouseDown(BMessage *msg) if (buttons == 1 && !fIsFullscreen) { // start mouse tracking - fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY + fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY /* | B_LOCK_WINDOW_FOCUS */); fMouseDownTracking = true; } @@ -510,7 +510,7 @@ MainWin::MouseMoved(BMessage *msg) printf("view where: %.0f, %.0f => ", mousePos.x, mousePos.y); fVideoView->ConvertToScreen(&mousePos); */ - // On Zeta, only "screen_where" is relyable, "where" and + // On Zeta, only "screen_where" is relyable, "where" and // "be:view_where" seem to be broken if (B_OK != msg->FindPoint("screen_where", &mousePos)) { // Workaround for BeOS R5, it has no "screen_where" @@ -542,65 +542,65 @@ MainWin::ShowContextMenu(const BPoint &screen_point) printf("Show context menu\n"); BPopUpMenu *menu = new BPopUpMenu("context menu", false, false); BMenuItem *item; - menu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"), + menu->AddItem(new BMenuItem(B_TRANSLATE("Scale to native size"), new BMessage(M_SCALE_TO_NATIVE_SIZE), 'N', B_COMMAND_KEY)); - menu->AddItem(item = new BMenuItem(B_TRANSLATE("Full screen"), + menu->AddItem(item = new BMenuItem(B_TRANSLATE("Full screen"), new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY)); item->SetMarked(fIsFullscreen); menu->AddSeparatorItem(); - menu->AddItem(item = new BMenuItem(B_TRANSLATE("No menu"), + menu->AddItem(item = new BMenuItem(B_TRANSLATE("No menu"), new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY)); item->SetMarked(fNoMenu); - menu->AddItem(item = new BMenuItem(B_TRANSLATE("No border"), + menu->AddItem(item = new BMenuItem(B_TRANSLATE("No border"), new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY)); item->SetMarked(fNoBorder); - menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"), + menu->AddItem(item = new BMenuItem(B_TRANSLATE("Always on top"), new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY)); item->SetMarked(fAlwaysOnTop); - menu->AddItem(item = new BMenuItem(B_TRANSLATE("Keep aspect ratio"), + menu->AddItem(item = new BMenuItem(B_TRANSLATE("Keep aspect ratio"), new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY)); item->SetMarked(fKeepAspectRatio); menu->AddSeparatorItem(); - menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), + menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY)); menu->AddSeparatorItem(); const char* pixel_aspect = "pixel aspect ratio"; BString str1 = pixel_aspect; str1 << " 1.00000:1"; - menu->AddItem(new BMenuItem(str1.String(), + menu->AddItem(new BMenuItem(str1.String(), new BMessage(M_ASPECT_100000_1))); BString str2 = pixel_aspect; str2 << " 1.06666:1"; - menu->AddItem(new BMenuItem(str2.String(), + menu->AddItem(new BMenuItem(str2.String(), new BMessage(M_ASPECT_106666_1))); BString str3 = pixel_aspect; str3 << " 1.09091:1"; - menu->AddItem(new BMenuItem(str3.String(), + menu->AddItem(new BMenuItem(str3.String(), new BMessage(M_ASPECT_109091_1))); BString str4 = pixel_aspect; str4 << " 1.41176:1"; - menu->AddItem(new BMenuItem(str4.String(), + menu->AddItem(new BMenuItem(str4.String(), new BMessage(M_ASPECT_141176_1))); menu->AddItem(new BMenuItem(B_TRANSLATE( - "force 720 x 576, display aspect 4:3"), + "force 720 x 576, display aspect 4:3"), new BMessage(M_ASPECT_720_576))); menu->AddItem(new BMenuItem(B_TRANSLATE( - "force 704 x 576, display aspect 4:3"), + "force 704 x 576, display aspect 4:3"), new BMessage(M_ASPECT_704_576))); menu->AddItem(new BMenuItem(B_TRANSLATE( - "force 544 x 576, display aspect 4:3"), + "force 544 x 576, display aspect 4:3"), new BMessage(M_ASPECT_544_576))); menu->SetTargetForItems(this); - BRect r(screen_point.x - 5, screen_point.y - 5, screen_point.x + 5, + BRect r(screen_point.x - 5, screen_point.y - 5, screen_point.x + 5, screen_point.y + 5); menu->Go(screen_point, true, true, r, true); } void -MainWin::VideoFormatChange(int width, int height, float width_scale, +MainWin::VideoFormatChange(int width, int height, float width_scale, float height_scale) { // called when video format or aspect ratio changes @@ -611,7 +611,7 @@ MainWin::VideoFormatChange(int width, int height, float width_scale, if (width_scale < 1.0 && height_scale >= 1.0) { width_scale = 1.0 / width_scale; height_scale = 1.0 / height_scale; - printf("inverting! new values: width_scale %.6f, height_scale %.6f\n", + printf("inverting! new values: width_scale %.6f, height_scale %.6f\n", width_scale, height_scale); } @@ -652,7 +652,7 @@ MainWin::FrameResized(float new_width, float new_height) printf("FrameResized enter: new_width %.0f, new_height %.0f, bounds width " - "%.0f, bounds height %.0f\n", new_width, new_height, Bounds().Width(), + "%.0f, bounds height %.0f\n", new_width, new_height, Bounds().Width(), Bounds().Height()); if (fIsFullscreen) { @@ -715,7 +715,7 @@ MainWin::AdjustFullscreenRenderer() float max_height = fBackground->Bounds().Height() + 1.0f; float scaled_width = fSourceWidth * fWidthScale; float scaled_height = fSourceHeight * fHeightScale; - float factor = min_c(max_width / scaled_width, max_height + float factor = min_c(max_width / scaled_width, max_height / scaled_height); int render_width = int(scaled_width * factor); int render_height = int(scaled_height * factor); @@ -724,8 +724,8 @@ MainWin::AdjustFullscreenRenderer() printf("AdjustFullscreenRenderer: background %.1f x %.1f, src video " "%d x %d, scaled video %.3f x %.3f, factor %.3f, render %d x %d, " - "x-ofs %d, y-ofs %d\n", max_width, max_height, fSourceWidth, - fSourceHeight, scaled_width, scaled_height, factor, render_width, + "x-ofs %d, y-ofs %d\n", max_width, max_height, fSourceWidth, + fSourceHeight, scaled_width, scaled_height, factor, render_width, render_height, x_ofs, y_ofs); fVideoView->MoveTo(x_ofs, y_ofs); @@ -738,7 +738,7 @@ MainWin::AdjustFullscreenRenderer() // no need to keep aspect ratio, make // render cover the whole background fVideoView->MoveTo(0, 0); - fVideoView->ResizeTo(fBackground->Bounds().Width(), + fVideoView->ResizeTo(fBackground->Bounds().Width(), fBackground->Bounds().Height()); } @@ -753,7 +753,7 @@ MainWin::AdjustWindowedRenderer(bool user_resized) // In windowed mode, the renderer always covers the // whole background, accounting for the menu fVideoView->MoveTo(0, fNoMenu ? 0 : fMenuBarHeight); - fVideoView->ResizeTo(fBackground->Bounds().Width(), + fVideoView->ResizeTo(fBackground->Bounds().Width(), fBackground->Bounds().Height() - (fNoMenu ? 0 : fMenuBarHeight)); if (fKeepAspectRatio) { @@ -761,19 +761,19 @@ MainWin::AdjustWindowedRenderer(bool user_resized) // do resize the window as required float max_width = Bounds().Width() + 1.0f; - float max_height = Bounds().Height() + 1.0f - (fNoMenu ? 0 + float max_height = Bounds().Height() + 1.0f - (fNoMenu ? 0 : fMenuBarHeight); float scaled_width = fSourceWidth * fWidthScale; float scaled_height = fSourceHeight * fHeightScale; - if (!user_resized && (scaled_width > max_width + if (!user_resized && (scaled_width > max_width || scaled_height > max_height)) { // A format switch occured, and the window was // smaller then the video source. As it was not // initiated by the user resizing the window, we // enlarge the window to fit the video. fIgnoreFrameResized = true; - ResizeTo(scaled_width - 1, scaled_height - 1 + ResizeTo(scaled_width - 1, scaled_height - 1 + (fNoMenu ? 0 : fMenuBarHeight)); // Sync(); return; @@ -785,12 +785,12 @@ MainWin::AdjustWindowedRenderer(bool user_resized) printf("AdjustWindowedRenderer: old display %d x %d, src video " "%d x %d, scaled video %.3f x %.3f, aspect ratio %.3f, new " - "display %d x %d\n", int(max_width), int(max_height), + "display %d x %d\n", int(max_width), int(max_height), fSourceWidth, fSourceHeight, scaled_width, scaled_height, display_aspect_ratio, new_width, new_height); fIgnoreFrameResized = true; - ResizeTo(new_width - 1, new_height - 1 + (fNoMenu ? 0 + ResizeTo(new_width - 1, new_height - 1 + (fNoMenu ? 0 : fMenuBarHeight)); // Sync(); } @@ -839,8 +839,8 @@ MainWin::ToggleFullscreen() // Sync(); fSavedFrame = Frame(); - printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left), - int(fSavedFrame.top), int(fSavedFrame.right), + printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left), + int(fSavedFrame.top), int(fSavedFrame.right), int(fSavedFrame.bottom)); BScreen screen(this); BRect rect(screen.Frame()); @@ -970,7 +970,7 @@ MainWin::KeyDown(BMessage *msg) uint32 raw_char = msg->FindInt32("raw_char"); uint32 modifiers = msg->FindInt32("modifiers"); - printf("key 0x%lx, raw_char 0x%lx, modifiers 0x%lx\n", key, raw_char, + printf("key 0x%lx, raw_char 0x%lx, modifiers 0x%lx\n", key, raw_char, modifiers); switch (raw_char) { @@ -993,7 +993,7 @@ MainWin::KeyDown(BMessage *msg) break; case B_TAB: - if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY + if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY | B_MENU_KEY)) == 0) { PostMessage(M_TOGGLE_FULLSCREEN); return B_OK; @@ -1086,17 +1086,17 @@ MainWin::KeyDown(BMessage *msg) void MainWin::DispatchMessage(BMessage *msg, BHandler *handler) { - if ((msg->what == B_MOUSE_DOWN) && (handler == fBackground + if ((msg->what == B_MOUSE_DOWN) && (handler == fBackground || handler == fVideoView)) MouseDown(msg); - if ((msg->what == B_MOUSE_MOVED) && (handler == fBackground + if ((msg->what == B_MOUSE_MOVED) && (handler == fBackground || handler == fVideoView)) MouseMoved(msg); - if ((msg->what == B_MOUSE_UP) && (handler == fBackground + if ((msg->what == B_MOUSE_UP) && (handler == fBackground || handler == fVideoView)) MouseUp(msg); - if ((msg->what == B_KEY_DOWN) && (handler == fBackground + if ((msg->what == B_KEY_DOWN) && (handler == fBackground || handler == fVideoView)) { // special case for PrintScreen key @@ -1229,7 +1229,7 @@ MainWin::MessageReceived(BMessage *msg) ToggleFullscreen(); } ResizeTo(int(fSourceWidth * fWidthScale), - int(fSourceHeight * fHeightScale) + (fNoMenu ? 0 + int(fSourceHeight * fHeightScale) + (fNoMenu ? 0 : fMenuBarHeight)); // Sync(); break; @@ -1267,12 +1267,12 @@ MainWin::MessageReceived(BMessage *msg) break; default: - if (msg->what >= M_SELECT_CHANNEL + if (msg->what >= M_SELECT_CHANNEL && msg->what <= M_SELECT_CHANNEL_END) { SelectChannel(msg->what - M_SELECT_CHANNEL); break; } - if (msg->what >= M_SELECT_INTERFACE + if (msg->what >= M_SELECT_INTERFACE && msg->what <= M_SELECT_INTERFACE_END) { SelectInterface(msg->what - M_SELECT_INTERFACE - 1); break; diff --git a/src/apps/webwatch/WatchApp.cpp b/src/apps/webwatch/WatchApp.cpp index 1001297758..4aa508c672 100644 --- a/src/apps/webwatch/WatchApp.cpp +++ b/src/apps/webwatch/WatchApp.cpp @@ -1,22 +1,22 @@ /* * Copyright (c) 1999-2003 Matthijs Hollemans - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in + * + * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ @@ -37,7 +37,7 @@ BView* instantiate_deskbar_item() WatchApp::WatchApp() : BApplication(APP_SIGNATURE) { - B_TRANSLATE_MARK_SYSTEM_NAME("WebWatch"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("WebWatch"); // Here we tell the Deskbar that we want to add a new replicant, and // where it can find this replicant (in our app). Because we only run @@ -52,13 +52,13 @@ WatchApp::WatchApp() : BApplication(APP_SIGNATURE) be_roster->FindApp(APP_SIGNATURE, &ref); deskbar.AddItem(&ref); } - + PostMessage(B_QUIT_REQUESTED); } /////////////////////////////////////////////////////////////////////////////// -int main() +int main() { WatchApp watchApp; watchApp.Run(); diff --git a/src/bin/locale/dumpcatalog.cpp b/src/bin/locale/dumpcatalog.cpp index c771940c8d..b1f58b6054 100644 --- a/src/bin/locale/dumpcatalog.cpp +++ b/src/bin/locale/dumpcatalog.cpp @@ -51,7 +51,7 @@ main(int argc, char **argv) exit(-1); } DefaultCatalog* inputCatImpl - = dynamic_cast(inputCatalog.CatalogAddOn()); + = dynamic_cast(inputCatalog.CatalogData()); if (!inputCatImpl) { fprintf(stderr, "couldn't access impl of input-catalog %s\n", inputFile); diff --git a/src/bin/locale/linkcatkeys.cpp b/src/bin/locale/linkcatkeys.cpp index a9987a570f..0fe8ac9b2f 100644 --- a/src/bin/locale/linkcatkeys.cpp +++ b/src/bin/locale/linkcatkeys.cpp @@ -100,7 +100,7 @@ main(int argc, char **argv) exit(-1); } DefaultCatalog* targetCatImpl - = dynamic_cast(targetCatalog.CatalogAddOn()); + = dynamic_cast(targetCatalog.CatalogData()); if (!targetCatImpl) { fprintf(stderr, "couldn't access impl of target-catalog %s\n", outputFile.String()); @@ -116,7 +116,7 @@ main(int argc, char **argv) exit(-1); } HashMapCatalog* inputCatImpl - = dynamic_cast(inputCatalog.CatalogAddOn()); + = dynamic_cast(inputCatalog.CatalogData()); if (!inputCatImpl) { fprintf(stderr, "couldn't access impl of input-catalog %s\n", inputFiles[i]); diff --git a/src/kits/locale/Catalog.cpp b/src/kits/locale/Catalog.cpp index a80c85478b..f2ec81a889 100644 --- a/src/kits/locale/Catalog.cpp +++ b/src/kits/locale/Catalog.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,7 @@ using BPrivate::MutableLocaleRoster; //#pragma mark - BCatalog BCatalog::BCatalog() : - fCatalog(NULL), + fCatalogData(NULL), fLock("Catalog") { } @@ -31,7 +32,7 @@ BCatalog::BCatalog() BCatalog::BCatalog(const entry_ref& catalogOwner, const char* language, uint32 fingerprint) : - fCatalog(NULL), + fCatalogData(NULL), fLock("Catalog") { SetTo(catalogOwner, language, fingerprint); @@ -40,7 +41,7 @@ BCatalog::BCatalog(const entry_ref& catalogOwner, const char* language, BCatalog::~BCatalog() { - MutableLocaleRoster::Default()->UnloadCatalog(fCatalog); + MutableLocaleRoster::Default()->UnloadCatalog(fCatalogData); } @@ -53,7 +54,7 @@ BCatalog::GetString(const char* string, const char* context, return string; const char* translated; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { translated = cat->GetString(string, context, comment); if (translated != NULL) return translated; @@ -71,7 +72,7 @@ BCatalog::GetString(uint32 id) return ""; const char* translated; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { translated = cat->GetString(id); if (translated != NULL) return translated; @@ -88,11 +89,11 @@ BCatalog::GetData(const char* name, BMessage* msg) if (!lock.IsLocked()) return B_ERROR; - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; status_t res; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { res = cat->GetData(name, msg); if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) return res; // return B_OK if found, or specific error-code @@ -109,11 +110,11 @@ BCatalog::GetData(uint32 id, BMessage* msg) if (!lock.IsLocked()) return B_ERROR; - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; status_t res; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { res = cat->GetData(id, msg); if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) return res; // return B_OK if found, or specific error-code @@ -133,10 +134,10 @@ BCatalog::GetSignature(BString* sig) if (sig == NULL) return B_BAD_VALUE; - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - *sig = fCatalog->fSignature; + *sig = fCatalogData->fSignature; return B_OK; } @@ -152,10 +153,10 @@ BCatalog::GetLanguage(BString* lang) if (lang == NULL) return B_BAD_VALUE; - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - *lang = fCatalog->fLanguageName; + *lang = fCatalogData->fLanguageName; return B_OK; } @@ -171,10 +172,10 @@ BCatalog::GetFingerprint(uint32* fp) if (fp == NULL) return B_BAD_VALUE; - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - *fp = fCatalog->fFingerprint; + *fp = fCatalogData->fFingerprint; return B_OK; } @@ -188,8 +189,8 @@ BCatalog::SetTo(const entry_ref& catalogOwner, const char* language, if (!lock.IsLocked()) return B_ERROR; - MutableLocaleRoster::Default()->UnloadCatalog(fCatalog); - fCatalog = MutableLocaleRoster::Default()->LoadCatalog(catalogOwner, + MutableLocaleRoster::Default()->UnloadCatalog(fCatalogData); + fCatalogData = MutableLocaleRoster::Default()->LoadCatalog(catalogOwner, language, fingerprint); return B_OK; @@ -203,7 +204,7 @@ BCatalog::InitCheck() const if (!lock.IsLocked()) return B_ERROR; - return fCatalog != NULL ? fCatalog->InitCheck() : B_NO_INIT; + return fCatalogData != NULL ? fCatalogData->InitCheck() : B_NO_INIT; } @@ -214,159 +215,5 @@ BCatalog::CountItems() const if (!lock.IsLocked()) return 0; - return fCatalog != NULL ? fCatalog->CountItems() : 0; -} - - -//#pragma mark - BCatalogAddOn -BCatalogAddOn::BCatalogAddOn(const char* signature, const char* language, - uint32 fingerprint) - : - fInitCheck(B_NO_INIT), - fSignature(signature), - fLanguageName(language), - fFingerprint(fingerprint), - fNext(NULL) -{ - fLanguageName.ToLower(); - // canonicalize language-name to lowercase -} - - -BCatalogAddOn::~BCatalogAddOn() -{ -} - - -void -BCatalogAddOn::UpdateFingerprint() -{ - fFingerprint = 0; - // base implementation always yields the same fingerprint, - // which means that no version-mismatch detection is possible. -} - - -status_t -BCatalogAddOn::InitCheck() const -{ - return fInitCheck; -} - - -bool -BCatalogAddOn::CanHaveData() const -{ - return false; -} - - -status_t -BCatalogAddOn::GetData(const char* name, BMessage* msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::GetData(uint32 id, BMessage* msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::SetString(const char* string, const char* translated, - const char* context, const char* comment) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::SetString(int32 id, const char* translated) -{ - return EOPNOTSUPP; -} - - -bool -BCatalogAddOn::CanWriteData() const -{ - return false; -} - - -status_t -BCatalogAddOn::SetData(const char* name, BMessage* msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::SetData(uint32 id, BMessage* msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::ReadFromFile(const char* path) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::ReadFromAttribute(const entry_ref& appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::ReadFromResource(const entry_ref& appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::WriteToFile(const char* path) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::WriteToAttribute(const entry_ref& appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::WriteToResource(const entry_ref& appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -void BCatalogAddOn::MakeEmpty() -{ -} - - -int32 -BCatalogAddOn::CountItems() const -{ - return 0; -} - - -void -BCatalogAddOn::SetNext(BCatalogAddOn* next) -{ - fNext = next; + return fCatalogData != NULL ? fCatalogData->CountItems() : 0; } diff --git a/src/kits/locale/CatalogData.cpp b/src/kits/locale/CatalogData.cpp new file mode 100644 index 0000000000..39f0fcccbd --- /dev/null +++ b/src/kits/locale/CatalogData.cpp @@ -0,0 +1,160 @@ +/* + * Copyright 2003-2004, Axel Dörfler, axeld@pinc-software.de + * Copyright 2003-2004,2012, Oliver Tappe, zooey@hirschkaefer.de + * Distributed under the terms of the MIT License. + */ + +#include + + +BCatalogData::BCatalogData(const char* signature, const char* language, + uint32 fingerprint) + : + fInitCheck(B_NO_INIT), + fSignature(signature), + fLanguageName(language), + fFingerprint(fingerprint), + fNext(NULL) +{ + fLanguageName.ToLower(); + // canonicalize language-name to lowercase +} + + +BCatalogData::~BCatalogData() +{ +} + + +void +BCatalogData::UpdateFingerprint() +{ + fFingerprint = 0; + // base implementation always yields the same fingerprint, + // which means that no version-mismatch detection is possible. +} + + +status_t +BCatalogData::InitCheck() const +{ + return fInitCheck; +} + + +bool +BCatalogData::CanHaveData() const +{ + return false; +} + + +status_t +BCatalogData::GetData(const char* name, BMessage* msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::GetData(uint32 id, BMessage* msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::SetString(const char* string, const char* translated, + const char* context, const char* comment) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::SetString(int32 id, const char* translated) +{ + return EOPNOTSUPP; +} + + +bool +BCatalogData::CanWriteData() const +{ + return false; +} + + +status_t +BCatalogData::SetData(const char* name, BMessage* msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::SetData(uint32 id, BMessage* msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::ReadFromFile(const char* path) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::ReadFromAttribute(const entry_ref& appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::ReadFromResource(const entry_ref& appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::WriteToFile(const char* path) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::WriteToAttribute(const entry_ref& appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::WriteToResource(const entry_ref& appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +void BCatalogData::MakeEmpty() +{ +} + + +int32 +BCatalogData::CountItems() const +{ + return 0; +} + + +void +BCatalogData::SetNext(BCatalogData* next) +{ + fNext = next; +} diff --git a/src/kits/locale/DefaultCatalog.cpp b/src/kits/locale/DefaultCatalog.cpp index 8f332eeeff..dbb913d952 100644 --- a/src/kits/locale/DefaultCatalog.cpp +++ b/src/kits/locale/DefaultCatalog.cpp @@ -593,7 +593,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO) } -BCatalogAddOn * +BCatalogData * DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language, uint32 fingerprint) { @@ -607,7 +607,7 @@ DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language, } -BCatalogAddOn * +BCatalogData * DefaultCatalog::Create(const char *signature, const char *language) { DefaultCatalog *catalog diff --git a/src/kits/locale/EditableCatalog.cpp b/src/kits/locale/EditableCatalog.cpp index 79263bfee3..b678dab47f 100644 --- a/src/kits/locale/EditableCatalog.cpp +++ b/src/kits/locale/EditableCatalog.cpp @@ -6,6 +6,7 @@ #include +#include #include @@ -16,8 +17,8 @@ namespace BPrivate { EditableCatalog::EditableCatalog(const char* type, const char* signature, const char* language) { - fCatalog = MutableLocaleRoster::Default()->CreateCatalog(type, signature, - language); + fCatalogData = MutableLocaleRoster::Default()->CreateCatalog(type, + signature, language); } @@ -30,124 +31,124 @@ status_t EditableCatalog::SetString(const char* string, const char* translated, const char* context, const char* comment) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->SetString(string, translated, context, comment); + return fCatalogData->SetString(string, translated, context, comment); } status_t EditableCatalog::SetString(int32 id, const char* translated) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->SetString(id, translated); + return fCatalogData->SetString(id, translated); } bool EditableCatalog::CanWriteData() const { - if (fCatalog == NULL) + if (fCatalogData == NULL) return false; - return fCatalog->CanWriteData(); + return fCatalogData->CanWriteData(); } status_t EditableCatalog::SetData(const char* name, BMessage* msg) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->SetData(name, msg); + return fCatalogData->SetData(name, msg); } status_t EditableCatalog::SetData(uint32 id, BMessage* msg) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->SetData(id, msg); + return fCatalogData->SetData(id, msg); } status_t EditableCatalog::ReadFromFile(const char* path) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->ReadFromFile(path); + return fCatalogData->ReadFromFile(path); } status_t EditableCatalog::ReadFromAttribute(const entry_ref& appOrAddOnRef) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->ReadFromAttribute(appOrAddOnRef); + return fCatalogData->ReadFromAttribute(appOrAddOnRef); } status_t EditableCatalog::ReadFromResource(const entry_ref& appOrAddOnRef) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->ReadFromResource(appOrAddOnRef); + return fCatalogData->ReadFromResource(appOrAddOnRef); } status_t EditableCatalog::WriteToFile(const char* path) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->WriteToFile(path); + return fCatalogData->WriteToFile(path); } status_t EditableCatalog::WriteToAttribute(const entry_ref& appOrAddOnRef) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->WriteToAttribute(appOrAddOnRef); + return fCatalogData->WriteToAttribute(appOrAddOnRef); } status_t EditableCatalog::WriteToResource(const entry_ref& appOrAddOnRef) { - if (fCatalog == NULL) + if (fCatalogData == NULL) return B_NO_INIT; - return fCatalog->WriteToResource(appOrAddOnRef); + return fCatalogData->WriteToResource(appOrAddOnRef); } void EditableCatalog::MakeEmpty() { - if (fCatalog == NULL) - fCatalog->MakeEmpty(); + if (fCatalogData == NULL) + fCatalogData->MakeEmpty(); } -BCatalogAddOn* -EditableCatalog::CatalogAddOn() +BCatalogData* +EditableCatalog::CatalogData() { - return fCatalog; + return fCatalogData; } diff --git a/src/kits/locale/HashMapCatalog.cpp b/src/kits/locale/HashMapCatalog.cpp index 6ae6bd1be2..1681fefc34 100644 --- a/src/kits/locale/HashMapCatalog.cpp +++ b/src/kits/locale/HashMapCatalog.cpp @@ -20,7 +20,7 @@ namespace BPrivate { * reading and writing the catalog to a file. Classes doing that are * HashMapCatalog and PlainTextCatalog. * If you ever need to create a catalog not built around an hash map, inherit - * BCatalogAddOn instead. Note that in this case you will not be able to use our + * BCatalogData instead. Note that in this case you will not be able to use our * development tools anymore. */ diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index 70b258c38c..007f6e9b9f 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -8,6 +8,7 @@ UsePublicHeaders locale storage ; local sources = cat.cpp Catalog.cpp + CatalogData.cpp Collator.cpp Country.cpp DefaultCatalog.cpp diff --git a/src/kits/locale/MutableLocaleRoster.cpp b/src/kits/locale/MutableLocaleRoster.cpp index e2b3ca0353..3d51c99723 100644 --- a/src/kits/locale/MutableLocaleRoster.cpp +++ b/src/kits/locale/MutableLocaleRoster.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2003-2010, Haiku. All rights reserved. + * Copyright 2003-2012, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -67,8 +67,8 @@ CatalogAddOnInfo::~CatalogAddOnInfo() { int32 count = fLoadedCatalogs.CountItems(); for (int32 i = 0; i < count; ++i) { - BCatalogAddOn* cat - = static_cast(fLoadedCatalogs.ItemAt(i)); + BCatalogData* cat + = static_cast(fLoadedCatalogs.ItemAt(i)); delete cat; } fLoadedCatalogs.MakeEmpty(); @@ -817,7 +817,7 @@ MutableLocaleRoster::LoadSystemCatalog(BCatalog* catalog) const * Any created catalog will be initialized with the given signature and * language-name. */ -BCatalogAddOn* +BCatalogData* MutableLocaleRoster::CreateCatalog(const char* type, const char* signature, const char* language) { @@ -836,7 +836,7 @@ MutableLocaleRoster::CreateCatalog(const char* type, const char* signature, || !info->fCreateFunc) continue; - BCatalogAddOn* catalog = info->fCreateFunc(signature, language); + BCatalogData* catalog = info->fCreateFunc(signature, language); if (catalog) { info->fLoadedCatalogs.AddItem(catalog); info->UnloadIfPossible(); @@ -858,7 +858,7 @@ MutableLocaleRoster::CreateCatalog(const char* type, const char* signature, * instead of a single catalog. * NULL is returned if no matching catalog could be found. */ -BCatalogAddOn* +BCatalogData* MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner, const char* language, int32 fingerprint) const { @@ -881,7 +881,7 @@ MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner, // try to load catalogs for one of the preferred languages: GetPreferredLanguages(&languages); - BCatalogAddOn* catalog = NULL; + BCatalogData* catalog = NULL; const char* lang; for (int32 l=0; languages.FindString("language", l, &lang)==B_OK; ++l) { catalog = info->fInstantiateFunc(catalogOwner, lang, fingerprint); @@ -895,8 +895,8 @@ MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner, // to "english"): int32 pos; BString langName(lang); - BCatalogAddOn* currCatalog = catalog; - BCatalogAddOn* nextCatalog = NULL; + BCatalogData* currCatalog = catalog; + BCatalogData* nextCatalog = NULL; while ((pos = langName.FindLast('_')) >= 0) { // language is based on parent, so we load that, too: // (even if the parent catalog was not found) @@ -928,7 +928,7 @@ MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner, * Add-ons that have no more current catalogs are unloaded, too. */ status_t -MutableLocaleRoster::UnloadCatalog(BCatalogAddOn* catalog) +MutableLocaleRoster::UnloadCatalog(BCatalogData* catalog) { if (!catalog) return B_BAD_VALUE; @@ -938,7 +938,7 @@ MutableLocaleRoster::UnloadCatalog(BCatalogAddOn* catalog) return B_ERROR; status_t res = B_ERROR; - BCatalogAddOn* nextCatalog; + BCatalogData* nextCatalog; while (catalog != NULL) { nextCatalog = catalog->Next(); diff --git a/src/preferences/cpufrequency/StatusView.cpp b/src/preferences/cpufrequency/StatusView.cpp index 3f85a1a884..859954edef 100644 --- a/src/preferences/cpufrequency/StatusView.cpp +++ b/src/preferences/cpufrequency/StatusView.cpp @@ -42,18 +42,16 @@ extern "C" _EXPORT BView *instantiate_deskbar_item(void); * and then collectcatkeys will not see the strings in the file. * So we mark them explicitly here. */ -void notUsed() { - B_TRANSLATE_MARK("Dynamic performance"); - B_TRANSLATE_MARK("High performance"); - B_TRANSLATE_MARK("Low energy"); - B_TRANSLATE_MARK("Set state"); - B_TRANSLATE_MARK("CPUFrequency\n" - "\twritten by Clemens Zeidler\n" - "\tCopyright 2009, Haiku, Inc.\n"); - B_TRANSLATE_MARK("Ok"); - B_TRANSLATE_MARK("Open Speedstep preferences" B_UTF8_ELLIPSIS); - B_TRANSLATE_MARK("Quit"); -} +B_TRANSLATE_MARK_VOID("Dynamic performance"); +B_TRANSLATE_MARK_VOID("High performance"); +B_TRANSLATE_MARK_VOID("Low energy"); +B_TRANSLATE_MARK_VOID("Set state"); +B_TRANSLATE_MARK_VOID("CPUFrequency\n" + "\twritten by Clemens Zeidler\n" + "\tCopyright 2009, Haiku, Inc.\n"); +B_TRANSLATE_MARK_VOID("Ok"); +B_TRANSLATE_MARK_VOID("Open Speedstep preferences" B_UTF8_ELLIPSIS); +B_TRANSLATE_MARK_VOID("Quit"); // messages FrequencySwitcher const uint32 kMsgDynamicPolicyPulse = '&dpp'; diff --git a/src/preferences/deskbar/DeskbarPreferences.cpp b/src/preferences/deskbar/DeskbarPreferences.cpp index 38f92064f1..644875da85 100644 --- a/src/preferences/deskbar/DeskbarPreferences.cpp +++ b/src/preferences/deskbar/DeskbarPreferences.cpp @@ -14,10 +14,10 @@ #include -int +int main(int argc, char **argv) { - B_TRANSLATE_MARK_SYSTEM_NAME("Deskbar"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("Deskbar"); BApplication app("application/x-vnd.Haiku-DeskbarPreferences"); be_roster->Launch("application/x-vnd.Be-TSKB", new BMessage(kConfigShow)); return 0; diff --git a/src/preferences/tracker/TrackerPreferences.cpp b/src/preferences/tracker/TrackerPreferences.cpp index 1128a75478..803bce49d1 100644 --- a/src/preferences/tracker/TrackerPreferences.cpp +++ b/src/preferences/tracker/TrackerPreferences.cpp @@ -11,20 +11,20 @@ #include -int +int main(int argc, char **argv) { - B_TRANSLATE_MARK_SYSTEM_NAME("Tracker"); + B_TRANSLATE_MARK_SYSTEM_NAME_VOID("Tracker"); BApplication app("application/x-vnd.Haiku-TrackerPreferences"); - + // launch Tracker if it's not running be_roster->Launch("application/x-vnd.Be-TRAK"); - - BMessage message; - message.what = B_EXECUTE_PROPERTY; + + BMessage message; + message.what = B_EXECUTE_PROPERTY; message.AddSpecifier("Preferences"); - + BMessenger("application/x-vnd.Be-TRAK").SendMessage(&message); - + return 0; } diff --git a/src/tools/locale/Catalog.cpp b/src/tools/locale/Catalog.cpp index f576b53e4b..77bc2bcabc 100644 --- a/src/tools/locale/Catalog.cpp +++ b/src/tools/locale/Catalog.cpp @@ -1,61 +1,52 @@ /* ** Distributed under the terms of the OpenBeOS License. -** Copyright 2003-2004. All rights reserved. +** Copyright 2003-2004,2012. All rights reserved. ** ** Authors: Axel Dörfler, axeld@pinc-software.de ** Oliver Tappe, zooey@hirschkaefer.de */ -#include - -#include #include -#include -#include -#include -#include +#include -BCatalog* be_catalog = NULL; - // catalog used by translation macros -BCatalog* be_app_catalog = NULL; - // app-catalog (useful for accessing app's catalog from inside an add-on, - // since in an add-on, be_catalog will hold the add-on's catalog. +// Provides an implementation of BCatalog for the build host, in effect only +// supporting setting and getting of catalog entries. -//#pragma mark - BCatalog BCatalog::BCatalog() : - fCatalog(NULL) + fCatalogData(NULL) { } BCatalog::BCatalog(const entry_ref& catalogOwner, const char *language, uint32 fingerprint) + : + fCatalogData(NULL) { - // Unsupported - the build tools can't (and don't need to) load anything - // this way. } BCatalog::~BCatalog() { - if (be_catalog == this) - be_app_catalog = be_catalog = NULL; - //be_locale_roster->UnloadCatalog(fCatalog); } const char * BCatalog::GetString(const char *string, const char *context, const char *comment) { + if (fCatalogData == 0) + return string; + const char *translated; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { translated = cat->GetString(string, context, comment); if (translated) return translated; } + return string; } @@ -63,12 +54,16 @@ BCatalog::GetString(const char *string, const char *context, const char *comment const char * BCatalog::GetString(uint32 id) { + if (fCatalogData == 0) + return ""; + const char *translated; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { translated = cat->GetString(id); if (translated) return translated; } + return ""; } @@ -76,15 +71,17 @@ BCatalog::GetString(uint32 id) status_t BCatalog::GetData(const char *name, BMessage *msg) { - if (!fCatalog) + if (fCatalogData == 0) return B_NO_INIT; + status_t res; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { res = cat->GetData(name, msg); if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) return res; // return B_OK if found, or specific error-code } + return B_NAME_NOT_FOUND; } @@ -92,161 +89,16 @@ BCatalog::GetData(const char *name, BMessage *msg) status_t BCatalog::GetData(uint32 id, BMessage *msg) { - if (!fCatalog) + if (fCatalogData == 0) return B_NO_INIT; + status_t res; - for (BCatalogAddOn* cat = fCatalog; cat != NULL; cat = cat->fNext) { + for (BCatalogData* cat = fCatalogData; cat != NULL; cat = cat->fNext) { res = cat->GetData(id, msg); if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) return res; // return B_OK if found, or specific error-code } + return B_NAME_NOT_FOUND; } - - -//#pragma mark - BCatalogAddOn -BCatalogAddOn::BCatalogAddOn(const char *signature, const char *language, - uint32 fingerprint) - : - fInitCheck(B_NO_INIT), - fSignature(signature), - fLanguageName(language), - fFingerprint(fingerprint), - fNext(NULL) -{ - fLanguageName.ToLower(); - // canonicalize language-name to lowercase -} - - -BCatalogAddOn::~BCatalogAddOn() -{ -} - - -void -BCatalogAddOn::UpdateFingerprint() -{ - fFingerprint = 0; - // base implementation always yields the same fingerprint, - // which means that no version-mismatch detection is possible. -} - - -status_t -BCatalogAddOn::InitCheck() const -{ - return fInitCheck; -} - - -bool -BCatalogAddOn::CanHaveData() const -{ - return false; -} - - -status_t -BCatalogAddOn::GetData(const char *name, BMessage *msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::GetData(uint32 id, BMessage *msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::SetString(const char *string, const char *translated, - const char *context, const char *comment) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::SetString(int32 id, const char *translated) -{ - return EOPNOTSUPP; -} - - -bool -BCatalogAddOn::CanWriteData() const -{ - return false; -} - - -status_t -BCatalogAddOn::SetData(const char *name, BMessage *msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::SetData(uint32 id, BMessage *msg) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::ReadFromFile(const char *path) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::ReadFromAttribute(const entry_ref &appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::ReadFromResource(const entry_ref &appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::WriteToFile(const char *path) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::WriteToAttribute(const entry_ref &appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -status_t -BCatalogAddOn::WriteToResource(const entry_ref &appOrAddOnRef) -{ - return EOPNOTSUPP; -} - - -void BCatalogAddOn::MakeEmpty() -{ -} - - -int32 -BCatalogAddOn::CountItems() const -{ - return 0; -} diff --git a/src/tools/locale/CatalogData.cpp b/src/tools/locale/CatalogData.cpp new file mode 100644 index 0000000000..24904fef12 --- /dev/null +++ b/src/tools/locale/CatalogData.cpp @@ -0,0 +1,158 @@ +/* +** Distributed under the terms of the OpenBeOS License. +** Copyright 2003-2004,2012. All rights reserved. +** +** Authors: Axel Dörfler, axeld@pinc-software.de +** Oliver Tappe, zooey@hirschkaefer.de +*/ + +#include + + +// Provides an empty implementation of BCatalogData for the build host. + + +BCatalogData::BCatalogData(const char *signature, const char *language, + uint32 fingerprint) + : + fInitCheck(B_NO_INIT), + fSignature(signature), + fLanguageName(language), + fFingerprint(fingerprint), + fNext(NULL) +{ + fLanguageName.ToLower(); + // canonicalize language-name to lowercase +} + + +BCatalogData::~BCatalogData() +{ +} + + +void +BCatalogData::UpdateFingerprint() +{ + fFingerprint = 0; + // base implementation always yields the same fingerprint, + // which means that no version-mismatch detection is possible. +} + + +status_t +BCatalogData::InitCheck() const +{ + return fInitCheck; +} + + +bool +BCatalogData::CanHaveData() const +{ + return false; +} + + +status_t +BCatalogData::GetData(const char *name, BMessage *msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::GetData(uint32 id, BMessage *msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::SetString(const char *string, const char *translated, + const char *context, const char *comment) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::SetString(int32 id, const char *translated) +{ + return EOPNOTSUPP; +} + + +bool +BCatalogData::CanWriteData() const +{ + return false; +} + + +status_t +BCatalogData::SetData(const char *name, BMessage *msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::SetData(uint32 id, BMessage *msg) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::ReadFromFile(const char *path) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::ReadFromAttribute(const entry_ref &appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::ReadFromResource(const entry_ref &appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::WriteToFile(const char *path) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::WriteToAttribute(const entry_ref &appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +status_t +BCatalogData::WriteToResource(const entry_ref &appOrAddOnRef) +{ + return EOPNOTSUPP; +} + + +void BCatalogData::MakeEmpty() +{ +} + + +int32 +BCatalogData::CountItems() const +{ + return 0; +} diff --git a/src/tools/locale/DefaultCatalog.cpp b/src/tools/locale/DefaultCatalog.cpp index 4352a81353..f5c70cf1c1 100644 --- a/src/tools/locale/DefaultCatalog.cpp +++ b/src/tools/locale/DefaultCatalog.cpp @@ -401,7 +401,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO) } -BCatalogAddOn * +BCatalogData * DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language, uint32 fingerprint) { @@ -415,7 +415,7 @@ DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language, } -BCatalogAddOn * +BCatalogData * DefaultCatalog::Create(const char *signature, const char *language) { DefaultCatalog *catalog diff --git a/src/tools/locale/Jamfile b/src/tools/locale/Jamfile index 32fdc0ccef..1e47eaacc4 100644 --- a/src/tools/locale/Jamfile +++ b/src/tools/locale/Jamfile @@ -35,6 +35,7 @@ BuildPlatformMain collectcatkeys : PlainTextCatalog.cpp HashMapCatalog.cpp Catalog.cpp + CatalogData.cpp RegExp.cpp : $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ; @@ -44,4 +45,5 @@ BuildPlatformMain linkcatkeys : HashMapCatalog.cpp DefaultCatalog.cpp Catalog.cpp + CatalogData.cpp : $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ; diff --git a/src/tools/locale/PlainTextCatalog.cpp b/src/tools/locale/PlainTextCatalog.cpp index 3cdd94f5c2..df9186b36e 100644 --- a/src/tools/locale/PlainTextCatalog.cpp +++ b/src/tools/locale/PlainTextCatalog.cpp @@ -329,7 +329,7 @@ PlainTextCatalog::UpdateAttributes(const char* path) } -BCatalogAddOn * +BCatalogData * PlainTextCatalog::Instantiate(const char *signature, const char *language, uint32 fingerprint) { @@ -346,7 +346,7 @@ PlainTextCatalog::Instantiate(const char *signature, const char *language, } // namespace BPrivate -extern "C" BCatalogAddOn * +extern "C" BCatalogData * instantiate_catalog(const char *signature, const char *language, uint32 fingerprint) { @@ -360,9 +360,8 @@ instantiate_catalog(const char *signature, const char *language, } -extern "C" -BCatalogAddOn *create_catalog(const char *signature, - const char *language) +extern "C" BCatalogData * +create_catalog(const char *signature, const char *language) { PlainTextCatalog *catalog = new(std::nothrow) PlainTextCatalog("emptycat", signature, language);