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
This commit is contained in:
Oliver Tappe
2012-04-16 00:04:41 +02:00
parent 5ac65b7f11
commit 541ff51a6e
36 changed files with 833 additions and 810 deletions
+71 -178
View File
@@ -12,7 +12,7 @@
#include <String.h> #include <String.h>
class BCatalogAddOn; class BCatalogData;
class BLocale; class BLocale;
class BMessage; class BMessage;
struct entry_ref; struct entry_ref;
@@ -31,11 +31,6 @@ public:
const char* comment = NULL); const char* comment = NULL);
const char* GetString(uint32 id); 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(const char* name, BMessage* msg);
status_t GetData(uint32 id, BMessage* msg); status_t GetData(uint32 id, BMessage* msg);
@@ -55,7 +50,7 @@ protected:
const BCatalog& operator= (const BCatalog&); const BCatalog& operator= (const BCatalog&);
// hide assignment and copy-constructor // hide assignment and copy-constructor
BCatalogAddOn* fCatalog; BCatalogData* fCatalogData;
mutable BLocker fLock; mutable BLocker fLock;
private: private:
@@ -122,12 +117,13 @@ private:
#undef B_TRANSLATE_SYSTEM_NAME #undef B_TRANSLATE_SYSTEM_NAME
#define B_TRANSLATE_SYSTEM_NAME(string) \ #define B_TRANSLATE_SYSTEM_NAME(string) \
BLocaleRoster::Default()->IsFilesystemTranslationPreferred() \ BLocaleRoster::Default()->IsFilesystemTranslationPreferred() \
? BLocaleRoster::Default()->GetCatalog()->GetString((string), \ ? BLocaleRoster::Default()->GetCatalog()->GetString((string), \
B_TRANSLATE_SYSTEM_NAME_CONTEXT) : (string) B_TRANSLATE_SYSTEM_NAME_CONTEXT) \
: (string)
// Translation markers which can be used to mark static strings/IDs which // 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): // are used as key for translation requests (at other places in the code).
/* example: /* Example:
#define B_TRANSLATE_CONTEXT "MyDecentApp-Menu" #define B_TRANSLATE_CONTEXT "MyDecentApp-Menu"
static const char* choices[] = { static const char* choices[] = {
@@ -137,7 +133,8 @@ private:
B_TRANSLATE_MARK("down") B_TRANSLATE_MARK("down")
}; };
void MyClass::AddChoices(BMenu* menu) { void MyClass::AddChoices(BMenu* menu)
{
for (char** ch = choices; *ch != '\0'; ++ch) { for (char** ch = choices; *ch != '\0'; ++ch) {
menu->AddItem( menu->AddItem(
new BMenuItem( new BMenuItem(
@@ -149,46 +146,57 @@ private:
} }
*/ */
#undef B_TRANSLATE_MARK #undef B_TRANSLATE_MARK
#define B_TRANSLATE_MARK(str) \ #define B_TRANSLATE_MARK(string) (string)
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, "")
#undef B_TRANSLATE_MARK_COMMENT #undef B_TRANSLATE_MARK_COMMENT
#define B_TRANSLATE_MARK_COMMENT(str, cmt) \ #define B_TRANSLATE_MARK_COMMENT(string, comment) (string)
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_CONTEXT, (cmt))
#undef B_TRANSLATE_MARK_ALL #undef B_TRANSLATE_MARK_ALL
#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \ #define B_TRANSLATE_MARK_ALL(string, context, comment) (string)
BCatalogAddOn::MarkForTranslation((str), (ctx), (cmt))
#undef B_TRANSLATE_MARK_ID #undef B_TRANSLATE_MARK_ID
#define B_TRANSLATE_MARK_ID(id) \ #define B_TRANSLATE_MARK_ID(id) (id)
BCatalogAddOn::MarkForTranslation((id))
#undef B_TRANSLATE_MARK_SYSTEM_NAME #undef B_TRANSLATE_MARK_SYSTEM_NAME
#define B_TRANSLATE_MARK_SYSTEM_NAME(str) \ #define B_TRANSLATE_MARK_SYSTEM_NAME(string) (string)
BCatalogAddOn::MarkForTranslation((str), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "")
// 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 // Translation macros which do not let collectcatkeys try to collect the key
// (useful in combination with the marking macros above): // (useful in combination with the marking macros above):
#undef B_TRANSLATE_NOCOLLECT #undef B_TRANSLATE_NOCOLLECT
#define B_TRANSLATE_NOCOLLECT(str) \ #define B_TRANSLATE_NOCOLLECT(string) \
B_TRANSLATE(str) B_TRANSLATE(string)
#undef B_TRANSLATE_NOCOLLECT_COMMENT #undef B_TRANSLATE_NOCOLLECT_COMMENT
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \ #define B_TRANSLATE_NOCOLLECT_COMMENT(string, comment) \
B_TRANSLATE_COMMENT(str, cmt) B_TRANSLATE_COMMENT(string, comment)
#undef B_TRANSLATE_NOCOLLECT_ALL #undef B_TRANSLATE_NOCOLLECT_ALL
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \ #define B_TRANSLATE_NOCOLLECT_ALL(string, context, comment) \
B_TRANSLATE_ALL(str, ctx, cmt) B_TRANSLATE_ALL(string, context, comment)
#undef B_TRANSLATE_NOCOLLECT_ID #undef B_TRANSLATE_NOCOLLECT_ID
#define B_TRANSLATE_NOCOLLECT_ID(id) \ #define B_TRANSLATE_NOCOLLECT_ID(id) \
B_TRANSLATE_ID(id) B_TRANSLATE_ID(id)
#undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME #undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME
#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(str) \ #define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(string) \
B_TRANSLATE_SYSTEM_NAME(str) B_TRANSLATE_SYSTEM_NAME(string)
#endif /* B_AVOID_TRANSLATION_MACROS */ #endif /* B_AVOID_TRANSLATION_MACROS */
@@ -226,176 +234,61 @@ private:
B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT) B_CATKEY((string), B_TRANSLATE_SYSTEM_NAME_CONTEXT)
#undef B_TRANSLATE_MARK #undef B_TRANSLATE_MARK
#define B_TRANSLATE_MARK(str) \ #define B_TRANSLATE_MARK(string) \
B_CATKEY((str), B_TRANSLATE_CONTEXT) B_CATKEY((string), B_TRANSLATE_CONTEXT)
#undef B_TRANSLATE_MARK_COMMENT #undef B_TRANSLATE_MARK_COMMENT
#define B_TRANSLATE_MARK_COMMENT(str, cmt) \ #define B_TRANSLATE_MARK_COMMENT(string, comment) \
B_CATKEY((str), B_TRANSLATE_CONTEXT, (cmt)) B_CATKEY((string), B_TRANSLATE_CONTEXT, (comment))
#undef B_TRANSLATE_MARK_ALL #undef B_TRANSLATE_MARK_ALL
#define B_TRANSLATE_MARK_ALL(str, ctx, cmt) \ #define B_TRANSLATE_MARK_ALL(string, context, comment) \
B_CATKEY((str), (ctx), (cmt)) B_CATKEY((string), (context), (comment))
#undef B_TRANSLATE_MARK_ID #undef B_TRANSLATE_MARK_ID
#define B_TRANSLATE_MARK_ID(id) \ #define B_TRANSLATE_MARK_ID(id) \
B_CATKEY((id)) B_CATKEY((id))
#undef B_TRANSLATE_MARK_SYSTEM_NAME #undef B_TRANSLATE_MARK_SYSTEM_NAME
#define B_TRANSLATE_MARK_SYSTEM_NAME(str) \ #define B_TRANSLATE_MARK_SYSTEM_NAME(string) \
B_CATKEY((str), B_TRANSLATE_SYSTEM_NAME_CONTEXT, "") 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 #undef B_TRANSLATE_NOCOLLECT
#define B_TRANSLATE_NOCOLLECT(str) \ #define B_TRANSLATE_NOCOLLECT(string)
(void)
#undef B_TRANSLATE_NOCOLLECT_COMMENT #undef B_TRANSLATE_NOCOLLECT_COMMENT
#define B_TRANSLATE_NOCOLLECT_COMMENT(str, cmt) \ #define B_TRANSLATE_NOCOLLECT_COMMENT(string, comment)
(void)
#undef B_TRANSLATE_NOCOLLECT_ALL #undef B_TRANSLATE_NOCOLLECT_ALL
#define B_TRANSLATE_NOCOLLECT_ALL(str, ctx, cmt) \ #define B_TRANSLATE_NOCOLLECT_ALL(string, context, comment)
(void)
#undef B_TRANSLATE_NOCOLLECT_ID #undef B_TRANSLATE_NOCOLLECT_ID
#define B_TRANSLATE_NOCOLLECT_ID(id) \ #define B_TRANSLATE_NOCOLLECT_ID(id)
(void)
#undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME #undef B_TRANSLATE_NOCOLLECT_SYSTEM_NAME
#define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(str) \ #define B_TRANSLATE_NOCOLLECT_SYSTEM_NAME(string)
(void)
#endif /* B_COLLECTING_CATKEYS */ #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_ */ #endif /* _CATALOG_H_ */
+113
View File
@@ -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_ */
+2 -2
View File
@@ -46,9 +46,9 @@ class DefaultCatalog : public HashMapCatalog {
status_t SetRawString(const CatKey& key, const char *translated); status_t SetRawString(const CatKey& key, const char *translated);
void SetSignature(const entry_ref &catalogOwner); 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); const char *language, uint32 fingerprint);
static BCatalogAddOn *Create(const char *signature, static BCatalogData *Create(const char *signature,
const char *language); const char *language);
static const uint8 kDefaultCatalogAddOnPriority; static const uint8 kDefaultCatalogAddOnPriority;
+1 -1
View File
@@ -46,7 +46,7 @@ public:
void MakeEmpty(); void MakeEmpty();
BCatalogAddOn* CatalogAddOn(); BCatalogData* CatalogData();
private: private:
EditableCatalog(); EditableCatalog();
+4 -4
View File
@@ -15,7 +15,7 @@
#include <assert.h> #include <assert.h>
#include <Catalog.h> #include <CatalogData.h>
#include <HashMap.h> #include <HashMap.h>
#include <String.h> #include <String.h>
@@ -61,7 +61,7 @@ class CatKey {
}; };
class HashMapCatalog: public BCatalogAddOn { class HashMapCatalog: public BCatalogData {
protected: protected:
uint32 ComputeFingerprint() const; uint32 ComputeFingerprint() const;
typedef HashMap<CatKey, BString> CatMap; typedef HashMap<CatKey, BString> CatMap;
@@ -72,7 +72,7 @@ class HashMapCatalog: public BCatalogAddOn {
uint32 fingerprint); uint32 fingerprint);
// Constructor for normal use // Constructor for normal use
// //
// overrides of BCatalogAddOn: // overrides of BCatalogData:
const char *GetString(const char *string, const char *context = NULL, const char *GetString(const char *string, const char *context = NULL,
const char *comment = NULL); const char *comment = NULL);
const char *GetString(uint32 id); const char *GetString(uint32 id);
@@ -132,7 +132,7 @@ class HashMapCatalog: public BCatalogAddOn {
inline HashMapCatalog::HashMapCatalog(const char* signature, inline HashMapCatalog::HashMapCatalog(const char* signature,
const char* language, uint32 fingerprint) const char* language, uint32 fingerprint)
: :
BCatalogAddOn(signature, language, fingerprint) BCatalogData(signature, language, fingerprint)
{ {
} }
+10 -9
View File
@@ -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. * Distributed under the terms of the MIT license.
*/ */
#ifndef _MUTABLE_LOCALE_ROSTER_H_ #ifndef _MUTABLE_LOCALE_ROSTER_H_
@@ -21,7 +21,7 @@
class BLocale; class BLocale;
class BCatalog; class BCatalog;
class BCatalogAddOn; class BCatalogData;
struct entry_ref; struct entry_ref;
@@ -44,28 +44,29 @@ public:
// the message contains one or more // the message contains one or more
// 'language'-string-fields which // 'language'-string-fields which
// contain the language-name(s) // contain the language-name(s)
status_t SetFilesystemTranslationPreferred(bool preferred); status_t SetFilesystemTranslationPreferred(
bool preferred);
status_t LoadSystemCatalog(BCatalog* catalog) const; status_t LoadSystemCatalog(BCatalog* catalog) const;
BCatalogAddOn* LoadCatalog(const entry_ref& catalogOwner, BCatalogData* LoadCatalog(const entry_ref& catalogOwner,
const char* language = NULL, const char* language = NULL,
int32 fingerprint = 0) const; 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* signature,
const char* language); const char* language);
}; };
typedef BCatalogAddOn* (*InstantiateCatalogFunc)(const entry_ref& catalogOwner, typedef BCatalogData* (*InstantiateCatalogFunc)(const entry_ref& catalogOwner,
const char* language, uint32 fingerprint); const char* language, uint32 fingerprint);
typedef BCatalogAddOn* (*CreateCatalogFunc)(const char* name, typedef BCatalogData* (*CreateCatalogFunc)(const char* name,
const char* language); const char* language);
typedef BCatalogAddOn* (*InstantiateEmbeddedCatalogFunc)( typedef BCatalogData* (*InstantiateEmbeddedCatalogFunc)(
entry_ref* appOrAddOnRef); entry_ref* appOrAddOnRef);
typedef status_t (*GetAvailableLanguagesFunc)(BMessage*, const char*, typedef status_t (*GetAvailableLanguagesFunc)(BMessage*, const char*,
+1 -1
View File
@@ -33,7 +33,7 @@ class PlainTextCatalog : public HashMapCatalog {
status_t ReadFromFile(const char *path = NULL); status_t ReadFromFile(const char *path = NULL);
status_t WriteToFile(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); const char *language, uint32 fingerprint);
static const char *kCatMimeType; static const char *kCatMimeType;
@@ -396,7 +396,7 @@ PlainTextCatalog::UpdateAttributes(const char* path)
} }
BCatalogAddOn * BCatalogData *
PlainTextCatalog::Instantiate(const char *signature, const char *language, PlainTextCatalog::Instantiate(const char *signature, const char *language,
uint32 fingerprint) 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, instantiate_catalog(const char *signature, const char *language,
uint32 fingerprint) 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) create_catalog(const char *signature, const char *language)
{ {
PlainTextCatalog *catalog PlainTextCatalog *catalog
+2 -2
View File
@@ -59,8 +59,8 @@ FlurryView::FlurryView(BRect bounds)
fOldFrameTime(-1.0), fOldFrameTime(-1.0),
fFlurryInfo_t(NULL) fFlurryInfo_t(NULL)
{ {
B_TRANSLATE_MARK_SYSTEM_NAME("Flurry"); B_TRANSLATE_MARK_SYSTEM_NAME_VOID("Flurry");
fWidth = bounds.Width(); fWidth = bounds.Width();
fHeight = bounds.Height(); fHeight = bounds.Height();
fStartTime = _CurrentTime(); fStartTime = _CurrentTime();
@@ -1,4 +1,4 @@
/* /*
** **
** A simple analog clock screensaver. ** A simple analog clock screensaver.
** **
@@ -28,7 +28,7 @@ public:
Clock(BMessage *message, image_id id); Clock(BMessage *message, image_id id);
void StartConfig(BView *view); void StartConfig(BView *view);
status_t StartSaver(BView *v, bool preview); status_t StartSaver(BView *v, bool preview);
void Draw(BView *v, int32 frame); void Draw(BView *v, int32 frame);
BStringView *tview; BStringView *tview;
private: private:
void DrawBlock(BView *view, float x, float y, float a, float size); 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) 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].x= x+size*cos(angles[i]);
points[i].y= y+size*sin(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) 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 x = xc+(len)*cos(a);
float y = yc+(len)*sin(a); float y = yc+(len)*sin(a);
float size = len*k; float size = len*k;
float angles[4]={a-g,a+g,a+(M_PI)-g,a+(M_PI)+g}; float angles[4]={a-g,a+g,a+(M_PI)-g,a+(M_PI)+g};
BPoint points[4]; BPoint points[4];
for(int i=0;i<4;i++) { for(int i=0;i<4;i++) {
points[i].x= x+size*cos(angles[i]); points[i].x= x+size*cos(angles[i]);
points[i].y= y+size*sin(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) void Clock::Draw(BView *view, int32)
{ {
BScreen screen; BScreen screen;
BBitmap buffer(view->Bounds(), screen.ColorSpace(), true); BBitmap buffer(view->Bounds(), screen.ColorSpace(), true);
BView offscreen(view->Bounds(), NULL, 0, 0); BView offscreen(view->Bounds(), NULL, 0, 0);
buffer.AddChild(&offscreen); buffer.AddChild(&offscreen);
buffer.Lock(); buffer.Lock();
int n; int n;
float a,R; float a,R;
float width = view->Bounds().Width(); float width = view->Bounds().Width();
@@ -122,23 +122,23 @@ void Clock::Draw(BView *view, int32)
todayhour = TodayTime->tm_hour + (todayminute/60.0); todayhour = TodayTime->tm_hour + (todayminute/60.0);
rgb_color bg_color = {0,0,0}; rgb_color bg_color = {0,0,0};
offscreen.SetHighColor(bg_color); offscreen.SetHighColor(bg_color);
offscreen.SetLowColor(bg_color); offscreen.SetLowColor(bg_color);
offscreen.FillRect(offscreen.Bounds()); offscreen.FillRect(offscreen.Bounds());
offscreen.SetHighColor(200,200,200); offscreen.SetHighColor(200,200,200);
for(n=0,a=0,R=510*zoom;n<60;n++,a+=(2*M_PI)/60) { for(n=0,a=0,R=510*zoom;n<60;n++,a+=(2*M_PI)/60) {
float x = width/2 + R * cos(a); 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); DrawBlock(&offscreen,x,y,a,14*zoom);
} }
offscreen.SetHighColor(255,255,255); offscreen.SetHighColor(255,255,255);
for(n=0,a=0,R=500*zoom;n<12;n++,a+=(2*M_PI)/12) { for(n=0,a=0,R=500*zoom;n<12;n++,a+=(2*M_PI)/12) {
float x = width/2 + R * cos(a); 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); 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); 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.FillEllipse(BPoint(width/2,height/2),24*zoom,24*zoom);
offscreen.SetHighColor(250,20,20); 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.FillEllipse(BPoint(width/2,height/2),20*zoom,20*zoom);
offscreen.Sync(); offscreen.Sync();
@@ -11,18 +11,18 @@
// Permission is hereby granted, free of charge, to any person obtaining a // Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"), // copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation // to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, // the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the // 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: // 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. // in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // 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 // 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 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
/*****************************************************************************/ /*****************************************************************************/
@@ -62,11 +62,11 @@ ent_is_dir(const entry_ref *ref)
BEntry ent(ref); BEntry ent(ref);
if (ent.InitCheck() != B_OK) if (ent.InitCheck() != B_OK)
return B_ERROR; return B_ERROR;
struct stat st; struct stat st;
if (ent.GetStat(&st) != B_OK) if (ent.GetStat(&st) != B_OK)
return B_ERROR; return B_ERROR;
return S_ISDIR(st.st_mode) ? (B_OK + 1) : B_OK; 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") BScreenSaver(archive, image), fLock("SlideShow Lock")
{ {
B_TRANSLATE_MARK_SYSTEM_NAME("SlideShowSaver"); B_TRANSLATE_MARK_SYSTEM_NAME_VOID("SlideShowSaver");
fNewDirectory = true; fNewDirectory = true;
fBitmap = NULL; fBitmap = NULL;
fShowBorder = true; fShowBorder = true;
fShowCaption = true; fShowCaption = true;
fSettings = new LiveSettings("SlideShowSaver_Settings", fSettings = new LiveSettings("SlideShowSaver_Settings",
gDefaultSettings, sizeof(gDefaultSettings) / sizeof(LiveSetting)); gDefaultSettings, sizeof(gDefaultSettings) / sizeof(LiveSetting));
fSettings->LoadSettings(); fSettings->LoadSettings();
// load settings from the settings file // load settings from the settings file
fSettings->AddObserver(this); fSettings->AddObserver(this);
} }
@@ -113,8 +113,8 @@ SlideShowSaver::~SlideShowSaver()
{ {
delete fBitmap; delete fBitmap;
fBitmap = NULL; fBitmap = NULL;
fSettings->RemoveObserver(this); fSettings->RemoveObserver(this);
fSettings->Release(); fSettings->Release();
} }
@@ -152,7 +152,7 @@ SlideShowSaver::UpdateTickSize()
bigtime_t ticks = static_cast<bigtime_t> bigtime_t ticks = static_cast<bigtime_t>
(fSettings->SetGetInt32(SAVER_SETTING_DELAY)) * 1000; (fSettings->SetGetInt32(SAVER_SETTING_DELAY)) * 1000;
SetTickSize(ticks); SetTickSize(ticks);
return B_OK; return B_OK;
} }
@@ -174,23 +174,23 @@ status_t
SlideShowSaver::UpdateDirectory() SlideShowSaver::UpdateDirectory()
{ {
status_t result = B_OK; status_t result = B_OK;
fLock.Lock(); fLock.Lock();
BString strDirectory; BString strDirectory;
fSettings->GetString(SAVER_SETTING_DIRECTORY, strDirectory); fSettings->GetString(SAVER_SETTING_DIRECTORY, strDirectory);
BDirectory dir(strDirectory.String()); BDirectory dir(strDirectory.String());
if (dir.InitCheck() != B_OK || dir.GetNextRef(&fCurrentRef) != B_OK) if (dir.InitCheck() != B_OK || dir.GetNextRef(&fCurrentRef) != B_OK)
result = B_ERROR; 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 // alphabetically first in the given directory, and load it
if (result == B_OK && ShowNextImage(true, true) == false) if (result == B_OK && ShowNextImage(true, true) == false)
result = B_ERROR; result = B_ERROR;
fNewDirectory = true; fNewDirectory = true;
fLock.Unlock(); fLock.Unlock();
return result; return result;
} }
@@ -207,25 +207,25 @@ SlideShowSaver::StartSaver(BView *view, bool preview)
{ {
UpdateShowCaption(); UpdateShowCaption();
UpdateShowBorder(); UpdateShowBorder();
if (UpdateDirectory() != B_OK) if (UpdateDirectory() != B_OK)
return B_ERROR; return B_ERROR;
// Read ticksize setting and set it as the delay // Read ticksize setting and set it as the delay
UpdateTickSize(); UpdateTickSize();
return B_OK; return B_OK;
} }
void void
SlideShowSaver::Draw(BView *view, int32 frame) SlideShowSaver::Draw(BView *view, int32 frame)
{ {
fLock.Lock(); fLock.Lock();
view->SetLowColor(0, 0, 0); view->SetLowColor(0, 0, 0);
view->SetHighColor(192, 192, 192); view->SetHighColor(192, 192, 192);
view->SetViewColor(192, 192, 192); view->SetViewColor(192, 192, 192);
bool bResult = false; bool bResult = false;
if (fNewDirectory == true) { if (fNewDirectory == true) {
// Already have a bitmap on the first frame // Already have a bitmap on the first frame
@@ -234,10 +234,10 @@ SlideShowSaver::Draw(BView *view, int32 frame)
bResult = ShowNextImage(true, false); bResult = ShowNextImage(true, false);
// try rewinding to beginning // try rewinding to beginning
if (bResult == false) if (bResult == false)
bResult = ShowNextImage(true, true); bResult = ShowNextImage(true, true);
} }
fNewDirectory = false; fNewDirectory = false;
if (bResult == true && fBitmap != NULL) { if (bResult == true && fBitmap != NULL) {
BRect destRect(0, 0, fBitmap->Bounds().Width(), fBitmap->Bounds().Height()), BRect destRect(0, 0, fBitmap->Bounds().Width(), fBitmap->Bounds().Height()),
vwBounds = view->Bounds(); vwBounds = view->Bounds();
@@ -248,7 +248,7 @@ SlideShowSaver::Draw(BView *view, int32 frame)
if (destRect.Height() < vwBounds.Height()) { if (destRect.Height() < vwBounds.Height()) {
destRect.OffsetBy(0, (vwBounds.Height() - destRect.Height()) / 2); destRect.OffsetBy(0, (vwBounds.Height() - destRect.Height()) / 2);
} }
BRect border = destRect, bounds = view->Bounds(); BRect border = destRect, bounds = view->Bounds();
// top // top
view->FillRect(BRect(0, 0, bounds.right, border.top-1), B_SOLID_LOW); 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); view->FillRect(BRect(border.right+1, border.top, bounds.right, border.bottom), B_SOLID_LOW);
// bottom // bottom
view->FillRect(BRect(0, border.bottom+1, bounds.right, bounds.bottom), B_SOLID_LOW); view->FillRect(BRect(0, border.bottom+1, bounds.right, bounds.bottom), B_SOLID_LOW);
if (fShowBorder == true) { if (fShowBorder == true) {
BRect strokeRect = destRect; BRect strokeRect = destRect;
strokeRect.InsetBy(-1, -1); strokeRect.InsetBy(-1, -1);
view->StrokeRect(strokeRect); view->StrokeRect(strokeRect);
} }
view->DrawBitmap(fBitmap, fBitmap->Bounds(), destRect); view->DrawBitmap(fBitmap, fBitmap->Bounds(), destRect);
if (fShowCaption == true) if (fShowCaption == true)
DrawCaption(view); DrawCaption(view);
} }
fLock.Unlock(); fLock.Unlock();
} }
@@ -303,7 +303,7 @@ SlideShowSaver::SetImage(const entry_ref *pref)
if (proster->Identify(&file, &ioExtension, &info, 0, NULL, if (proster->Identify(&file, &ioExtension, &info, 0, NULL,
B_TRANSLATOR_BITMAP) != B_OK) B_TRANSLATOR_BITMAP) != B_OK)
return B_ERROR; return B_ERROR;
// Translate image data and create a new ShowImage window // Translate image data and create a new ShowImage window
BBitmapStream outstream; BBitmapStream outstream;
if (proster->Translate(&file, &info, &ioExtension, &outstream, if (proster->Translate(&file, &info, &ioExtension, &outstream,
@@ -312,15 +312,15 @@ SlideShowSaver::SetImage(const entry_ref *pref)
BBitmap *newBitmap = NULL; BBitmap *newBitmap = NULL;
if (outstream.DetachBitmap(&newBitmap) != B_OK) if (outstream.DetachBitmap(&newBitmap) != B_OK)
return B_ERROR; return B_ERROR;
// Now that I've successfully loaded the new bitmap, // 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 // and clear everything
delete fBitmap; delete fBitmap;
fBitmap = newBitmap; fBitmap = newBitmap;
newBitmap = NULL; newBitmap = NULL;
fCurrentRef = ref; fCurrentRef = ref;
// Get path to use in caption // Get path to use in caption
fCaption = "<< Unable to read the path >>"; fCaption = "<< Unable to read the path >>";
BEntry entry(&fCurrentRef); BEntry entry(&fCurrentRef);
@@ -340,7 +340,7 @@ SlideShowSaver::ShowNextImage(bool next, bool rewind)
{ {
bool found; bool found;
entry_ref curRef, imgRef; entry_ref curRef, imgRef;
curRef = fCurrentRef; curRef = fCurrentRef;
found = FindNextImage(&curRef, &imgRef, next, rewind); found = FindNextImage(&curRef, &imgRef, next, rewind);
if (found) { if (found) {
@@ -367,7 +367,7 @@ SlideShowSaver::IsImage(const entry_ref *pref)
{ {
if (!pref) if (!pref)
return false; return false;
if (ent_is_dir(pref) != B_OK) if (ent_is_dir(pref) != B_OK)
// if ref is erroneous or a directory, return false // if ref is erroneous or a directory, return false
return false; return false;
@@ -379,7 +379,7 @@ SlideShowSaver::IsImage(const entry_ref *pref)
BTranslatorRoster *proster = BTranslatorRoster::Default(); BTranslatorRoster *proster = BTranslatorRoster::Default();
if (!proster) if (!proster)
return false; return false;
BMessage ioExtension; BMessage ioExtension;
if (ioExtension.AddInt32("/documentIndex", 1) != B_OK) if (ioExtension.AddInt32("/documentIndex", 1) != B_OK)
return false; return false;
@@ -389,7 +389,7 @@ SlideShowSaver::IsImage(const entry_ref *pref)
if (proster->Identify(&file, &ioExtension, &info, 0, NULL, if (proster->Identify(&file, &ioExtension, &info, 0, NULL,
B_TRANSLATOR_BITMAP) != B_OK) B_TRANSLATOR_BITMAP) != B_OK)
return false; return false;
return true; return true;
} }
@@ -405,7 +405,7 @@ SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool
BList entries; BList entries;
bool found = false; bool found = false;
int32 cur; int32 cur;
if (curImage.GetParent(&parent) != B_OK) if (curImage.GetParent(&parent) != B_OK)
return false; return false;
@@ -417,15 +417,15 @@ SlideShowSaver::FindNextImage(entry_ref *in_current, entry_ref *out_image, bool
entries.AddItem(in_current); entries.AddItem(in_current);
} }
} }
entries.SortItems(CompareEntries); entries.SortItems(CompareEntries);
cur = entries.IndexOf(in_current); cur = entries.IndexOf(in_current);
// ASSERT(cur >= 0); // ASSERT(cur >= 0);
// remove it so FreeEntries() does not delete it // remove it so FreeEntries() does not delete it
entries.RemoveItem(in_current); entries.RemoveItem(in_current);
if (next) { if (next) {
// find the next image in the list // find the next image in the list
if (rewind) cur = 0; // start with first if (rewind) cur = 0; // start with first
@@ -461,7 +461,7 @@ SlideShowSaver::FreeEntries(BList *entries)
const int32 n = entries->CountItems(); const int32 n = entries->CountItems();
for (int32 i = 0; i < n; i ++) { for (int32 i = 0; i < n; i ++) {
entry_ref *ref = (entry_ref *)entries->ItemAt(i); entry_ref *ref = (entry_ref *)entries->ItemAt(i);
delete ref; delete ref;
} }
entries->MakeEmpty(); entries->MakeEmpty();
} }
@@ -480,20 +480,20 @@ SlideShowSaver::LayoutCaption(BView *view, BFont &font, BPoint &pos, BRect &rect
pos.x = (bounds.left + bounds.right - width)/2; pos.x = (bounds.left + bounds.right - width)/2;
// flush bottom // flush bottom
pos.y = bounds.bottom - fontHeight.descent - 5; pos.y = bounds.bottom - fontHeight.descent - 5;
// background rectangle // background rectangle
rect.Set(0, 0, (width-1)+2, (height-1)+2+1); // 2 for border and 1 for text shadow rect.Set(0, 0, (width-1)+2, (height-1)+2+1); // 2 for border and 1 for text shadow
rect.OffsetTo(pos); rect.OffsetTo(pos);
rect.OffsetBy(-1, -1-fontHeight.ascent); // -1 for border rect.OffsetBy(-1, -1-fontHeight.ascent); // -1 for border
} }
void void
SlideShowSaver::DrawCaption(BView *view) SlideShowSaver::DrawCaption(BView *view)
{ {
BFont font; BFont font;
BPoint pos; BPoint pos;
BRect rect; BRect rect;
LayoutCaption(view, font, pos, rect); LayoutCaption(view, font, pos, rect);
view->PushState(); view->PushState();
// draw background // draw background
+1 -1
View File
@@ -389,7 +389,7 @@ private:
AboutApp::AboutApp() AboutApp::AboutApp()
: BApplication("application/x-vnd.Haiku-About") : 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(); AboutWindow *window = new(std::nothrow) AboutWindow();
if (window) if (window)
+11 -13
View File
@@ -41,15 +41,13 @@ const char* kCategoryString[] = {
}; };
// This list is only used to translate Device properties // This list is only used to translate Device properties
static const char* kTranslateMarkString[] = { B_TRANSLATE_MARK_VOID("unknown");
B_TRANSLATE_MARK("unknown"), B_TRANSLATE_MARK_VOID("Device");
B_TRANSLATE_MARK("Device"), B_TRANSLATE_MARK_VOID("Computer");
B_TRANSLATE_MARK("Computer"), B_TRANSLATE_MARK_VOID("ACPI bus");
B_TRANSLATE_MARK("ACPI bus"), B_TRANSLATE_MARK_VOID("PCI bus");
B_TRANSLATE_MARK("PCI bus"), B_TRANSLATE_MARK_VOID("ISA bus");
B_TRANSLATE_MARK("ISA bus"), B_TRANSLATE_MARK_VOID("Unknown device");
B_TRANSLATE_MARK("Unknown device")
};
Device::Device(Device* physicalParent, BusType busType, Category category, Device::Device(Device* physicalParent, BusType busType, Category category,
@@ -150,8 +148,8 @@ Device::GetBasicStrings()
"Manufacturer\t\t\t: %Manufacturer%\n" "Manufacturer\t\t\t: %Manufacturer%\n"
"Driver used\t\t\t\t: %DriverUsed%\n" "Driver used\t\t\t\t: %DriverUsed%\n"
"Device paths\t: %DevicePaths%")); "Device paths\t: %DevicePaths%"));
str.ReplaceFirst("%Name%", GetName()); str.ReplaceFirst("%Name%", GetName());
str.ReplaceFirst("%Manufacturer%", GetManufacturer()); str.ReplaceFirst("%Manufacturer%", GetManufacturer());
str.ReplaceFirst("%DriverUsed%", GetDriverUsed()); str.ReplaceFirst("%DriverUsed%", GetDriverUsed());
str.ReplaceFirst("%DevicePaths%", GetDevPathsPublished()); str.ReplaceFirst("%DevicePaths%", GetDevPathsPublished());
@@ -168,8 +166,8 @@ Device::GetBusStrings()
BString BString
Device::GetBusTabName() Device::GetBusTabName()
{ {
return B_TRANSLATE("Bus Information"); return B_TRANSLATE("Bus Information");
} }
+1 -1
View File
@@ -73,7 +73,7 @@ TPeopleApp::TPeopleApp()
fWindowCount(0), fWindowCount(0),
fAttributes(20, true) 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, fPosition.Set(6, TITLE_BAR_HEIGHT, 6 + WIND_WIDTH,
TITLE_BAR_HEIGHT + WIND_HEIGHT); TITLE_BAR_HEIGHT + WIND_HEIGHT);
+2 -2
View File
@@ -39,7 +39,7 @@ ShowImageApp::ShowImageApp()
fPulseStarted(false), fPulseStarted(false),
fLastWindowFrame(BRect(30, 30, 430, 330)) fLastWindowFrame(BRect(30, 30, 430, 330))
{ {
B_TRANSLATE_MARK_SYSTEM_NAME("ShowImage"); B_TRANSLATE_MARK_SYSTEM_NAME_VOID("ShowImage");
_UpdateLastWindowFrame(); _UpdateLastWindowFrame();
// BBitmap can be created after there is a BApplication instance. // BBitmap can be created after there is a BApplication instance.
init_tool_bar_icons(); init_tool_bar_icons();
@@ -198,7 +198,7 @@ ShowImageApp::_Open(const entry_ref& ref, const BMessenger& trackerMessenger)
fLastWindowFrame.OffsetBy(20, 20); fLastWindowFrame.OffsetBy(20, 20);
if (!BScreen(B_MAIN_SCREEN_ID).Frame().Contains(fLastWindowFrame)) if (!BScreen(B_MAIN_SCREEN_ID).Frame().Contains(fLastWindowFrame))
fLastWindowFrame.OffsetTo(50, 50); fLastWindowFrame.OffsetTo(50, 50);
new ShowImageWindow(fLastWindowFrame, ref, trackerMessenger); new ShowImageWindow(fLastWindowFrame, ref, trackerMessenger);
} }
+2 -2
View File
@@ -89,8 +89,8 @@ StyledEditApp::StyledEditApp()
BApplication(APP_SIGNATURE), BApplication(APP_SIGNATURE),
fOpenPanel(NULL) fOpenPanel(NULL)
{ {
B_TRANSLATE_MARK_SYSTEM_NAME("StyledEdit"); B_TRANSLATE_MARK_SYSTEM_NAME_VOID("StyledEdit");
fOpenPanel = new BFilePanel(); fOpenPanel = new BFilePanel();
fOpenAsEncoding = 0; fOpenAsEncoding = 0;
+3 -3
View File
@@ -52,7 +52,7 @@ All rights reserved.
int main(int , char **) int main(int , char **)
{ {
#ifdef PROFILE #ifdef PROFILE
PROFILE_INIT(1024); PROFILE_INIT(1024);
#endif #endif
@@ -60,12 +60,12 @@ int main(int , char **)
SetNewLeakChecking(true); SetNewLeakChecking(true);
SetMallocLeakChecking(true); SetMallocLeakChecking(true);
#endif #endif
B_TRANSLATE_MARK_SYSTEM_NAME("Tracker"); B_TRANSLATE_MARK_SYSTEM_NAME_VOID("Tracker");
TTracker tracker; TTracker tracker;
tracker.Run(); tracker.Run();
#ifdef PROFILE #ifdef PROFILE
PROFILE_DUMP("/boot/home/Desktop/trackerProfile"); PROFILE_DUMP("/boot/home/Desktop/trackerProfile");
#endif #endif
+80 -80
View File
@@ -46,9 +46,9 @@
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "MainWin" #define B_TRANSLATE_CONTEXT "MainWin"
static const char* fLocalizedName = B_TRANSLATE_MARK("TV"); B_TRANSLATE_MARK_VOID("TV");
static const char* fLocalizedRevision = B_TRANSLATE_MARK("unknown"); B_TRANSLATE_MARK_VOID("unknown");
static const char* fLocalizedInfo1 = B_TRANSLATE_MARK("DVB - Digital Video Broadcasting TV"); B_TRANSLATE_MARK_VOID("DVB - Digital Video Broadcasting TV");
enum enum
{ {
@@ -85,7 +85,7 @@ enum
MainWin::MainWin(BRect frame_rect) 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 */) B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */)
, fController(new Controller) , fController(new Controller)
, fIsFullscreen(false) , fIsFullscreen(false)
@@ -103,9 +103,9 @@ MainWin::MainWin(BRect frame_rect)
, fFrameResizedCalled(true) , fFrameResizedCalled(true)
{ {
BRect rect = Bounds(); BRect rect = Bounds();
// background // 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); B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fBackground->SetViewColor(0,0,0); fBackground->SetViewColor(0,0,0);
AddChild(fBackground); AddChild(fBackground);
@@ -120,14 +120,14 @@ MainWin::MainWin(BRect frame_rect)
// video view // video view
BRect video_rect = BRect(0, fMenuBarHeight, rect.right, rect.bottom); 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); B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fBackground->AddChild(fVideoView); fBackground->AddChild(fVideoView);
fVideoView->MakeFocus(); fVideoView->MakeFocus();
// SetSizeLimits(fControlViewMinWidth - 1, 32767, // SetSizeLimits(fControlViewMinWidth - 1, 32767,
// fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight // fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight
// + fControlViewHeight - 1); // + fControlViewHeight - 1);
// SetSizeLimits(320 - 1, 32767, 240 + fMenuBarHeight - 1, 32767); // SetSizeLimits(320 - 1, 32767, 240 + fMenuBarHeight - 1, 32767);
@@ -174,40 +174,40 @@ MainWin::CreateMenu()
fMenuBar->AddItem(fSettingsMenu); fMenuBar->AddItem(fSettingsMenu);
fMenuBar->AddItem(fDebugMenu); 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)); 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)); 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)); new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY));
fChannelMenu->AddSeparatorItem(); 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)); 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)); B_COMMAND_KEY));
fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none"), fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none"),
new BMessage(M_DUMMY))); new BMessage(M_DUMMY)));
fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 1"), fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 1"),
new BMessage(M_DUMMY))); new BMessage(M_DUMMY)));
fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 2"), fInterfaceMenu->AddItem(new BMenuItem(B_TRANSLATE("none 2"),
new BMessage(M_DUMMY))); 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)); 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)); new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY));
fSettingsMenu->AddSeparatorItem(); 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)); 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)); 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)); 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)); new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY));
fSettingsMenu->AddSeparatorItem(); fSettingsMenu->AddSeparatorItem();
fSettingsMenu->AddItem(new BMenuItem(B_TRANSLATE("Settings"B_UTF8_ELLIPSIS) 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"); const char* pixel_ratio = B_TRANSLATE("pixel aspect ratio");
BString str1 = pixel_ratio; BString str1 = pixel_ratio;
str1 << " 1.00000:1"; str1 << " 1.00000:1";
fDebugMenu->AddItem(new BMenuItem(str1.String(), fDebugMenu->AddItem(new BMenuItem(str1.String(),
new BMessage(M_ASPECT_100000_1))); new BMessage(M_ASPECT_100000_1)));
BString str2 = pixel_ratio; BString str2 = pixel_ratio;
str2 << " 1.06666:1"; str2 << " 1.06666:1";
fDebugMenu->AddItem(new BMenuItem(str2.String(), fDebugMenu->AddItem(new BMenuItem(str2.String(),
new BMessage(M_ASPECT_106666_1))); new BMessage(M_ASPECT_106666_1)));
BString str3 = pixel_ratio; BString str3 = pixel_ratio;
str3 << " 1.09091:1"; str3 << " 1.09091:1";
fDebugMenu->AddItem(new BMenuItem(str3.String(), fDebugMenu->AddItem(new BMenuItem(str3.String(),
new BMessage(M_ASPECT_109091_1))); new BMessage(M_ASPECT_109091_1)));
BString str4 = pixel_ratio; BString str4 = pixel_ratio;
str4 << " 1.41176:1"; str4 << " 1.41176:1";
fDebugMenu->AddItem(new BMenuItem(str4.String(), fDebugMenu->AddItem(new BMenuItem(str4.String(),
new BMessage(M_ASPECT_141176_1))); new BMessage(M_ASPECT_141176_1)));
fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( 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))); new BMessage(M_ASPECT_720_576)));
fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( 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))); new BMessage(M_ASPECT_704_576)));
fDebugMenu->AddItem(new BMenuItem(B_TRANSLATE( 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))); new BMessage(M_ASPECT_544_576)));
fSettingsMenu->ItemAt(1)->SetMarked(fIsFullscreen); fSettingsMenu->ItemAt(1)->SetMarked(fIsFullscreen);
@@ -255,7 +255,7 @@ MainWin::SetupInterfaceMenu()
{ {
fInterfaceMenu->RemoveItems(0, fInterfaceMenu->CountItems(), true); 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))); new BMessage(M_SELECT_INTERFACE)));
int count = gDeviceRoster->DeviceCount(); int count = gDeviceRoster->DeviceCount();
@@ -264,9 +264,9 @@ MainWin::SetupInterfaceMenu()
fInterfaceMenu->AddSeparatorItem(); fInterfaceMenu->AddSeparatorItem();
for (int i = 0; i < count; i++) { 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() // 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))); new BMessage(M_SELECT_INTERFACE + i + 1)));
} }
} }
@@ -283,12 +283,12 @@ MainWin::SetupChannelMenu()
int channels = fController->ChannelCount(); int channels = fController->ChannelCount();
if (channels == 0) { if (channels == 0) {
fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("None"), fChannelMenu->AddItem(new BMenuItem(B_TRANSLATE("None"),
new BMessage(M_DUMMY))); new BMessage(M_DUMMY)));
} else { } 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)); 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)); new BMessage(M_CHANNEL_PREV), '-', B_COMMAND_KEY));
fChannelMenu->AddSeparatorItem(); fChannelMenu->AddSeparatorItem();
} }
@@ -405,7 +405,7 @@ MainWin::SelectInitialInterface()
int count = gDeviceRoster->DeviceCount(); int count = gDeviceRoster->DeviceCount();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (fController->IsInterfaceAvailable(i) if (fController->IsInterfaceAvailable(i)
&& B_OK == fController->ConnectInterface(i)) { && B_OK == fController->ConnectInterface(i)) {
printf("MainWin::SelectInitialInterface connected to interface " printf("MainWin::SelectInitialInterface connected to interface "
"%d\n", i); "%d\n", i);
@@ -431,7 +431,7 @@ MainWin::MouseDown(BMessage *msg)
BPoint screen_where; BPoint screen_where;
uint32 buttons = msg->FindInt32("buttons"); 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 // seem to be broken
if (B_OK != msg->FindPoint("screen_where", &screen_where)) { if (B_OK != msg->FindPoint("screen_where", &screen_where)) {
// Workaround for BeOS R5, it has no "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 == msg->FindInt32("buttons") && msg->FindInt32("clicks") == 1) {
if (1 == buttons && msg->FindInt32("clicks") % 2 == 0) { 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); screen_where.y + 1);
if (r.Contains(fMouseDownMousePos)) { if (r.Contains(fMouseDownMousePos)) {
PostMessage(M_TOGGLE_FULLSCREEN); PostMessage(M_TOGGLE_FULLSCREEN);
@@ -453,7 +453,7 @@ MainWin::MouseDown(BMessage *msg)
} }
if (2 == buttons && msg->FindInt32("clicks") % 2 == 0) { 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); screen_where.y + 1);
if (r.Contains(fMouseDownMousePos)) { if (r.Contains(fMouseDownMousePos)) {
PostMessage(M_TOGGLE_NO_BORDER_NO_MENU); PostMessage(M_TOGGLE_NO_BORDER_NO_MENU);
@@ -471,7 +471,7 @@ MainWin::MouseDown(BMessage *msg)
if (buttons == 1 && !fIsFullscreen) { if (buttons == 1 && !fIsFullscreen) {
// start mouse tracking // 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 */); /* | B_LOCK_WINDOW_FOCUS */);
fMouseDownTracking = true; fMouseDownTracking = true;
} }
@@ -510,7 +510,7 @@ MainWin::MouseMoved(BMessage *msg)
printf("view where: %.0f, %.0f => ", mousePos.x, mousePos.y); printf("view where: %.0f, %.0f => ", mousePos.x, mousePos.y);
fVideoView->ConvertToScreen(&mousePos); 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 // "be:view_where" seem to be broken
if (B_OK != msg->FindPoint("screen_where", &mousePos)) { if (B_OK != msg->FindPoint("screen_where", &mousePos)) {
// Workaround for BeOS R5, it has no "screen_where" // Workaround for BeOS R5, it has no "screen_where"
@@ -542,65 +542,65 @@ MainWin::ShowContextMenu(const BPoint &screen_point)
printf("Show context menu\n"); printf("Show context menu\n");
BPopUpMenu *menu = new BPopUpMenu("context menu", false, false); BPopUpMenu *menu = new BPopUpMenu("context menu", false, false);
BMenuItem *item; 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)); 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)); new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY));
item->SetMarked(fIsFullscreen); item->SetMarked(fIsFullscreen);
menu->AddSeparatorItem(); 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)); new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY));
item->SetMarked(fNoMenu); 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)); new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY));
item->SetMarked(fNoBorder); 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)); new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY));
item->SetMarked(fAlwaysOnTop); 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)); new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY));
item->SetMarked(fKeepAspectRatio); item->SetMarked(fKeepAspectRatio);
menu->AddSeparatorItem(); 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)); new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
const char* pixel_aspect = "pixel aspect ratio"; const char* pixel_aspect = "pixel aspect ratio";
BString str1 = pixel_aspect; BString str1 = pixel_aspect;
str1 << " 1.00000:1"; str1 << " 1.00000:1";
menu->AddItem(new BMenuItem(str1.String(), menu->AddItem(new BMenuItem(str1.String(),
new BMessage(M_ASPECT_100000_1))); new BMessage(M_ASPECT_100000_1)));
BString str2 = pixel_aspect; BString str2 = pixel_aspect;
str2 << " 1.06666:1"; str2 << " 1.06666:1";
menu->AddItem(new BMenuItem(str2.String(), menu->AddItem(new BMenuItem(str2.String(),
new BMessage(M_ASPECT_106666_1))); new BMessage(M_ASPECT_106666_1)));
BString str3 = pixel_aspect; BString str3 = pixel_aspect;
str3 << " 1.09091:1"; str3 << " 1.09091:1";
menu->AddItem(new BMenuItem(str3.String(), menu->AddItem(new BMenuItem(str3.String(),
new BMessage(M_ASPECT_109091_1))); new BMessage(M_ASPECT_109091_1)));
BString str4 = pixel_aspect; BString str4 = pixel_aspect;
str4 << " 1.41176:1"; str4 << " 1.41176:1";
menu->AddItem(new BMenuItem(str4.String(), menu->AddItem(new BMenuItem(str4.String(),
new BMessage(M_ASPECT_141176_1))); new BMessage(M_ASPECT_141176_1)));
menu->AddItem(new BMenuItem(B_TRANSLATE( 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))); new BMessage(M_ASPECT_720_576)));
menu->AddItem(new BMenuItem(B_TRANSLATE( 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))); new BMessage(M_ASPECT_704_576)));
menu->AddItem(new BMenuItem(B_TRANSLATE( 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))); new BMessage(M_ASPECT_544_576)));
menu->SetTargetForItems(this); 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); screen_point.y + 5);
menu->Go(screen_point, true, true, r, true); menu->Go(screen_point, true, true, r, true);
} }
void void
MainWin::VideoFormatChange(int width, int height, float width_scale, MainWin::VideoFormatChange(int width, int height, float width_scale,
float height_scale) float height_scale)
{ {
// called when video format or aspect ratio changes // 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) { if (width_scale < 1.0 && height_scale >= 1.0) {
width_scale = 1.0 / width_scale; width_scale = 1.0 / width_scale;
height_scale = 1.0 / height_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); 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 " 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()); Bounds().Height());
if (fIsFullscreen) { if (fIsFullscreen) {
@@ -715,7 +715,7 @@ MainWin::AdjustFullscreenRenderer()
float max_height = fBackground->Bounds().Height() + 1.0f; float max_height = fBackground->Bounds().Height() + 1.0f;
float scaled_width = fSourceWidth * fWidthScale; float scaled_width = fSourceWidth * fWidthScale;
float scaled_height = fSourceHeight * fHeightScale; 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); / scaled_height);
int render_width = int(scaled_width * factor); int render_width = int(scaled_width * factor);
int render_height = int(scaled_height * factor); int render_height = int(scaled_height * factor);
@@ -724,8 +724,8 @@ MainWin::AdjustFullscreenRenderer()
printf("AdjustFullscreenRenderer: background %.1f x %.1f, src video " printf("AdjustFullscreenRenderer: background %.1f x %.1f, src video "
"%d x %d, scaled video %.3f x %.3f, factor %.3f, render %d x %d, " "%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, "x-ofs %d, y-ofs %d\n", max_width, max_height, fSourceWidth,
fSourceHeight, scaled_width, scaled_height, factor, render_width, fSourceHeight, scaled_width, scaled_height, factor, render_width,
render_height, x_ofs, y_ofs); render_height, x_ofs, y_ofs);
fVideoView->MoveTo(x_ofs, y_ofs); fVideoView->MoveTo(x_ofs, y_ofs);
@@ -738,7 +738,7 @@ MainWin::AdjustFullscreenRenderer()
// no need to keep aspect ratio, make // no need to keep aspect ratio, make
// render cover the whole background // render cover the whole background
fVideoView->MoveTo(0, 0); fVideoView->MoveTo(0, 0);
fVideoView->ResizeTo(fBackground->Bounds().Width(), fVideoView->ResizeTo(fBackground->Bounds().Width(),
fBackground->Bounds().Height()); fBackground->Bounds().Height());
} }
@@ -753,7 +753,7 @@ MainWin::AdjustWindowedRenderer(bool user_resized)
// In windowed mode, the renderer always covers the // In windowed mode, the renderer always covers the
// whole background, accounting for the menu // whole background, accounting for the menu
fVideoView->MoveTo(0, fNoMenu ? 0 : fMenuBarHeight); fVideoView->MoveTo(0, fNoMenu ? 0 : fMenuBarHeight);
fVideoView->ResizeTo(fBackground->Bounds().Width(), fVideoView->ResizeTo(fBackground->Bounds().Width(),
fBackground->Bounds().Height() - (fNoMenu ? 0 : fMenuBarHeight)); fBackground->Bounds().Height() - (fNoMenu ? 0 : fMenuBarHeight));
if (fKeepAspectRatio) { if (fKeepAspectRatio) {
@@ -761,19 +761,19 @@ MainWin::AdjustWindowedRenderer(bool user_resized)
// do resize the window as required // do resize the window as required
float max_width = Bounds().Width() + 1.0f; 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); : fMenuBarHeight);
float scaled_width = fSourceWidth * fWidthScale; float scaled_width = fSourceWidth * fWidthScale;
float scaled_height = fSourceHeight * fHeightScale; float scaled_height = fSourceHeight * fHeightScale;
if (!user_resized && (scaled_width > max_width if (!user_resized && (scaled_width > max_width
|| scaled_height > max_height)) { || scaled_height > max_height)) {
// A format switch occured, and the window was // A format switch occured, and the window was
// smaller then the video source. As it was not // smaller then the video source. As it was not
// initiated by the user resizing the window, we // initiated by the user resizing the window, we
// enlarge the window to fit the video. // enlarge the window to fit the video.
fIgnoreFrameResized = true; fIgnoreFrameResized = true;
ResizeTo(scaled_width - 1, scaled_height - 1 ResizeTo(scaled_width - 1, scaled_height - 1
+ (fNoMenu ? 0 : fMenuBarHeight)); + (fNoMenu ? 0 : fMenuBarHeight));
// Sync(); // Sync();
return; return;
@@ -785,12 +785,12 @@ MainWin::AdjustWindowedRenderer(bool user_resized)
printf("AdjustWindowedRenderer: old display %d x %d, src video " printf("AdjustWindowedRenderer: old display %d x %d, src video "
"%d x %d, scaled video %.3f x %.3f, aspect ratio %.3f, new " "%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, fSourceWidth, fSourceHeight, scaled_width, scaled_height,
display_aspect_ratio, new_width, new_height); display_aspect_ratio, new_width, new_height);
fIgnoreFrameResized = true; fIgnoreFrameResized = true;
ResizeTo(new_width - 1, new_height - 1 + (fNoMenu ? 0 ResizeTo(new_width - 1, new_height - 1 + (fNoMenu ? 0
: fMenuBarHeight)); : fMenuBarHeight));
// Sync(); // Sync();
} }
@@ -839,8 +839,8 @@ MainWin::ToggleFullscreen()
// Sync(); // Sync();
fSavedFrame = Frame(); fSavedFrame = Frame();
printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left), printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left),
int(fSavedFrame.top), int(fSavedFrame.right), int(fSavedFrame.top), int(fSavedFrame.right),
int(fSavedFrame.bottom)); int(fSavedFrame.bottom));
BScreen screen(this); BScreen screen(this);
BRect rect(screen.Frame()); BRect rect(screen.Frame());
@@ -970,7 +970,7 @@ MainWin::KeyDown(BMessage *msg)
uint32 raw_char = msg->FindInt32("raw_char"); uint32 raw_char = msg->FindInt32("raw_char");
uint32 modifiers = msg->FindInt32("modifiers"); 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); modifiers);
switch (raw_char) { switch (raw_char) {
@@ -993,7 +993,7 @@ MainWin::KeyDown(BMessage *msg)
break; break;
case B_TAB: 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) { | B_MENU_KEY)) == 0) {
PostMessage(M_TOGGLE_FULLSCREEN); PostMessage(M_TOGGLE_FULLSCREEN);
return B_OK; return B_OK;
@@ -1086,17 +1086,17 @@ MainWin::KeyDown(BMessage *msg)
void void
MainWin::DispatchMessage(BMessage *msg, BHandler *handler) MainWin::DispatchMessage(BMessage *msg, BHandler *handler)
{ {
if ((msg->what == B_MOUSE_DOWN) && (handler == fBackground if ((msg->what == B_MOUSE_DOWN) && (handler == fBackground
|| handler == fVideoView)) || handler == fVideoView))
MouseDown(msg); MouseDown(msg);
if ((msg->what == B_MOUSE_MOVED) && (handler == fBackground if ((msg->what == B_MOUSE_MOVED) && (handler == fBackground
|| handler == fVideoView)) || handler == fVideoView))
MouseMoved(msg); MouseMoved(msg);
if ((msg->what == B_MOUSE_UP) && (handler == fBackground if ((msg->what == B_MOUSE_UP) && (handler == fBackground
|| handler == fVideoView)) || handler == fVideoView))
MouseUp(msg); MouseUp(msg);
if ((msg->what == B_KEY_DOWN) && (handler == fBackground if ((msg->what == B_KEY_DOWN) && (handler == fBackground
|| handler == fVideoView)) { || handler == fVideoView)) {
// special case for PrintScreen key // special case for PrintScreen key
@@ -1229,7 +1229,7 @@ MainWin::MessageReceived(BMessage *msg)
ToggleFullscreen(); ToggleFullscreen();
} }
ResizeTo(int(fSourceWidth * fWidthScale), ResizeTo(int(fSourceWidth * fWidthScale),
int(fSourceHeight * fHeightScale) + (fNoMenu ? 0 int(fSourceHeight * fHeightScale) + (fNoMenu ? 0
: fMenuBarHeight)); : fMenuBarHeight));
// Sync(); // Sync();
break; break;
@@ -1267,12 +1267,12 @@ MainWin::MessageReceived(BMessage *msg)
break; break;
default: default:
if (msg->what >= M_SELECT_CHANNEL if (msg->what >= M_SELECT_CHANNEL
&& msg->what <= M_SELECT_CHANNEL_END) { && msg->what <= M_SELECT_CHANNEL_END) {
SelectChannel(msg->what - M_SELECT_CHANNEL); SelectChannel(msg->what - M_SELECT_CHANNEL);
break; break;
} }
if (msg->what >= M_SELECT_INTERFACE if (msg->what >= M_SELECT_INTERFACE
&& msg->what <= M_SELECT_INTERFACE_END) { && msg->what <= M_SELECT_INTERFACE_END) {
SelectInterface(msg->what - M_SELECT_INTERFACE - 1); SelectInterface(msg->what - M_SELECT_INTERFACE - 1);
break; break;
+18 -18
View File
@@ -1,22 +1,22 @@
/* /*
* Copyright (c) 1999-2003 Matthijs Hollemans * Copyright (c) 1999-2003 Matthijs Hollemans
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the * 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: * 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. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * 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 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
@@ -37,7 +37,7 @@ BView* instantiate_deskbar_item()
WatchApp::WatchApp() : BApplication(APP_SIGNATURE) 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 // 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 // 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); be_roster->FindApp(APP_SIGNATURE, &ref);
deskbar.AddItem(&ref); deskbar.AddItem(&ref);
} }
PostMessage(B_QUIT_REQUESTED); PostMessage(B_QUIT_REQUESTED);
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
int main() int main()
{ {
WatchApp watchApp; WatchApp watchApp;
watchApp.Run(); watchApp.Run();
+1 -1
View File
@@ -51,7 +51,7 @@ main(int argc, char **argv)
exit(-1); exit(-1);
} }
DefaultCatalog* inputCatImpl DefaultCatalog* inputCatImpl
= dynamic_cast<DefaultCatalog*>(inputCatalog.CatalogAddOn()); = dynamic_cast<DefaultCatalog*>(inputCatalog.CatalogData());
if (!inputCatImpl) { if (!inputCatImpl) {
fprintf(stderr, "couldn't access impl of input-catalog %s\n", fprintf(stderr, "couldn't access impl of input-catalog %s\n",
inputFile); inputFile);
+2 -2
View File
@@ -100,7 +100,7 @@ main(int argc, char **argv)
exit(-1); exit(-1);
} }
DefaultCatalog* targetCatImpl DefaultCatalog* targetCatImpl
= dynamic_cast<DefaultCatalog*>(targetCatalog.CatalogAddOn()); = dynamic_cast<DefaultCatalog*>(targetCatalog.CatalogData());
if (!targetCatImpl) { if (!targetCatImpl) {
fprintf(stderr, "couldn't access impl of target-catalog %s\n", fprintf(stderr, "couldn't access impl of target-catalog %s\n",
outputFile.String()); outputFile.String());
@@ -116,7 +116,7 @@ main(int argc, char **argv)
exit(-1); exit(-1);
} }
HashMapCatalog* inputCatImpl HashMapCatalog* inputCatImpl
= dynamic_cast<HashMapCatalog*>(inputCatalog.CatalogAddOn()); = dynamic_cast<HashMapCatalog*>(inputCatalog.CatalogData());
if (!inputCatImpl) { if (!inputCatImpl) {
fprintf(stderr, "couldn't access impl of input-catalog %s\n", fprintf(stderr, "couldn't access impl of input-catalog %s\n",
inputFiles[i]); inputFiles[i]);
+20 -173
View File
@@ -10,6 +10,7 @@
#include <Application.h> #include <Application.h>
#include <Autolock.h> #include <Autolock.h>
#include <CatalogData.h>
#include <Locale.h> #include <Locale.h>
#include <MutableLocaleRoster.h> #include <MutableLocaleRoster.h>
#include <Node.h> #include <Node.h>
@@ -22,7 +23,7 @@ using BPrivate::MutableLocaleRoster;
//#pragma mark - BCatalog //#pragma mark - BCatalog
BCatalog::BCatalog() BCatalog::BCatalog()
: :
fCatalog(NULL), fCatalogData(NULL),
fLock("Catalog") fLock("Catalog")
{ {
} }
@@ -31,7 +32,7 @@ BCatalog::BCatalog()
BCatalog::BCatalog(const entry_ref& catalogOwner, const char* language, BCatalog::BCatalog(const entry_ref& catalogOwner, const char* language,
uint32 fingerprint) uint32 fingerprint)
: :
fCatalog(NULL), fCatalogData(NULL),
fLock("Catalog") fLock("Catalog")
{ {
SetTo(catalogOwner, language, fingerprint); SetTo(catalogOwner, language, fingerprint);
@@ -40,7 +41,7 @@ BCatalog::BCatalog(const entry_ref& catalogOwner, const char* language,
BCatalog::~BCatalog() BCatalog::~BCatalog()
{ {
MutableLocaleRoster::Default()->UnloadCatalog(fCatalog); MutableLocaleRoster::Default()->UnloadCatalog(fCatalogData);
} }
@@ -53,7 +54,7 @@ BCatalog::GetString(const char* string, const char* context,
return string; return string;
const char* translated; 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); translated = cat->GetString(string, context, comment);
if (translated != NULL) if (translated != NULL)
return translated; return translated;
@@ -71,7 +72,7 @@ BCatalog::GetString(uint32 id)
return ""; return "";
const char* translated; 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); translated = cat->GetString(id);
if (translated != NULL) if (translated != NULL)
return translated; return translated;
@@ -88,11 +89,11 @@ BCatalog::GetData(const char* name, BMessage* msg)
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; return B_ERROR;
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
status_t res; 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); res = cat->GetData(name, msg);
if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP)
return res; // return B_OK if found, or specific error-code return res; // return B_OK if found, or specific error-code
@@ -109,11 +110,11 @@ BCatalog::GetData(uint32 id, BMessage* msg)
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; return B_ERROR;
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
status_t res; 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); res = cat->GetData(id, msg);
if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP)
return res; // return B_OK if found, or specific error-code return res; // return B_OK if found, or specific error-code
@@ -133,10 +134,10 @@ BCatalog::GetSignature(BString* sig)
if (sig == NULL) if (sig == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
*sig = fCatalog->fSignature; *sig = fCatalogData->fSignature;
return B_OK; return B_OK;
} }
@@ -152,10 +153,10 @@ BCatalog::GetLanguage(BString* lang)
if (lang == NULL) if (lang == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
*lang = fCatalog->fLanguageName; *lang = fCatalogData->fLanguageName;
return B_OK; return B_OK;
} }
@@ -171,10 +172,10 @@ BCatalog::GetFingerprint(uint32* fp)
if (fp == NULL) if (fp == NULL)
return B_BAD_VALUE; return B_BAD_VALUE;
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
*fp = fCatalog->fFingerprint; *fp = fCatalogData->fFingerprint;
return B_OK; return B_OK;
} }
@@ -188,8 +189,8 @@ BCatalog::SetTo(const entry_ref& catalogOwner, const char* language,
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; return B_ERROR;
MutableLocaleRoster::Default()->UnloadCatalog(fCatalog); MutableLocaleRoster::Default()->UnloadCatalog(fCatalogData);
fCatalog = MutableLocaleRoster::Default()->LoadCatalog(catalogOwner, fCatalogData = MutableLocaleRoster::Default()->LoadCatalog(catalogOwner,
language, fingerprint); language, fingerprint);
return B_OK; return B_OK;
@@ -203,7 +204,7 @@ BCatalog::InitCheck() const
if (!lock.IsLocked()) if (!lock.IsLocked())
return B_ERROR; 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()) if (!lock.IsLocked())
return 0; return 0;
return fCatalog != NULL ? fCatalog->CountItems() : 0; return fCatalogData != NULL ? fCatalogData->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;
} }
+160
View File
@@ -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 <CatalogData.h>
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;
}
+2 -2
View File
@@ -593,7 +593,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
} }
BCatalogAddOn * BCatalogData *
DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language, DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language,
uint32 fingerprint) 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::Create(const char *signature, const char *language)
{ {
DefaultCatalog *catalog DefaultCatalog *catalog
+30 -29
View File
@@ -6,6 +6,7 @@
#include <EditableCatalog.h> #include <EditableCatalog.h>
#include <CatalogData.h>
#include <MutableLocaleRoster.h> #include <MutableLocaleRoster.h>
@@ -16,8 +17,8 @@ namespace BPrivate {
EditableCatalog::EditableCatalog(const char* type, const char* signature, EditableCatalog::EditableCatalog(const char* type, const char* signature,
const char* language) const char* language)
{ {
fCatalog = MutableLocaleRoster::Default()->CreateCatalog(type, signature, fCatalogData = MutableLocaleRoster::Default()->CreateCatalog(type,
language); signature, language);
} }
@@ -30,124 +31,124 @@ status_t
EditableCatalog::SetString(const char* string, const char* translated, EditableCatalog::SetString(const char* string, const char* translated,
const char* context, const char* comment) const char* context, const char* comment)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->SetString(string, translated, context, comment); return fCatalogData->SetString(string, translated, context, comment);
} }
status_t status_t
EditableCatalog::SetString(int32 id, const char* translated) EditableCatalog::SetString(int32 id, const char* translated)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->SetString(id, translated); return fCatalogData->SetString(id, translated);
} }
bool bool
EditableCatalog::CanWriteData() const EditableCatalog::CanWriteData() const
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return false; return false;
return fCatalog->CanWriteData(); return fCatalogData->CanWriteData();
} }
status_t status_t
EditableCatalog::SetData(const char* name, BMessage* msg) EditableCatalog::SetData(const char* name, BMessage* msg)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->SetData(name, msg); return fCatalogData->SetData(name, msg);
} }
status_t status_t
EditableCatalog::SetData(uint32 id, BMessage* msg) EditableCatalog::SetData(uint32 id, BMessage* msg)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->SetData(id, msg); return fCatalogData->SetData(id, msg);
} }
status_t status_t
EditableCatalog::ReadFromFile(const char* path) EditableCatalog::ReadFromFile(const char* path)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->ReadFromFile(path); return fCatalogData->ReadFromFile(path);
} }
status_t status_t
EditableCatalog::ReadFromAttribute(const entry_ref& appOrAddOnRef) EditableCatalog::ReadFromAttribute(const entry_ref& appOrAddOnRef)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->ReadFromAttribute(appOrAddOnRef); return fCatalogData->ReadFromAttribute(appOrAddOnRef);
} }
status_t status_t
EditableCatalog::ReadFromResource(const entry_ref& appOrAddOnRef) EditableCatalog::ReadFromResource(const entry_ref& appOrAddOnRef)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->ReadFromResource(appOrAddOnRef); return fCatalogData->ReadFromResource(appOrAddOnRef);
} }
status_t status_t
EditableCatalog::WriteToFile(const char* path) EditableCatalog::WriteToFile(const char* path)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->WriteToFile(path); return fCatalogData->WriteToFile(path);
} }
status_t status_t
EditableCatalog::WriteToAttribute(const entry_ref& appOrAddOnRef) EditableCatalog::WriteToAttribute(const entry_ref& appOrAddOnRef)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->WriteToAttribute(appOrAddOnRef); return fCatalogData->WriteToAttribute(appOrAddOnRef);
} }
status_t status_t
EditableCatalog::WriteToResource(const entry_ref& appOrAddOnRef) EditableCatalog::WriteToResource(const entry_ref& appOrAddOnRef)
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
return B_NO_INIT; return B_NO_INIT;
return fCatalog->WriteToResource(appOrAddOnRef); return fCatalogData->WriteToResource(appOrAddOnRef);
} }
void EditableCatalog::MakeEmpty() void EditableCatalog::MakeEmpty()
{ {
if (fCatalog == NULL) if (fCatalogData == NULL)
fCatalog->MakeEmpty(); fCatalogData->MakeEmpty();
} }
BCatalogAddOn* BCatalogData*
EditableCatalog::CatalogAddOn() EditableCatalog::CatalogData()
{ {
return fCatalog; return fCatalogData;
} }
+1 -1
View File
@@ -20,7 +20,7 @@ namespace BPrivate {
* reading and writing the catalog to a file. Classes doing that are * reading and writing the catalog to a file. Classes doing that are
* HashMapCatalog and PlainTextCatalog. * HashMapCatalog and PlainTextCatalog.
* If you ever need to create a catalog not built around an hash map, inherit * 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. * development tools anymore.
*/ */
+1
View File
@@ -8,6 +8,7 @@ UsePublicHeaders locale storage ;
local sources = local sources =
cat.cpp cat.cpp
Catalog.cpp Catalog.cpp
CatalogData.cpp
Collator.cpp Collator.cpp
Country.cpp Country.cpp
DefaultCatalog.cpp DefaultCatalog.cpp
+11 -11
View File
@@ -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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -67,8 +67,8 @@ CatalogAddOnInfo::~CatalogAddOnInfo()
{ {
int32 count = fLoadedCatalogs.CountItems(); int32 count = fLoadedCatalogs.CountItems();
for (int32 i = 0; i < count; ++i) { for (int32 i = 0; i < count; ++i) {
BCatalogAddOn* cat BCatalogData* cat
= static_cast<BCatalogAddOn*>(fLoadedCatalogs.ItemAt(i)); = static_cast<BCatalogData*>(fLoadedCatalogs.ItemAt(i));
delete cat; delete cat;
} }
fLoadedCatalogs.MakeEmpty(); fLoadedCatalogs.MakeEmpty();
@@ -817,7 +817,7 @@ MutableLocaleRoster::LoadSystemCatalog(BCatalog* catalog) const
* Any created catalog will be initialized with the given signature and * Any created catalog will be initialized with the given signature and
* language-name. * language-name.
*/ */
BCatalogAddOn* BCatalogData*
MutableLocaleRoster::CreateCatalog(const char* type, const char* signature, MutableLocaleRoster::CreateCatalog(const char* type, const char* signature,
const char* language) const char* language)
{ {
@@ -836,7 +836,7 @@ MutableLocaleRoster::CreateCatalog(const char* type, const char* signature,
|| !info->fCreateFunc) || !info->fCreateFunc)
continue; continue;
BCatalogAddOn* catalog = info->fCreateFunc(signature, language); BCatalogData* catalog = info->fCreateFunc(signature, language);
if (catalog) { if (catalog) {
info->fLoadedCatalogs.AddItem(catalog); info->fLoadedCatalogs.AddItem(catalog);
info->UnloadIfPossible(); info->UnloadIfPossible();
@@ -858,7 +858,7 @@ MutableLocaleRoster::CreateCatalog(const char* type, const char* signature,
* instead of a single catalog. * instead of a single catalog.
* NULL is returned if no matching catalog could be found. * NULL is returned if no matching catalog could be found.
*/ */
BCatalogAddOn* BCatalogData*
MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner, MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner,
const char* language, int32 fingerprint) const 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: // try to load catalogs for one of the preferred languages:
GetPreferredLanguages(&languages); GetPreferredLanguages(&languages);
BCatalogAddOn* catalog = NULL; BCatalogData* catalog = NULL;
const char* lang; const char* lang;
for (int32 l=0; languages.FindString("language", l, &lang)==B_OK; ++l) { for (int32 l=0; languages.FindString("language", l, &lang)==B_OK; ++l) {
catalog = info->fInstantiateFunc(catalogOwner, lang, fingerprint); catalog = info->fInstantiateFunc(catalogOwner, lang, fingerprint);
@@ -895,8 +895,8 @@ MutableLocaleRoster::LoadCatalog(const entry_ref& catalogOwner,
// to "english"): // to "english"):
int32 pos; int32 pos;
BString langName(lang); BString langName(lang);
BCatalogAddOn* currCatalog = catalog; BCatalogData* currCatalog = catalog;
BCatalogAddOn* nextCatalog = NULL; BCatalogData* nextCatalog = NULL;
while ((pos = langName.FindLast('_')) >= 0) { while ((pos = langName.FindLast('_')) >= 0) {
// language is based on parent, so we load that, too: // language is based on parent, so we load that, too:
// (even if the parent catalog was not found) // (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. * Add-ons that have no more current catalogs are unloaded, too.
*/ */
status_t status_t
MutableLocaleRoster::UnloadCatalog(BCatalogAddOn* catalog) MutableLocaleRoster::UnloadCatalog(BCatalogData* catalog)
{ {
if (!catalog) if (!catalog)
return B_BAD_VALUE; return B_BAD_VALUE;
@@ -938,7 +938,7 @@ MutableLocaleRoster::UnloadCatalog(BCatalogAddOn* catalog)
return B_ERROR; return B_ERROR;
status_t res = B_ERROR; status_t res = B_ERROR;
BCatalogAddOn* nextCatalog; BCatalogData* nextCatalog;
while (catalog != NULL) { while (catalog != NULL) {
nextCatalog = catalog->Next(); nextCatalog = catalog->Next();
+10 -12
View File
@@ -42,18 +42,16 @@ extern "C" _EXPORT BView *instantiate_deskbar_item(void);
* and then collectcatkeys will not see the strings in the file. * and then collectcatkeys will not see the strings in the file.
* So we mark them explicitly here. * So we mark them explicitly here.
*/ */
void notUsed() { B_TRANSLATE_MARK_VOID("Dynamic performance");
B_TRANSLATE_MARK("Dynamic performance"); B_TRANSLATE_MARK_VOID("High performance");
B_TRANSLATE_MARK("High performance"); B_TRANSLATE_MARK_VOID("Low energy");
B_TRANSLATE_MARK("Low energy"); B_TRANSLATE_MARK_VOID("Set state");
B_TRANSLATE_MARK("Set state"); B_TRANSLATE_MARK_VOID("CPUFrequency\n"
B_TRANSLATE_MARK("CPUFrequency\n" "\twritten by Clemens Zeidler\n"
"\twritten by Clemens Zeidler\n" "\tCopyright 2009, Haiku, Inc.\n");
"\tCopyright 2009, Haiku, Inc.\n"); B_TRANSLATE_MARK_VOID("Ok");
B_TRANSLATE_MARK("Ok"); B_TRANSLATE_MARK_VOID("Open Speedstep preferences" B_UTF8_ELLIPSIS);
B_TRANSLATE_MARK("Open Speedstep preferences" B_UTF8_ELLIPSIS); B_TRANSLATE_MARK_VOID("Quit");
B_TRANSLATE_MARK("Quit");
}
// messages FrequencySwitcher // messages FrequencySwitcher
const uint32 kMsgDynamicPolicyPulse = '&dpp'; const uint32 kMsgDynamicPolicyPulse = '&dpp';
@@ -14,10 +14,10 @@
#include <Roster.h> #include <Roster.h>
int int
main(int argc, char **argv) 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"); BApplication app("application/x-vnd.Haiku-DeskbarPreferences");
be_roster->Launch("application/x-vnd.Be-TSKB", new BMessage(kConfigShow)); be_roster->Launch("application/x-vnd.Be-TSKB", new BMessage(kConfigShow));
return 0; return 0;
@@ -11,20 +11,20 @@
#include <Roster.h> #include <Roster.h>
int int
main(int argc, char **argv) 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"); BApplication app("application/x-vnd.Haiku-TrackerPreferences");
// launch Tracker if it's not running // launch Tracker if it's not running
be_roster->Launch("application/x-vnd.Be-TRAK"); be_roster->Launch("application/x-vnd.Be-TRAK");
BMessage message; BMessage message;
message.what = B_EXECUTE_PROPERTY; message.what = B_EXECUTE_PROPERTY;
message.AddSpecifier("Preferences"); message.AddSpecifier("Preferences");
BMessenger("application/x-vnd.Be-TRAK").SendMessage(&message); BMessenger("application/x-vnd.Be-TRAK").SendMessage(&message);
return 0; return 0;
} }
+25 -173
View File
@@ -1,61 +1,52 @@
/* /*
** Distributed under the terms of the OpenBeOS License. ** 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 ** Authors: Axel Dörfler, axeld@pinc-software.de
** Oliver Tappe, zooey@hirschkaefer.de ** Oliver Tappe, zooey@hirschkaefer.de
*/ */
#include <syslog.h>
#include <Application.h>
#include <Catalog.h> #include <Catalog.h>
#include <Locale.h> #include <CatalogData.h>
#include <LocaleRoster.h>
#include <Node.h>
#include <Roster.h>
BCatalog* be_catalog = NULL; // Provides an implementation of BCatalog for the build host, in effect only
// catalog used by translation macros // supporting setting and getting of catalog entries.
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.
//#pragma mark - BCatalog
BCatalog::BCatalog() BCatalog::BCatalog()
: :
fCatalog(NULL) fCatalogData(NULL)
{ {
} }
BCatalog::BCatalog(const entry_ref& catalogOwner, const char *language, BCatalog::BCatalog(const entry_ref& catalogOwner, const char *language,
uint32 fingerprint) uint32 fingerprint)
:
fCatalogData(NULL)
{ {
// Unsupported - the build tools can't (and don't need to) load anything
// this way.
} }
BCatalog::~BCatalog() BCatalog::~BCatalog()
{ {
if (be_catalog == this)
be_app_catalog = be_catalog = NULL;
//be_locale_roster->UnloadCatalog(fCatalog);
} }
const char * const char *
BCatalog::GetString(const char *string, const char *context, const char *comment) BCatalog::GetString(const char *string, const char *context, const char *comment)
{ {
if (fCatalogData == 0)
return string;
const char *translated; 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); translated = cat->GetString(string, context, comment);
if (translated) if (translated)
return translated; return translated;
} }
return string; return string;
} }
@@ -63,12 +54,16 @@ BCatalog::GetString(const char *string, const char *context, const char *comment
const char * const char *
BCatalog::GetString(uint32 id) BCatalog::GetString(uint32 id)
{ {
if (fCatalogData == 0)
return "";
const char *translated; 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); translated = cat->GetString(id);
if (translated) if (translated)
return translated; return translated;
} }
return ""; return "";
} }
@@ -76,15 +71,17 @@ BCatalog::GetString(uint32 id)
status_t status_t
BCatalog::GetData(const char *name, BMessage *msg) BCatalog::GetData(const char *name, BMessage *msg)
{ {
if (!fCatalog) if (fCatalogData == 0)
return B_NO_INIT; return B_NO_INIT;
status_t res; 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); res = cat->GetData(name, msg);
if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP)
return res; return res;
// return B_OK if found, or specific error-code // return B_OK if found, or specific error-code
} }
return B_NAME_NOT_FOUND; return B_NAME_NOT_FOUND;
} }
@@ -92,161 +89,16 @@ BCatalog::GetData(const char *name, BMessage *msg)
status_t status_t
BCatalog::GetData(uint32 id, BMessage *msg) BCatalog::GetData(uint32 id, BMessage *msg)
{ {
if (!fCatalog) if (fCatalogData == 0)
return B_NO_INIT; return B_NO_INIT;
status_t res; 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); res = cat->GetData(id, msg);
if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP) if (res != B_NAME_NOT_FOUND && res != EOPNOTSUPP)
return res; return res;
// return B_OK if found, or specific error-code // return B_OK if found, or specific error-code
} }
return B_NAME_NOT_FOUND; 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;
}
+158
View File
@@ -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 <CatalogData.h>
// 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;
}
+2 -2
View File
@@ -401,7 +401,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
} }
BCatalogAddOn * BCatalogData *
DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language, DefaultCatalog::Instantiate(const entry_ref &catalogOwner, const char *language,
uint32 fingerprint) 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::Create(const char *signature, const char *language)
{ {
DefaultCatalog *catalog DefaultCatalog *catalog
+2
View File
@@ -35,6 +35,7 @@ BuildPlatformMain <build>collectcatkeys :
PlainTextCatalog.cpp PlainTextCatalog.cpp
HashMapCatalog.cpp HashMapCatalog.cpp
Catalog.cpp Catalog.cpp
CatalogData.cpp
RegExp.cpp RegExp.cpp
: $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ; : $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ;
@@ -44,4 +45,5 @@ BuildPlatformMain <build>linkcatkeys :
HashMapCatalog.cpp HashMapCatalog.cpp
DefaultCatalog.cpp DefaultCatalog.cpp
Catalog.cpp Catalog.cpp
CatalogData.cpp
: $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ; : $(HOST_LIBBE) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++) ;
+4 -5
View File
@@ -329,7 +329,7 @@ PlainTextCatalog::UpdateAttributes(const char* path)
} }
BCatalogAddOn * BCatalogData *
PlainTextCatalog::Instantiate(const char *signature, const char *language, PlainTextCatalog::Instantiate(const char *signature, const char *language,
uint32 fingerprint) uint32 fingerprint)
{ {
@@ -346,7 +346,7 @@ PlainTextCatalog::Instantiate(const char *signature, const char *language,
} // namespace BPrivate } // namespace BPrivate
extern "C" BCatalogAddOn * extern "C" BCatalogData *
instantiate_catalog(const char *signature, const char *language, instantiate_catalog(const char *signature, const char *language,
uint32 fingerprint) uint32 fingerprint)
{ {
@@ -360,9 +360,8 @@ instantiate_catalog(const char *signature, const char *language,
} }
extern "C" extern "C" BCatalogData *
BCatalogAddOn *create_catalog(const char *signature, create_catalog(const char *signature, const char *language)
const char *language)
{ {
PlainTextCatalog *catalog PlainTextCatalog *catalog
= new(std::nothrow) PlainTextCatalog("emptycat", signature, language); = new(std::nothrow) PlainTextCatalog("emptycat", signature, language);