hrev44037 adds 5 changesets to branch 'master' old head: 1cd97d5e869c263a900f17a7cd314d1df9186a1c new head: 248f2283dd5fcfc0bc79f26b84c8fdec9da7e60c ---------------------------------------------------------------------------- 16e5092: Extract EditableCatalog from Catalog.{h,cpp}. * move EditableCatalog to its own header and implementation file * move problematic BCatalog::CatalogAddOn() to EditableCatalog * adjust Locale tools accordingly 7ae67a9: Drop empty 'zeta' catalog add-on, wouldn't be useful anyway. 5ac65b7: More cleanup in locale kit, this time regarding namespaces. * it's bad practice to do a 'using <namespace>' in a header, as that is very likely to have unintended effects, so drop those from a couple of private Locale headers * adjust files all over the locale kit in order to fix the problems (by explicitly importing the required classes in the implementation files) 541ff51: 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 248f228: Final part of cleanup in Catalog.h. * move versions of the B_TRANSLATE_...-macros used during collecting of catalog keys to a specific header file, which will only be picked up when running collectcatkeys * fix a couple of build problems during the preprocessing of the libbe- sources when extracting catalog keys, all due to private headers not being found * move ZombieReplicantView.h from kits/interface to headers/private/interface, as this way it can be picked up when building the libbe catalog [ Oliver Tappe <zooey@xxxxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- 49 files changed, 1197 insertions(+), 1208 deletions(-) build/jam/HaikuImage | 2 +- build/jam/LocaleRules | 23 +- headers/os/locale/Catalog.h | 330 ++-------------- headers/os/locale/CatalogData.h | 113 ++++++ .../private}/interface/ZombieReplicantView.h | 0 headers/private/locale/DefaultCatalog.h | 10 +- headers/private/locale/EditableCatalog.h | 63 +++ headers/private/locale/HashMapCatalog.h | 32 +- headers/private/locale/MutableLocaleRoster.h | 19 +- headers/private/locale/PlainTextCatalog.h | 9 +- headers/private/locale/collecting/Catalog.h | 95 +++++ src/add-ons/locale/catalogs/Jamfile | 2 - src/add-ons/locale/catalogs/plaintext/Catalog.cpp | 12 +- src/add-ons/locale/catalogs/zeta/Catalog.cpp | 92 ----- src/add-ons/locale/catalogs/zeta/Jamfile | 8 - 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/collectcatkeys.cpp | 8 +- src/bin/locale/dumpcatalog.cpp | 17 +- src/bin/locale/linkcatkeys.cpp | 17 +- src/kits/Jamfile | 3 +- src/kits/locale/Catalog.cpp | 329 +--------------- src/kits/locale/CatalogData.cpp | 160 ++++++++ src/kits/locale/DefaultCatalog.cpp | 21 +- src/kits/locale/EditableCatalog.cpp | 155 ++++++++ src/kits/locale/HashMapCatalog.cpp | 24 +- src/kits/locale/InitLocaleKit.cpp | 8 +- src/kits/locale/Jamfile | 2 + src/kits/locale/LocaleRoster.cpp | 2 + src/kits/locale/MutableLocaleRoster.cpp | 22 +- src/preferences/cpufrequency/StatusView.cpp | 22 +- src/preferences/deskbar/DeskbarPreferences.cpp | 4 +- src/preferences/tracker/TrackerPreferences.cpp | 16 +- src/tools/locale/Catalog.cpp | 198 ++-------- src/tools/locale/CatalogData.cpp | 158 ++++++++ src/tools/locale/DefaultCatalog.cpp | 17 +- src/tools/locale/Jamfile | 2 + src/tools/locale/PlainTextCatalog.cpp | 20 +- src/tools/locale/collectcatkeys.cpp | 3 + src/tools/locale/linkcatkeys.cpp | 7 +- ############################################################################ Commit: 16e5092306efca466d27519953cdbb803f3d5f5e URL: http://cgit.haiku-os.org/haiku/commit/?id=16e5092 Author: Oliver Tappe <zooey@xxxxxxxxxxxxxxx> Date: Sat Apr 14 17:56:49 2012 UTC Extract EditableCatalog from Catalog.{h,cpp}. * move EditableCatalog to its own header and implementation file * move problematic BCatalog::CatalogAddOn() to EditableCatalog * adjust Locale tools accordingly ---------------------------------------------------------------------------- diff --git a/headers/os/locale/Catalog.h b/headers/os/locale/Catalog.h index bdf178b..0eef285 100644 --- a/headers/os/locale/Catalog.h +++ b/headers/os/locale/Catalog.h @@ -50,10 +50,6 @@ public: status_t InitCheck() const; int32 CountItems() const; - // TODO: drop this, as the lifetime of the returned object - // is indeterminate - BCatalogAddOn* CatalogAddOn(); - protected: BCatalog(const BCatalog&); const BCatalog& operator= (const BCatalog&); @@ -378,13 +374,6 @@ BCatalog::GetNoAutoCollectString(uint32 id) } -inline BCatalogAddOn* -BCatalog::CatalogAddOn() -{ - return fCatalog; -} - - /* * BCatalogAddOn - inlines for trivial accessors: */ @@ -409,50 +398,4 @@ BCatalogAddOn::MarkForTranslation(int32 id) } -// TODO: does not belong here, either -namespace BPrivate { - - -class EditableCatalog : public BCatalog { -public: - EditableCatalog(const char* type, - const char* signature, - const char* language); - virtual ~EditableCatalog(); - - status_t SetString(const char* string, - const char* translated, - const char* context = NULL, - const char* comment = NULL); - status_t SetString(int32 id, const char* translated); - - bool CanWriteData() const; - status_t SetData(const char* name, BMessage* msg); - status_t SetData(uint32 id, BMessage* msg); - - status_t ReadFromFile(const char* path = NULL); - status_t ReadFromAttribute( - const entry_ref& appOrAddOnRef); - status_t ReadFromResource( - const entry_ref& appOrAddOnRef); - status_t WriteToFile(const char* path = NULL); - status_t WriteToAttribute( - const entry_ref& appOrAddOnRef); - status_t WriteToResource( - const entry_ref& appOrAddOnRef); - - void MakeEmpty(); - -private: - EditableCatalog(); - EditableCatalog(const EditableCatalog& other); - const EditableCatalog& operator=(const EditableCatalog& other); - // hide assignment, default-, and - // copy-constructor -}; - - -} // namespace BPrivate - - #endif /* _CATALOG_H_ */ diff --git a/headers/private/locale/EditableCatalog.h b/headers/private/locale/EditableCatalog.h new file mode 100644 index 0000000..ad8bb31 --- /dev/null +++ b/headers/private/locale/EditableCatalog.h @@ -0,0 +1,63 @@ +/* + * Copyright 2003-2012, Haiku, Inc. + * Distributed under the terms of the MIT License. + */ +#ifndef _EDITABLE_CATALOG_H_ +#define _EDITABLE_CATALOG_H_ + + +#include <Catalog.h> + + +class BMessage; +struct entry_ref; + + +namespace BPrivate { + + +class EditableCatalog : public BCatalog { +public: + EditableCatalog(const char* type, + const char* signature, + const char* language); + virtual ~EditableCatalog(); + + status_t SetString(const char* string, + const char* translated, + const char* context = NULL, + const char* comment = NULL); + status_t SetString(int32 id, const char* translated); + + bool CanWriteData() const; + status_t SetData(const char* name, BMessage* msg); + status_t SetData(uint32 id, BMessage* msg); + + status_t ReadFromFile(const char* path = NULL); + status_t ReadFromAttribute( + const entry_ref& appOrAddOnRef); + status_t ReadFromResource( + const entry_ref& appOrAddOnRef); + status_t WriteToFile(const char* path = NULL); + status_t WriteToAttribute( + const entry_ref& appOrAddOnRef); + status_t WriteToResource( + const entry_ref& appOrAddOnRef); + + void MakeEmpty(); + + BCatalogAddOn* CatalogAddOn(); + +private: + EditableCatalog(); + EditableCatalog(const EditableCatalog& other); + const EditableCatalog& operator=(const EditableCatalog& other); + // hide assignment, default-, and + // copy-constructor +}; + + +} // namespace BPrivate + + +#endif /* _EDITABLE_CATALOG_H_ */ diff --git a/headers/private/locale/HashMapCatalog.h b/headers/private/locale/HashMapCatalog.h index fd5b27f..9ddc8d5 100644 --- a/headers/private/locale/HashMapCatalog.h +++ b/headers/private/locale/HashMapCatalog.h @@ -60,10 +60,6 @@ class CatKey { uint32 GetHashCode() const { return fHashVal; } }; -} // namespace BPrivate - - -namespace BPrivate { class BHashMapCatalog: public BCatalogAddOn { protected: @@ -200,6 +196,4 @@ BHashMapCatalog::GetWalker(CatWalker *walker) } // namespace BPrivate -using namespace BPrivate; - #endif // _HASH_MAP_CATALOG_H_ diff --git a/src/bin/locale/collectcatkeys.cpp b/src/bin/locale/collectcatkeys.cpp index 6fd00bc..06156c8 100644 --- a/src/bin/locale/collectcatkeys.cpp +++ b/src/bin/locale/collectcatkeys.cpp @@ -13,14 +13,16 @@ #include <cstdio> #include <cstdlib> -#include <Catalog.h> -using namespace BPrivate; #include <Entry.h> #include <File.h> #include "RegExp.h" #include <StorageDefs.h> #include <String.h> +#include <EditableCatalog.h> + +using BPrivate::EditableCatalog; + bool showKeys = false; bool showSummary = false; @@ -31,8 +33,6 @@ const char *catalogSig = NULL; const char *catalogLang = "English"; BString rxString("B_CATKEY\\s*"); - - BString str, ctx, cmt; bool haveID; int32 id; diff --git a/src/bin/locale/dumpcatalog.cpp b/src/bin/locale/dumpcatalog.cpp index 36330fd..6ba9bf8 100644 --- a/src/bin/locale/dumpcatalog.cpp +++ b/src/bin/locale/dumpcatalog.cpp @@ -6,11 +6,15 @@ #include <cstdio> #include <cstdlib> -#include <Catalog.h> -#include <DefaultCatalog.h> #include <File.h> #include <String.h> +#include <DefaultCatalog.h> +#include <EditableCatalog.h> + +using BPrivate::EditableCatalog; + + void usage() { @@ -57,8 +61,8 @@ main(int argc, char **argv) while (!walker.AtEnd()) { const CatKey &key(walker.GetKey()); key.GetStringParts(&str, &ctx, &cmt); - printf("Hash:\t\t%lu\nKey:\t\t<%s:%s:%s>\nTranslation:\t%s\n-----\n", - key.fHashVal, str.String(), ctx.String(), cmt.String(), + printf("Hash:\t\t%lu\nKey:\t\t<%s:%s:%s>\nTranslation:\t%s\n-----\n", + key.fHashVal, str.String(), ctx.String(), cmt.String(), walker.GetValue()); walker.Next(); } diff --git a/src/bin/locale/linkcatkeys.cpp b/src/bin/locale/linkcatkeys.cpp index c762362..2b222c2 100644 --- a/src/bin/locale/linkcatkeys.cpp +++ b/src/bin/locale/linkcatkeys.cpp @@ -7,17 +7,19 @@ #include <cstdlib> #include <vector> -#include <Catalog.h> #include <Entry.h> #include <File.h> #include <String.h> +#include <EditableCatalog.h> #include <DefaultCatalog.h> #include <HashMapCatalog.h> #include <PlainTextCatalog.h> +using BPrivate::EditableCatalog; using std::vector; + void usage() { diff --git a/src/kits/locale/Catalog.cpp b/src/kits/locale/Catalog.cpp index 2d51a5b..a80c854 100644 --- a/src/kits/locale/Catalog.cpp +++ b/src/kits/locale/Catalog.cpp @@ -370,139 +370,3 @@ BCatalogAddOn::SetNext(BCatalogAddOn* next) { fNext = next; } - - -//#pragma mark - EditableCatalog -namespace BPrivate { -EditableCatalog::EditableCatalog(const char* type, const char* signature, - const char* language) -{ - fCatalog = MutableLocaleRoster::Default()->CreateCatalog(type, signature, - language); -} - - -EditableCatalog::~EditableCatalog() -{ -} - - -status_t -EditableCatalog::SetString(const char* string, const char* translated, - const char* context, const char* comment) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->SetString(string, translated, context, comment); -} - - -status_t -EditableCatalog::SetString(int32 id, const char* translated) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->SetString(id, translated); -} - - -bool -EditableCatalog::CanWriteData() const -{ - if (fCatalog == NULL) - return false; - - return fCatalog->CanWriteData(); -} - - -status_t -EditableCatalog::SetData(const char* name, BMessage* msg) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->SetData(name, msg); -} - - -status_t -EditableCatalog::SetData(uint32 id, BMessage* msg) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->SetData(id, msg); -} - - -status_t -EditableCatalog::ReadFromFile(const char* path) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->ReadFromFile(path); -} - - -status_t -EditableCatalog::ReadFromAttribute(const entry_ref& appOrAddOnRef) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->ReadFromAttribute(appOrAddOnRef); -} - - -status_t -EditableCatalog::ReadFromResource(const entry_ref& appOrAddOnRef) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->ReadFromResource(appOrAddOnRef); -} - - -status_t -EditableCatalog::WriteToFile(const char* path) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->WriteToFile(path); -} - - -status_t -EditableCatalog::WriteToAttribute(const entry_ref& appOrAddOnRef) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->WriteToAttribute(appOrAddOnRef); -} - - -status_t -EditableCatalog::WriteToResource(const entry_ref& appOrAddOnRef) -{ - if (fCatalog == NULL) - return B_NO_INIT; - - return fCatalog->WriteToResource(appOrAddOnRef); -} - - -void EditableCatalog::MakeEmpty() -{ - if (fCatalog == NULL) - fCatalog->MakeEmpty(); -} - - -} // namespace BPrivate diff --git a/src/kits/locale/EditableCatalog.cpp b/src/kits/locale/EditableCatalog.cpp new file mode 100644 index 0000000..79263bf --- /dev/null +++ b/src/kits/locale/EditableCatalog.cpp @@ -0,0 +1,154 @@ +/* + * Copyright 2003-2004, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx + * Copyright 2003-2004,2012, Oliver Tappe, zooey@xxxxxxxxxxxxxxx + * Distributed under the terms of the MIT License. + */ + +#include <EditableCatalog.h> + +#include <MutableLocaleRoster.h> + + +using BPrivate::MutableLocaleRoster; + + +namespace BPrivate { +EditableCatalog::EditableCatalog(const char* type, const char* signature, + const char* language) +{ + fCatalog = MutableLocaleRoster::Default()->CreateCatalog(type, signature, + language); +} + + +EditableCatalog::~EditableCatalog() +{ +} + + +status_t +EditableCatalog::SetString(const char* string, const char* translated, + const char* context, const char* comment) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->SetString(string, translated, context, comment); +} + + +status_t +EditableCatalog::SetString(int32 id, const char* translated) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->SetString(id, translated); +} + + +bool +EditableCatalog::CanWriteData() const +{ + if (fCatalog == NULL) + return false; + + return fCatalog->CanWriteData(); +} + + +status_t +EditableCatalog::SetData(const char* name, BMessage* msg) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->SetData(name, msg); +} + + +status_t +EditableCatalog::SetData(uint32 id, BMessage* msg) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->SetData(id, msg); +} + + +status_t +EditableCatalog::ReadFromFile(const char* path) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->ReadFromFile(path); +} + + +status_t +EditableCatalog::ReadFromAttribute(const entry_ref& appOrAddOnRef) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->ReadFromAttribute(appOrAddOnRef); +} + + +status_t +EditableCatalog::ReadFromResource(const entry_ref& appOrAddOnRef) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->ReadFromResource(appOrAddOnRef); +} + + +status_t +EditableCatalog::WriteToFile(const char* path) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->WriteToFile(path); +} + + +status_t +EditableCatalog::WriteToAttribute(const entry_ref& appOrAddOnRef) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->WriteToAttribute(appOrAddOnRef); +} + + +status_t +EditableCatalog::WriteToResource(const entry_ref& appOrAddOnRef) +{ + if (fCatalog == NULL) + return B_NO_INIT; + + return fCatalog->WriteToResource(appOrAddOnRef); +} + + +void EditableCatalog::MakeEmpty() +{ + if (fCatalog == NULL) + fCatalog->MakeEmpty(); +} + + +BCatalogAddOn* +EditableCatalog::CatalogAddOn() +{ + return fCatalog; +} + + +} // namespace BPrivate diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index 87430d9..70b258c 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -11,6 +11,7 @@ local sources = Collator.cpp Country.cpp DefaultCatalog.cpp + EditableCatalog.cpp FormattingConventions.cpp HashMapCatalog.cpp InitLocaleKit.cpp ############################################################################ Commit: 7ae67a9920ee43e5f8e2cd55efe9ea7fa0a0ec51 URL: http://cgit.haiku-os.org/haiku/commit/?id=7ae67a9 Author: Oliver Tappe <zooey@xxxxxxxxxxxxxxx> Date: Sat Apr 14 18:33:45 2012 UTC Drop empty 'zeta' catalog add-on, wouldn't be useful anyway. ---------------------------------------------------------------------------- diff --git a/build/jam/HaikuImage b/build/jam/HaikuImage index 36f6edd..d02dd66 100644 --- a/build/jam/HaikuImage +++ b/build/jam/HaikuImage @@ -131,7 +131,7 @@ SYSTEM_ADD_ONS_TRANSLATORS = BMPTranslator EXRTranslator GIFTranslator RAWTranslator RTF-Translator SGITranslator STXTTranslator TGATranslator TIFFTranslator WebPTranslator WonderBrushTranslator ; -SYSTEM_ADD_ONS_LOCALE_CATALOGS = <catalog-addon>zeta <catalog-addon>plaintext ; +SYSTEM_ADD_ONS_LOCALE_CATALOGS = <catalog-addon>plaintext ; SYSTEM_ADD_ONS_MEDIA = cortex_audioadapter.media_addon cortex_flanger.media_addon $(X86_ONLY)dvb.media_addon diff --git a/src/add-ons/locale/catalogs/Jamfile b/src/add-ons/locale/catalogs/Jamfile index a6e0e55..9644ba3 100644 --- a/src/add-ons/locale/catalogs/Jamfile +++ b/src/add-ons/locale/catalogs/Jamfile @@ -5,8 +5,6 @@ NotFile LocaleKitCatalogAddons ; Depends LocaleKitCatalogAddons : <catalog-addon>plaintext - <catalog-addon>zeta ; SubInclude HAIKU_TOP src add-ons locale catalogs plaintext ; -SubInclude HAIKU_TOP src add-ons locale catalogs zeta ; diff --git a/src/add-ons/locale/catalogs/zeta/Catalog.cpp b/src/add-ons/locale/catalogs/zeta/Catalog.cpp deleted file mode 100644 index 7489142..0000000 --- a/src/add-ons/locale/catalogs/zeta/Catalog.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* -** Copyright 2003, Oliver Tappe, zooey@xxxxxxxxxxxxxxxx All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ - -#include <new> - -#include <syslog.h> - -#include <Application.h> -#include <Directory.h> -#include <File.h> -#include <FindDirectory.h> -#include <Message.h> -#include <Path.h> -#include <Roster.h> - -#include <Catalog.h> -#include <LocaleRoster.h> - -/** This implements a compatibility catalog-type which uses the catalogs - * supplied by the Zeta Locale Kit. - */ - -class ZetaCatalog : public BCatalogAddOn { - - public: - ZetaCatalog(const char *signature, const char *language, - uint32 fingerprint); - ~ZetaCatalog(); - - const char *GetString(const char *string, const char *context=NULL, - const char *comment=NULL); - const char *GetString(uint32 id); - - private: - -}; - -ZetaCatalog::ZetaCatalog(const char *signature, const char *language, - uint32 fingerprint) - : - BCatalogAddOn(signature, language, fingerprint) -{ - app_info appInfo; - be_app->GetAppInfo(&appInfo); - node_ref nref; - nref.device = appInfo.ref.device; - nref.node = appInfo.ref.directory; - BDirectory appDir( &nref); - - // ToDo: implement loading of zeta-catalog - fInitCheck = EOPNOTSUPP; - - log_team(LOG_DEBUG, - "trying to load zeta-catalog with sig %s for lang %s results in %s", - signature, language, strerror(fInitCheck)); -} - -ZetaCatalog::~ZetaCatalog() -{ -} - -const char * -ZetaCatalog::GetString(const char *string, const char *context, - const char *comment) -{ - return "zeta-string-by-string"; -} - -const char * -ZetaCatalog::GetString(uint32 id) -{ - return "zeta-string-by-id"; -} - - - -extern "C" BCatalogAddOn * -instantiate_catalog(const char *signature, const char *language, uint32 fingerprint) -{ - ZetaCatalog *catalog - = new(std::nothrow) ZetaCatalog(signature, language, fingerprint); - if (catalog && catalog->InitCheck() != B_OK) { - delete catalog; - return NULL; - } - return catalog; -} - -uint8 gCatalogAddOnPriority = 5; - // priority for Zeta catalog-add-on diff --git a/src/add-ons/locale/catalogs/zeta/Jamfile b/src/add-ons/locale/catalogs/zeta/Jamfile deleted file mode 100644 index c02cecb..0000000 --- a/src/add-ons/locale/catalogs/zeta/Jamfile +++ /dev/null @@ -1,8 +0,0 @@ -SubDir HAIKU_TOP src add-ons locale catalogs zeta ; - -UsePublicHeaders locale ; - -Addon <catalog-addon>zeta - : Catalog.cpp - : be $(TARGET_LIBSUPC++) - ; ############################################################################ Commit: 5ac65b7f11e3cec39f7f1540558884427fec935d URL: http://cgit.haiku-os.org/haiku/commit/?id=5ac65b7 Author: Oliver Tappe <zooey@xxxxxxxxxxxxxxx> Date: Sat Apr 14 18:38:05 2012 UTC More cleanup in locale kit, this time regarding namespaces. * it's bad practice to do a 'using <namespace>' in a header, as that is very likely to have unintended effects, so drop those from a couple of private Locale headers * adjust files all over the locale kit in order to fix the problems (by explicitly importing the required classes in the implementation files) ---------------------------------------------------------------------------- diff --git a/headers/private/locale/DefaultCatalog.h b/headers/private/locale/DefaultCatalog.h index be519d3..5afb733 100644 --- a/headers/private/locale/DefaultCatalog.h +++ b/headers/private/locale/DefaultCatalog.h @@ -22,7 +22,7 @@ namespace BPrivate { * but the value-type might change to add support for shortcuts and/or * graphical data (button-images and the like). */ -class DefaultCatalog : public BHashMapCatalog { +class DefaultCatalog : public HashMapCatalog { public: DefaultCatalog(const entry_ref &catalogOwner, const char *language, uint32 fingerprint); @@ -35,7 +35,6 @@ class DefaultCatalog : public BHashMapCatalog { ~DefaultCatalog(); - // implementation for editor-interface: status_t ReadFromFile(const char *path = NULL); status_t ReadFromAttribute(const entry_ref &appOrAddOnRef); @@ -63,13 +62,14 @@ class DefaultCatalog : public BHashMapCatalog { mutable BString fPath; }; + extern "C" status_t default_catalog_get_available_languages(BMessage* availableLanguages, const char* sigPattern, const char* langPattern = NULL, int32 fingerprint = 0); + } // namespace BPrivate -using namespace BPrivate; #endif /* _DEFAULT_CATALOG_H_ */ diff --git a/headers/private/locale/HashMapCatalog.h b/headers/private/locale/HashMapCatalog.h index 9ddc8d5..a189f35 100644 --- a/headers/private/locale/HashMapCatalog.h +++ b/headers/private/locale/HashMapCatalog.h @@ -61,14 +61,14 @@ class CatKey { }; -class BHashMapCatalog: public BCatalogAddOn { +class HashMapCatalog: public BCatalogAddOn { protected: uint32 ComputeFingerprint() const; typedef HashMap<CatKey, BString> CatMap; CatMap fCatMap; public: - BHashMapCatalog(const char* signature, const char* language, + HashMapCatalog(const char* signature, const char* language, uint32 fingerprint); // Constructor for normal use // @@ -112,7 +112,7 @@ class BHashMapCatalog: public BCatalogAddOn { public: //CatWalker() {}; // if you use this there is no way to set fPos // properly. - CatWalker(BHashMapCatalog* catalog); + CatWalker(HashMapCatalog* catalog); bool AtEnd() const; const CatKey& GetKey() const; const char *GetValue() const; @@ -129,7 +129,7 @@ class BHashMapCatalog: public BCatalogAddOn { }; -inline BHashMapCatalog::BHashMapCatalog(const char* signature, +inline HashMapCatalog::HashMapCatalog(const char* signature, const char* language, uint32 fingerprint) : BCatalogAddOn(signature, language, fingerprint) @@ -138,7 +138,7 @@ inline BHashMapCatalog::BHashMapCatalog(const char* signature, inline -BHashMapCatalog::CatWalker::CatWalker(BHashMapCatalog* catalog) +HashMapCatalog::CatWalker::CatWalker(HashMapCatalog* catalog) : fPos(catalog->fCatMap.GetIterator()) { @@ -151,14 +151,14 @@ BHashMapCatalog::CatWalker::CatWalker(BHashMapCatalog* catalog) inline bool -BHashMapCatalog::CatWalker::AtEnd() const +HashMapCatalog::CatWalker::AtEnd() const { return atEnd; } inline const CatKey & -BHashMapCatalog::CatWalker::GetKey() const +HashMapCatalog::CatWalker::GetKey() const { assert(!atEnd); return current.key; @@ -166,7 +166,7 @@ BHashMapCatalog::CatWalker::GetKey() const inline const char * -BHashMapCatalog::CatWalker::GetValue() const +HashMapCatalog::CatWalker::GetValue() const { assert(!atEnd); return current.value.String(); @@ -174,7 +174,7 @@ BHashMapCatalog::CatWalker::GetValue() const inline void -BHashMapCatalog::CatWalker::Next() +HashMapCatalog::CatWalker::Next() { if (fPos.HasNext()) { current = fPos.Next(); @@ -185,7 +185,7 @@ BHashMapCatalog::CatWalker::Next() inline status_t -BHashMapCatalog::GetWalker(CatWalker *walker) +HashMapCatalog::GetWalker(CatWalker *walker) { if (!walker) return B_BAD_VALUE; diff --git a/headers/private/locale/PlainTextCatalog.h b/headers/private/locale/PlainTextCatalog.h index 030ee5d..154e79f 100644 --- a/headers/private/locale/PlainTextCatalog.h +++ b/headers/private/locale/PlainTextCatalog.h @@ -15,7 +15,8 @@ class BFile; namespace BPrivate { -class PlainTextCatalog : public BHashMapCatalog { + +class PlainTextCatalog : public HashMapCatalog { public: PlainTextCatalog(const char *signature, const char *language, uint32 fingerprint); @@ -28,7 +29,6 @@ class PlainTextCatalog : public BHashMapCatalog { ~PlainTextCatalog(); - // implementation for editor-interface: status_t ReadFromFile(const char *path = NULL); status_t WriteToFile(const char *path = NULL); @@ -45,9 +45,8 @@ class PlainTextCatalog : public BHashMapCatalog { mutable BString fPath; }; -} // namespace BPrivate -using BPrivate::PlainTextCatalog; +} // namespace BPrivate #endif /* _PLAINTEXT_CATALOG_H_ */ diff --git a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp index 646ff35..e2dedb0 100644 --- a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp +++ b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp @@ -32,6 +32,8 @@ #include <Catalog.h> +using BPrivate::HashMapCatalog; +using BPrivate::PlainTextCatalog; using std::auto_ptr; using std::min; using std::max; @@ -77,7 +79,7 @@ escapeQuotedChars(BString& stringToEscape) PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language, uint32 fingerprint) : - BHashMapCatalog(signature, language, fingerprint) + HashMapCatalog(signature, language, fingerprint) { // give highest priority to catalog living in sub-folder of app's folder: app_info appInfo; @@ -137,7 +139,7 @@ PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language, PlainTextCatalog::PlainTextCatalog(const char *path, const char *signature, const char *language) : - BHashMapCatalog(signature, language, 0), + HashMapCatalog(signature, language, 0), fPath(path) { fInitCheck = B_OK; diff --git a/src/bin/locale/dumpcatalog.cpp b/src/bin/locale/dumpcatalog.cpp index 6ba9bf8..c771940 100644 --- a/src/bin/locale/dumpcatalog.cpp +++ b/src/bin/locale/dumpcatalog.cpp @@ -12,6 +12,9 @@ #include <DefaultCatalog.h> #include <EditableCatalog.h> + +using BPrivate::CatKey; +using BPrivate::DefaultCatalog; using BPrivate::EditableCatalog; diff --git a/src/bin/locale/linkcatkeys.cpp b/src/bin/locale/linkcatkeys.cpp index 2b222c2..a9987a5 100644 --- a/src/bin/locale/linkcatkeys.cpp +++ b/src/bin/locale/linkcatkeys.cpp @@ -14,9 +14,12 @@ #include <EditableCatalog.h> #include <DefaultCatalog.h> #include <HashMapCatalog.h> -#include <PlainTextCatalog.h> + +using BPrivate::CatKey; +using BPrivate::DefaultCatalog; using BPrivate::EditableCatalog; +using BPrivate::HashMapCatalog; using std::vector; @@ -112,8 +115,8 @@ main(int argc, char **argv) inputFiles[i], strerror(res)); exit(-1); } - BHashMapCatalog* inputCatImpl - = dynamic_cast<BHashMapCatalog*>(inputCatalog.CatalogAddOn()); + HashMapCatalog* inputCatImpl + = dynamic_cast<HashMapCatalog*>(inputCatalog.CatalogAddOn()); if (!inputCatImpl) { fprintf(stderr, "couldn't access impl of input-catalog %s\n", inputFiles[i]); @@ -122,7 +125,7 @@ main(int argc, char **argv) // now walk over all entries in input-catalog and add them to // target catalog, unless they already exist there. - BHashMapCatalog::CatWalker walker(inputCatImpl); + HashMapCatalog::CatWalker walker(inputCatImpl); while (!walker.AtEnd()) { const CatKey &plainTextKey(walker.GetKey()); BString keyString, keyComment, keyContext; diff --git a/src/kits/locale/DefaultCatalog.cpp b/src/kits/locale/DefaultCatalog.cpp index a7acc96..8f332ee 100644 --- a/src/kits/locale/DefaultCatalog.cpp +++ b/src/kits/locale/DefaultCatalog.cpp @@ -46,6 +46,10 @@ using std::pair; static const char *kCatFolder = "catalogs"; static const char *kCatExtension = ".catalog"; + +namespace BPrivate { + + const char *DefaultCatalog::kCatMimeType = "locale/x-vnd.Be.locale-catalog.default"; @@ -64,7 +68,7 @@ const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1; DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *language, uint32 fingerprint) : - BHashMapCatalog("", language, fingerprint) + HashMapCatalog("", language, fingerprint) { // We created the catalog with an invalid signature, but we fix that now. SetSignature(catalogOwner); @@ -127,7 +131,7 @@ DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *langua */ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef) : - BHashMapCatalog("", "", 0) + HashMapCatalog("", "", 0) { fInitCheck = ReadFromResource(*appOrAddOnRef); log_team(LOG_DEBUG, @@ -143,7 +147,7 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef) DefaultCatalog::DefaultCatalog(const char *path, const char *signature, const char *language) : - BHashMapCatalog(signature, language, 0), + HashMapCatalog(signature, language, 0), fPath(path) { fInitCheck = B_OK; @@ -615,10 +619,13 @@ DefaultCatalog::Create(const char *signature, const char *language) return catalog; } + +} // namespace BPrivate + + extern "C" status_t default_catalog_get_available_languages(BMessage* availableLanguages, - const char* sigPattern, const char* langPattern = NULL, - int32 fingerprint = 0) + const char* sigPattern, const char* langPattern, int32 fingerprint) { if (availableLanguages == NULL || sigPattern == NULL) return B_BAD_DATA; diff --git a/src/kits/locale/HashMapCatalog.cpp b/src/kits/locale/HashMapCatalog.cpp index 70f0fc0..6ae6bd1 100644 --- a/src/kits/locale/HashMapCatalog.cpp +++ b/src/kits/locale/HashMapCatalog.cpp @@ -102,25 +102,25 @@ CatKey::HashFun(const char* s, int startValue) { } -// BHashMapCatalog +// HashMapCatalog void -BHashMapCatalog::MakeEmpty() +HashMapCatalog::MakeEmpty() { fCatMap.Clear(); } int32 -BHashMapCatalog::CountItems() const +HashMapCatalog::CountItems() const { return fCatMap.Size(); } const char * -BHashMapCatalog::GetString(const char *string, const char *context, +HashMapCatalog::GetString(const char *string, const char *context, const char *comment) { CatKey key(string, context, comment); @@ -129,7 +129,7 @@ BHashMapCatalog::GetString(const char *string, const char *context, const char * -BHashMapCatalog::GetString(uint32 id) +HashMapCatalog::GetString(uint32 id) { CatKey key(id); return GetString(key); @@ -137,7 +137,7 @@ BHashMapCatalog::GetString(uint32 id) const char * -BHashMapCatalog::GetString(const CatKey& key) +HashMapCatalog::GetString(const CatKey& key) { BString value = fCatMap.Get(key); if (value.Length() == 0) @@ -202,7 +202,7 @@ parseQuotedChars(BString& stringToParse) status_t -BHashMapCatalog::SetString(const char *string, const char *translated, +HashMapCatalog::SetString(const char *string, const char *translated, const char *context, const char *comment) { BString stringCopy(string); @@ -225,7 +225,7 @@ BHashMapCatalog::SetString(const char *string, const char *translated, status_t -BHashMapCatalog::SetString(int32 id, const char *translated) +HashMapCatalog::SetString(int32 id, const char *translated) { BString translatedCopy(translated); status_t result = parseQuotedChars(translatedCopy); @@ -238,7 +238,7 @@ BHashMapCatalog::SetString(int32 id, const char *translated) status_t -BHashMapCatalog::SetString(const CatKey& key, const char *translated) +HashMapCatalog::SetString(const CatKey& key, const char *translated) { BString translatedCopy(translated); status_t result = parseQuotedChars(translatedCopy); @@ -258,7 +258,7 @@ BHashMapCatalog::SetString(const CatKey& key, const char *translated) * wrong order, and this does happen, as an hash map is an unsorted container. */ uint32 -BHashMapCatalog::ComputeFingerprint() const +HashMapCatalog::ComputeFingerprint() const { uint32 checksum = 0; @@ -276,7 +276,7 @@ BHashMapCatalog::ComputeFingerprint() const void -BHashMapCatalog::UpdateFingerprint() +HashMapCatalog::UpdateFingerprint() { fFingerprint = ComputeFingerprint(); } diff --git a/src/kits/locale/InitLocaleKit.cpp b/src/kits/locale/InitLocaleKit.cpp index 3092092..96f281a 100644 --- a/src/kits/locale/InitLocaleKit.cpp +++ b/src/kits/locale/InitLocaleKit.cpp @@ -22,6 +22,11 @@ BCatalog gSystemCatalog; } +using BPrivate::DefaultCatalog; +using BPrivate::MutableLocaleRoster; +using BPrivate::gSystemCatalog; + + // helper function that makes sure an attribute-index exists: static void EnsureIndexExists(const char *attrName) { @@ -129,6 +134,5 @@ __initialize_locale_kit() { SetupCatalogBasics(); - MutableLocaleRoster::Default()->LoadSystemCatalog( - &BPrivate::gSystemCatalog); + MutableLocaleRoster::Default()->LoadSystemCatalog(&gSystemCatalog); } diff --git a/src/kits/locale/LocaleRoster.cpp b/src/kits/locale/LocaleRoster.cpp index 2631f93..c681f68 100644 --- a/src/kits/locale/LocaleRoster.cpp +++ b/src/kits/locale/LocaleRoster.cpp @@ -44,6 +44,8 @@ using BPrivate::CatalogAddOnInfo; +using BPrivate::MutableLocaleRoster; +using BPrivate::RosterData; /* diff --git a/src/tools/locale/DefaultCatalog.cpp b/src/tools/locale/DefaultCatalog.cpp index e8fc2e0..4352a81 100644 --- a/src/tools/locale/DefaultCatalog.cpp +++ b/src/tools/locale/DefaultCatalog.cpp @@ -31,6 +31,7 @@ #include <cstdio> +using BPrivate::DefaultCatalog; using std::auto_ptr; @@ -40,6 +41,9 @@ using std::auto_ptr; */ +namespace BPrivate { + + // several attributes/resource-IDs used within the Locale Kit: const char *kCatLangAttr = "BEOS:LOCALE_LANGUAGE"; @@ -64,7 +68,7 @@ static int16 kCatArchiveVersion = 1; DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, const char *language, uint32 fingerprint) : - BHashMapCatalog("", language, fingerprint) + HashMapCatalog("", language, fingerprint) { fInitCheck = B_NOT_SUPPORTED; fprintf(stderr, @@ -80,7 +84,7 @@ DefaultCatalog::DefaultCatalog(const entry_ref &catalogOwner, */ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef) : - BHashMapCatalog("", "", 0) + HashMapCatalog("", "", 0) { fInitCheck = ReadFromResource(*appOrAddOnRef); // fprintf(stderr, @@ -96,7 +100,7 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef) DefaultCatalog::DefaultCatalog(const char *path, const char *signature, const char *language) : - BHashMapCatalog(signature, language, 0), + HashMapCatalog(signature, language, 0), fPath(path) { fInitCheck = B_OK; @@ -426,3 +430,6 @@ DefaultCatalog::Create(const char *signature, const char *language) const uint8 DefaultCatalog::kDefaultCatalogAddOnPriority = 1; // give highest priority to our embedded catalog-add-on + + +} // namespace BPrivate diff --git a/src/tools/locale/PlainTextCatalog.cpp b/src/tools/locale/PlainTextCatalog.cpp index 71e35bb..3cdd94f 100644 --- a/src/tools/locale/PlainTextCatalog.cpp +++ b/src/tools/locale/PlainTextCatalog.cpp @@ -31,6 +31,7 @@ #include <Catalog.h> +using BPrivate::PlainTextCatalog; using std::auto_ptr; using std::min; using std::max; @@ -44,6 +45,9 @@ using std::pair; */ +namespace BPrivate { + + const char *PlainTextCatalog::kCatMimeType = "locale/x-vnd.Be.locale-catalog.plaintext"; @@ -73,7 +77,7 @@ escapeQuotedChars(BString& stringToEscape) PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language, uint32 fingerprint) : - BHashMapCatalog(signature, language, fingerprint) + HashMapCatalog(signature, language, fingerprint) { // Look for the catalog in the directory we are going to use // This constructor is not used so lets disable that... @@ -93,7 +97,7 @@ PlainTextCatalog::PlainTextCatalog(const char *signature, const char *language, PlainTextCatalog::PlainTextCatalog(const char *path, const char *signature, const char *language) : - BHashMapCatalog(signature, language, 0), + HashMapCatalog(signature, language, 0), fPath(path) { fInitCheck = B_OK; @@ -339,6 +343,9 @@ PlainTextCatalog::Instantiate(const char *signature, const char *language, } +} // namespace BPrivate + + extern "C" BCatalogAddOn * instantiate_catalog(const char *signature, const char *language, uint32 fingerprint) diff --git a/src/tools/locale/collectcatkeys.cpp b/src/tools/locale/collectcatkeys.cpp index 87356c5..6430c30 100644 --- a/src/tools/locale/collectcatkeys.cpp +++ b/src/tools/locale/collectcatkeys.cpp @@ -21,6 +21,9 @@ #include <String.h> +using BPrivate::PlainTextCatalog; + + bool showKeys = false; bool showSummary = false; bool showWarnings = false; diff --git a/src/tools/locale/linkcatkeys.cpp b/src/tools/locale/linkcatkeys.cpp index 41aaff0..072a022 100644 --- a/src/tools/locale/linkcatkeys.cpp +++ b/src/tools/locale/linkcatkeys.cpp @@ -16,8 +16,13 @@ #include <HashMapCatalog.h> #include <PlainTextCatalog.h> +using BPrivate::CatKey; +using BPrivate::DefaultCatalog; +using BPrivate::HashMapCatalog; +using BPrivate::PlainTextCatalog; using std::vector; + void usage() { @@ -108,7 +113,7 @@ main(int argc, char **argv) // now walk over all entries in input-catalog and add them to // target catalog, unless they already exist there. - BHashMapCatalog::CatWalker walker(&inputCatalog); + HashMapCatalog::CatWalker walker(&inputCatalog); while (!walker.AtEnd()) { const CatKey &key(walker.GetKey()); ############################################################################ Commit: 541ff51a6ef4c47f8ab105ba6ff895cdbba83aca URL: http://cgit.haiku-os.org/haiku/commit/?id=541ff51 Author: Oliver Tappe <zooey@xxxxxxxxxxxxxxx> Date: Sun Apr 15 17:04:02 2012 UTC 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 ---------------------------------------------------------------------------- diff --git a/headers/os/locale/Catalog.h b/headers/os/locale/Catalog.h index 0eef285..4096016 100644 --- a/headers/os/locale/Catalog.h +++ b/headers/os/locale/Catalog.h @@ -12,7 +12,7 @@ #include <String.h> -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 0000000..5c6d91b --- /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 <SupportDefs.h> +#include <String.h> + + +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 5afb733..0cfab3f 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 ad8bb31..7842610 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 a189f35..09d18f3 100644 --- a/headers/private/locale/HashMapCatalog.h +++ b/headers/private/locale/HashMapCatalog.h @@ -15,7 +15,7 @@ #include <assert.h> -#include <Catalog.h> +#include <CatalogData.h> #include <HashMap.h> #include <String.h> @@ -61,7 +61,7 @@ class CatKey { }; -class HashMapCatalog: public BCatalogAddOn { +class HashMapCatalog: public BCatalogData { protected: uint32 ComputeFingerprint() const; typedef HashMap<CatKey, BString> 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 44dec12..4eb072b 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 154e79f..b31031b 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 e2dedb0..8c92425 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 31c6a15..04b360a 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 1eb3f48..d4d8287 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 7caee44..cb029a9 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<bigtime_t> (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 08c1fdc..b43075b 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 fc1bab5..92fd385 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 8f9ff8e..2f4ba5b 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 3272bcb..00b45a1 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 7db8760..8aae8dc 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 c822f5e..d23c132 100644 --- a/src/apps/tracker/main.cpp +++ b/src/apps/tracker/main.cpp [ *** diff truncated: 1997 lines dropped *** ] ############################################################################ Revision: hrev44037 Commit: 248f2283dd5fcfc0bc79f26b84c8fdec9da7e60c URL: http://cgit.haiku-os.org/haiku/commit/?id=248f228 Author: Oliver Tappe <zooey@xxxxxxxxxxxxxxx> Date: Sun Apr 15 22:03:28 2012 UTC Final part of cleanup in Catalog.h. * move versions of the B_TRANSLATE_...-macros used during collecting of catalog keys to a specific header file, which will only be picked up when running collectcatkeys * fix a couple of build problems during the preprocessing of the libbe- sources when extracting catalog keys, all due to private headers not being found * move ZombieReplicantView.h from kits/interface to headers/private/interface, as this way it can be picked up when building the libbe catalog ----------------------------------------------------------------------------