olta+pulkomandy:
* Introduce an add-on system to allow libbe to call things living inside liblocale (as liblocale depends on libbe, it can't be linked the usual way) * This allows localizing the BColorControl class that had some text inside it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36190 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
1 english system 1811097932
|
1 french system 2677153267
|
||||||
%3.2f GiB StringForSize %3.2f Gio
|
%3.2f GiB StringForSize %3.2f Gio
|
||||||
%3.2f KiB StringForSize %3.2f Kio
|
%3.2f KiB StringForSize %3.2f Kio
|
||||||
%d bytes StringForSize %d octets
|
%d bytes StringForSize %d octets
|
||||||
%.2f TiB StringForSize %.2f Tio
|
%.2f TiB StringForSize %.2f Tio
|
||||||
%3.2f MiB StringForSize %3.2f Mio
|
%3.2f MiB StringForSize %3.2f Mio
|
||||||
|
Red: ColorControl Rouge :
|
||||||
|
Green: ColorControl Vert :
|
||||||
|
Blue: ColorControl Bleu :
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010, Oliver Tappe, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _LOCALE_BACKEND_H
|
||||||
|
#define _LOCALE_BACKEND_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
|
class LocaleBackend {
|
||||||
|
public:
|
||||||
|
LocaleBackend();
|
||||||
|
virtual ~LocaleBackend();
|
||||||
|
|
||||||
|
virtual const char* GetString(const char* string,
|
||||||
|
const char* context = NULL,
|
||||||
|
const char* comment = NULL) = 0;
|
||||||
|
|
||||||
|
static status_t LoadBackend();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
extern LocaleBackend* gLocaleBackend;
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _LOCALE_BACKEND_H
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010, Oliver Tappe, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef _LIBBE_LOCALE_BACKEND_H
|
||||||
|
#define _LIBBE_LOCALE_BACKEND_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <LocaleBackend.h>
|
||||||
|
|
||||||
|
class BCatalogAddOn;
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
|
class LibbeLocaleBackend : public LocaleBackend {
|
||||||
|
public:
|
||||||
|
LibbeLocaleBackend();
|
||||||
|
virtual ~LibbeLocaleBackend();
|
||||||
|
|
||||||
|
virtual const char* GetString(const char* string,
|
||||||
|
const char* context = NULL,
|
||||||
|
const char* comment = NULL);
|
||||||
|
private:
|
||||||
|
BCatalogAddOn* systemCatalog;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _LIBBE_LOCALE_BACKEND_H
|
||||||
@@ -19,6 +19,7 @@ if $(RUN_WITHOUT_APP_SERVER) != 0 {
|
|||||||
|
|
||||||
UsePrivateHeaders [ FDirName kernel ] ; # For KMessage.h
|
UsePrivateHeaders [ FDirName kernel ] ; # For KMessage.h
|
||||||
#UsePrivateHeaders syslog_daemon ; # For syslog.cpp
|
#UsePrivateHeaders syslog_daemon ; # For syslog.cpp
|
||||||
|
UsePrivateHeaders libbe ;
|
||||||
|
|
||||||
# Build our libbe.so
|
# Build our libbe.so
|
||||||
|
|
||||||
@@ -27,6 +28,7 @@ AddResources libbe.so : libbe_version.rdef ;
|
|||||||
SetVersionScript libbe.so : libbe_versions ;
|
SetVersionScript libbe.so : libbe_versions ;
|
||||||
|
|
||||||
SharedLibrary libbe.so :
|
SharedLibrary libbe.so :
|
||||||
|
LocaleBackend.cpp
|
||||||
:
|
:
|
||||||
<libbe>app_kit.o
|
<libbe>app_kit.o
|
||||||
<libbe>interface_kit.o
|
<libbe>interface_kit.o
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010, Oliver Tappe, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "LocaleBackend.h"
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <image.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
|
LocaleBackend* gLocaleBackend = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
static pthread_once_t sBackendInitOnce = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
LoadBackend()
|
||||||
|
{
|
||||||
|
image_id libLocaleAddonID = load_add_on("/system/lib/liblocale.so");
|
||||||
|
printf("backend-id: %ld\n", libLocaleAddonID);
|
||||||
|
if (libLocaleAddonID < 0)
|
||||||
|
return;
|
||||||
|
LocaleBackend* (*createInstanceFunc)();
|
||||||
|
if (get_image_symbol(libLocaleAddonID, "CreateLocaleBackendInstance",
|
||||||
|
B_SYMBOL_TYPE_TEXT, (void**)&createInstanceFunc) != B_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("invoking creator func\n");
|
||||||
|
gLocaleBackend = createInstanceFunc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LocaleBackend::LocaleBackend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LocaleBackend::~LocaleBackend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
LocaleBackend::LoadBackend()
|
||||||
|
{
|
||||||
|
if (gLocaleBackend == NULL)
|
||||||
|
pthread_once(&sBackendInitOnce, &BPrivate::LoadBackend);
|
||||||
|
|
||||||
|
return gLocaleBackend != NULL ? B_OK : B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
@@ -23,9 +23,17 @@
|
|||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <LocaleBackend.h>
|
||||||
|
using BPrivate::gLocaleBackend;
|
||||||
|
using BPrivate::LocaleBackend;
|
||||||
|
|
||||||
#include <binary_compatibility/Interface.h>
|
#include <binary_compatibility/Interface.h>
|
||||||
|
|
||||||
|
|
||||||
|
#undef TR_CONTEXT
|
||||||
|
#define TR_CONTEXT "ColorControl"
|
||||||
|
|
||||||
static const uint32 kMsgColorEntered = 'ccol';
|
static const uint32 kMsgColorEntered = 'ccol';
|
||||||
static const uint32 kMinCellSize = 6;
|
static const uint32 kMinCellSize = 6;
|
||||||
static const float kSelectorPenSize = 2.0f;
|
static const float kSelectorPenSize = 2.0f;
|
||||||
@@ -68,6 +76,14 @@ void
|
|||||||
BColorControl::_InitData(color_control_layout layout, float size,
|
BColorControl::_InitData(color_control_layout layout, float size,
|
||||||
bool useOffscreen, BMessage* archive)
|
bool useOffscreen, BMessage* archive)
|
||||||
{
|
{
|
||||||
|
// we need to translate some strings, and in order to do so, we need
|
||||||
|
// to use the LocaleBackend to reache liblocale.so
|
||||||
|
if (gLocaleBackend == NULL)
|
||||||
|
{
|
||||||
|
printf("trying to load backend\n");
|
||||||
|
LocaleBackend::LoadBackend();
|
||||||
|
printf("backend = %p\n", gLocaleBackend);
|
||||||
|
}
|
||||||
fPaletteMode = BScreen(B_MAIN_SCREEN_ID).ColorSpace() == B_CMAP8;
|
fPaletteMode = BScreen(B_MAIN_SCREEN_ID).ColorSpace() == B_CMAP8;
|
||||||
//TODO: we don't support workspace and colorspace changing for now
|
//TODO: we don't support workspace and colorspace changing for now
|
||||||
// so we take the main_screen colorspace at startup
|
// so we take the main_screen colorspace at startup
|
||||||
@@ -79,6 +95,15 @@ BColorControl::_InitData(color_control_layout layout, float size,
|
|||||||
fPreviousSelectedPaletteColorIndex = -1;
|
fPreviousSelectedPaletteColorIndex = -1;
|
||||||
fFocusedComponent = 0;
|
fFocusedComponent = 0;
|
||||||
|
|
||||||
|
const char* red = TR_MARK("Red:");
|
||||||
|
const char* green = TR_MARK("Green:");
|
||||||
|
const char* blue = TR_MARK("Blue:");
|
||||||
|
if (gLocaleBackend) {
|
||||||
|
red = gLocaleBackend->GetString(red, "ColorControl");
|
||||||
|
green = gLocaleBackend->GetString(green, "ColorControl");
|
||||||
|
blue = gLocaleBackend->GetString(blue, "ColorControl");
|
||||||
|
}
|
||||||
|
|
||||||
if (archive) {
|
if (archive) {
|
||||||
fRedText = (BTextControl*)FindView("_red");
|
fRedText = (BTextControl*)FindView("_red");
|
||||||
fGreenText = (BTextControl*)FindView("_green");
|
fGreenText = (BTextControl*)FindView("_green");
|
||||||
@@ -95,7 +120,7 @@ BColorControl::_InitData(color_control_layout layout, float size,
|
|||||||
|
|
||||||
// red
|
// red
|
||||||
|
|
||||||
fRedText = new BTextControl(rect, "_red", "Red:", "0",
|
fRedText = new BTextControl(rect, "_red", red, "0",
|
||||||
new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_NAVIGABLE);
|
B_WILL_DRAW | B_NAVIGABLE);
|
||||||
fRedText->SetDivider(labelWidth);
|
fRedText->SetDivider(labelWidth);
|
||||||
@@ -111,7 +136,7 @@ BColorControl::_InitData(color_control_layout layout, float size,
|
|||||||
// green
|
// green
|
||||||
|
|
||||||
rect.OffsetBy(0.0f, offset);
|
rect.OffsetBy(0.0f, offset);
|
||||||
fGreenText = new BTextControl(rect, "_green", "Green:", "0",
|
fGreenText = new BTextControl(rect, "_green", green, "0",
|
||||||
new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_NAVIGABLE);
|
B_WILL_DRAW | B_NAVIGABLE);
|
||||||
fGreenText->SetDivider(labelWidth);
|
fGreenText->SetDivider(labelWidth);
|
||||||
@@ -125,7 +150,7 @@ BColorControl::_InitData(color_control_layout layout, float size,
|
|||||||
// blue
|
// blue
|
||||||
|
|
||||||
rect.OffsetBy(0.0f, offset);
|
rect.OffsetBy(0.0f, offset);
|
||||||
fBlueText = new BTextControl(rect, "_blue", "Blue:", "0",
|
fBlueText = new BTextControl(rect, "_blue", blue, "0",
|
||||||
new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
new BMessage(kMsgColorEntered), B_FOLLOW_LEFT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_NAVIGABLE);
|
B_WILL_DRAW | B_NAVIGABLE);
|
||||||
fBlueText->SetDivider(labelWidth);
|
fBlueText->SetDivider(labelWidth);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) {
|
|||||||
SetSubDirSupportedPlatforms haiku libbe_test ;
|
SetSubDirSupportedPlatforms haiku libbe_test ;
|
||||||
|
|
||||||
UseLibraryHeaders agg icon ;
|
UseLibraryHeaders agg icon ;
|
||||||
UsePrivateHeaders app input print interface shared tracker ;
|
UsePrivateHeaders app input print interface libbe shared tracker ;
|
||||||
|
|
||||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ;
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ;
|
||||||
SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
|
SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
SubDir HAIKU_TOP src kits locale ;
|
SubDir HAIKU_TOP src kits locale ;
|
||||||
|
|
||||||
UsePrivateHeaders locale shared ;
|
UsePrivateHeaders libbe locale shared ;
|
||||||
UsePublicHeaders locale storage ;
|
UsePublicHeaders locale storage ;
|
||||||
UseLibraryHeaders icu ;
|
UseLibraryHeaders icu ;
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ SharedLibrary liblocale.so
|
|||||||
IntegerFormatParameters.cpp
|
IntegerFormatParameters.cpp
|
||||||
langinfo.cpp
|
langinfo.cpp
|
||||||
Language.cpp
|
Language.cpp
|
||||||
|
LibbeLocaleBackend.cpp
|
||||||
LibraryInit.cpp
|
LibraryInit.cpp
|
||||||
Locale.cpp
|
Locale.cpp
|
||||||
LocaleRoster.cpp
|
LocaleRoster.cpp
|
||||||
@@ -36,9 +37,13 @@ SharedLibrary liblocale.so
|
|||||||
: be $(TARGET_LIBSTDC++) libicu-common.so libicu-i18n.so
|
: be $(TARGET_LIBSTDC++) libicu-common.so libicu-i18n.so
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SEARCH on [ FGristFiles StringForSize.cpp ] += [ FDirName $(HAIKU_TOP) src kits shared ] ;
|
||||||
|
SEARCH on [ FGristFiles ColorControl.cpp ] += [ FDirName $(HAIKU_TOP) src kits interface ] ;
|
||||||
|
|
||||||
DoCatalogs liblocale.so :
|
DoCatalogs liblocale.so :
|
||||||
system
|
system
|
||||||
: ../shared/StringForSize.cpp
|
: StringForSize.cpp
|
||||||
|
ColorControl.cpp
|
||||||
:
|
:
|
||||||
: '"systemCatalog\\s*->\\s*GetString\\s*"'
|
: '"(systemCatalog\\s*->\\s*GetString\\s*|BCatalogAddOn\\s*::\\s*MarkForTranslation\\s*)"'
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "LibbeLocaleBackend.h"
|
||||||
|
|
||||||
|
#include "Catalog.h"
|
||||||
|
#include "Locale.h"
|
||||||
|
#include "LocaleRoster.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
|
||||||
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" LocaleBackend*
|
||||||
|
CreateLocaleBackendInstance()
|
||||||
|
{
|
||||||
|
return new(std::nothrow) LibbeLocaleBackend();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LibbeLocaleBackend::LibbeLocaleBackend()
|
||||||
|
{
|
||||||
|
be_locale_roster->GetSystemCatalog(&systemCatalog);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LibbeLocaleBackend::~LibbeLocaleBackend()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
LibbeLocaleBackend::GetString(const char* string, const char* context,
|
||||||
|
const char* comment)
|
||||||
|
{
|
||||||
|
return systemCatalog->GetString(string, context, comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace BPrivate
|
||||||
Reference in New Issue
Block a user