wait until we know the UI language before initializing gtk
so that we can set LANGUAGE to get RTL mirroring for RTL UI languages even under a LTR system locale Change-Id: I31fce6f1620d7fb35a489c771285b15ba05773df
This commit is contained in:
@@ -65,6 +65,9 @@ public:
|
||||
SalInstance() {}
|
||||
virtual ~SalInstance();
|
||||
|
||||
//called directly after Application::Init
|
||||
virtual void AfterAppInit() {}
|
||||
|
||||
// Frame
|
||||
// DisplayName for Unix ???
|
||||
virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle ) = 0;
|
||||
|
@@ -66,7 +66,8 @@ class GtkInstance : public X11SalInstance
|
||||
public:
|
||||
GtkInstance( SalYieldMutex* pMutex );
|
||||
virtual ~GtkInstance();
|
||||
void Init();
|
||||
void EnsureInit();
|
||||
virtual void AfterAppInit();
|
||||
|
||||
virtual SalFrame* CreateFrame( SalFrame* pParent, sal_uLong nStyle );
|
||||
virtual SalFrame* CreateChildFrame( SystemParentData* pParent, sal_uLong nStyle );
|
||||
@@ -110,6 +111,7 @@ public:
|
||||
private:
|
||||
std::vector<GtkSalTimer *> m_aTimers;
|
||||
bool IsTimerExpired();
|
||||
bool bNeedsInit;
|
||||
|
||||
mutable boost::shared_ptr<vcl::unx::GtkPrintWrapper> m_pPrintWrapper;
|
||||
};
|
||||
|
@@ -282,6 +282,8 @@ bool InitVCL()
|
||||
// soffice/sfx implementation creates the global service manager
|
||||
pSVData->mpApp->Init();
|
||||
|
||||
pSVData->mpDefInst->AfterAppInit();
|
||||
|
||||
// Fetch AppFileName and make it absolute before the workdir changes...
|
||||
OUString aExeFileName;
|
||||
osl_getExecutableFile( &aExeFileName.pData );
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <stack>
|
||||
#include <string.h>
|
||||
#include <osl/module.h>
|
||||
#include <osl/process.h>
|
||||
#include <unx/gtk/gtkdata.hxx>
|
||||
#include <unx/gtk/gtkinst.hxx>
|
||||
#include <unx/salobj.h>
|
||||
@@ -122,14 +123,8 @@ extern "C"
|
||||
fprintf( stderr, "creating GtkSalInstance 0x%p\n", pInstance );
|
||||
#endif
|
||||
|
||||
// initialize SalData
|
||||
GtkData *pSalData = new GtkData( pInstance );
|
||||
pSalData->Init();
|
||||
pSalData->initNWF();
|
||||
|
||||
pInstance->Init();
|
||||
|
||||
InitAtkBridge();
|
||||
//Create SalData, this does not leak
|
||||
/*GtkData *pSalData =*/ new GtkData( pInstance );
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
@@ -172,13 +167,37 @@ GtkInstance::GtkInstance( SalYieldMutex* pMutex )
|
||||
#else
|
||||
: X11SalInstance( pMutex )
|
||||
#endif
|
||||
, bNeedsInit(true)
|
||||
{
|
||||
}
|
||||
|
||||
// This has to happen after gtk_init has been called by saldata.cxx's
|
||||
// Init or our handlers just get clobbered.
|
||||
void GtkInstance::Init()
|
||||
//We want to defer initializing gtk until we are after uno has been
|
||||
//bootstrapped so we can ask the config what the UI language is so that we can
|
||||
//force that in as $LANGUAGE to get gtk to render widgets RTL if we have a RTL
|
||||
//UI in a LTR locale
|
||||
void GtkInstance::AfterAppInit()
|
||||
{
|
||||
OUString aLocaleString(Application::GetSettings().GetUILanguageTag().getGlibcLocaleString(".UTF-8"));
|
||||
if (!aLocaleString.isEmpty())
|
||||
{
|
||||
OUString envVar("LANGUAGE");
|
||||
osl_setEnvironment(envVar.pData, aLocaleString.pData);
|
||||
}
|
||||
EnsureInit();
|
||||
}
|
||||
|
||||
void GtkInstance::EnsureInit()
|
||||
{
|
||||
if (!bNeedsInit)
|
||||
return;
|
||||
// initialize SalData
|
||||
GtkData *pSalData = GetGtkSalData();
|
||||
pSalData->Init();
|
||||
pSalData->initNWF();
|
||||
|
||||
InitAtkBridge();
|
||||
|
||||
bNeedsInit = false;
|
||||
}
|
||||
|
||||
GtkInstance::~GtkInstance()
|
||||
@@ -190,16 +209,19 @@ GtkInstance::~GtkInstance()
|
||||
|
||||
SalFrame* GtkInstance::CreateFrame( SalFrame* pParent, sal_uLong nStyle )
|
||||
{
|
||||
EnsureInit();
|
||||
return new GtkSalFrame( pParent, nStyle );
|
||||
}
|
||||
|
||||
SalFrame* GtkInstance::CreateChildFrame( SystemParentData* pParentData, sal_uLong )
|
||||
{
|
||||
EnsureInit();
|
||||
return new GtkSalFrame( pParentData );
|
||||
}
|
||||
|
||||
SalObject* GtkInstance::CreateObject( SalFrame* pParent, SystemWindowData* pWindowData, sal_Bool bShow )
|
||||
{
|
||||
EnsureInit();
|
||||
#if !GTK_CHECK_VERSION(3,0,0)
|
||||
// there is no method to set a visual for a GtkWidget
|
||||
// so we need the X11SalObject in that case
|
||||
@@ -221,6 +243,7 @@ extern "C"
|
||||
|
||||
void GtkInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUString& rMimeType, const OUString& rDocumentService)
|
||||
{
|
||||
EnsureInit();
|
||||
OString sGtkURL;
|
||||
rtl_TextEncoding aSystemEnc = osl_getThreadTextEncoding();
|
||||
if ((aSystemEnc == RTL_TEXTENCODING_UTF8) || !rFileUrl.startsWith( "file://" ))
|
||||
@@ -258,6 +281,7 @@ void GtkInstance::AddToRecentDocumentList(const OUString& rFileUrl, const OUStri
|
||||
SalInfoPrinter* GtkInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
|
||||
ImplJobSetup* pSetupData )
|
||||
{
|
||||
EnsureInit();
|
||||
#if defined ENABLE_GTK_PRINT || GTK_CHECK_VERSION(3,0,0)
|
||||
mbPrinterInit = true;
|
||||
// create and initialize SalInfoPrinter
|
||||
@@ -271,6 +295,7 @@ SalInfoPrinter* GtkInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
|
||||
|
||||
SalPrinter* GtkInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
|
||||
{
|
||||
EnsureInit();
|
||||
#if defined ENABLE_GTK_PRINT || GTK_CHECK_VERSION(3,0,0)
|
||||
mbPrinterInit = true;
|
||||
return new GtkSalPrinter( pInfoPrinter );
|
||||
@@ -333,6 +358,7 @@ SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
|
||||
sal_uInt16 nBitCount,
|
||||
const SystemGraphicsData *pGd )
|
||||
{
|
||||
EnsureInit();
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
(void)pG; (void) pGd;
|
||||
SvpSalVirtualDevice* pNew = new SvpSalVirtualDevice( nBitCount );
|
||||
@@ -345,6 +371,7 @@ SalVirtualDevice* GtkInstance::CreateVirtualDevice( SalGraphics *pG,
|
||||
|
||||
SalBitmap* GtkInstance::CreateSalBitmap()
|
||||
{
|
||||
EnsureInit();
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
return new SvpSalBitmap();
|
||||
#else
|
||||
@@ -356,6 +383,7 @@ SalBitmap* GtkInstance::CreateSalBitmap()
|
||||
|
||||
SalMenu* GtkInstance::CreateMenu( sal_Bool bMenuBar, Menu* pVCLMenu )
|
||||
{
|
||||
EnsureInit();
|
||||
GtkSalMenu* pSalMenu = new GtkSalMenu( bMenuBar );
|
||||
pSalMenu->SetMenu( pVCLMenu );
|
||||
return pSalMenu;
|
||||
@@ -363,16 +391,19 @@ SalMenu* GtkInstance::CreateMenu( sal_Bool bMenuBar, Menu* pVCLMenu )
|
||||
|
||||
void GtkInstance::DestroyMenu( SalMenu* pMenu )
|
||||
{
|
||||
EnsureInit();
|
||||
delete pMenu;
|
||||
}
|
||||
|
||||
SalMenuItem* GtkInstance::CreateMenuItem( const SalItemParams* pItemData )
|
||||
{
|
||||
EnsureInit();
|
||||
return new GtkSalMenuItem( pItemData );
|
||||
}
|
||||
|
||||
void GtkInstance::DestroyMenuItem( SalMenuItem* pItem )
|
||||
{
|
||||
EnsureInit();
|
||||
delete pItem;
|
||||
}
|
||||
|
||||
@@ -387,6 +418,7 @@ void GtkInstance::DestroyMenuItem( SalMenuItem* ) {}
|
||||
|
||||
SalTimer* GtkInstance::CreateSalTimer()
|
||||
{
|
||||
EnsureInit();
|
||||
GtkSalTimer *pTimer = new GtkSalTimer();
|
||||
m_aTimers.push_back( pTimer );
|
||||
return pTimer;
|
||||
@@ -394,6 +426,7 @@ SalTimer* GtkInstance::CreateSalTimer()
|
||||
|
||||
void GtkInstance::RemoveTimer (SalTimer *pTimer)
|
||||
{
|
||||
EnsureInit();
|
||||
std::vector<GtkSalTimer *>::iterator it;
|
||||
it = std::find( m_aTimers.begin(), m_aTimers.end(), pTimer );
|
||||
if( it != m_aTimers.end() )
|
||||
@@ -402,11 +435,13 @@ void GtkInstance::RemoveTimer (SalTimer *pTimer)
|
||||
|
||||
void GtkInstance::Yield( bool bWait, bool bHandleAllCurrentEvents )
|
||||
{
|
||||
EnsureInit();
|
||||
GetGtkSalData()->Yield( bWait, bHandleAllCurrentEvents );
|
||||
}
|
||||
|
||||
bool GtkInstance::IsTimerExpired()
|
||||
{
|
||||
EnsureInit();
|
||||
for( std::vector<GtkSalTimer *>::iterator it = m_aTimers.begin();
|
||||
it != m_aTimers.end(); ++it )
|
||||
if( (*it)->Expired() )
|
||||
@@ -417,6 +452,7 @@ bool GtkInstance::IsTimerExpired()
|
||||
|
||||
bool GtkInstance::AnyInput( sal_uInt16 nType )
|
||||
{
|
||||
EnsureInit();
|
||||
if( (nType & VCL_INPUT_TIMER) && IsTimerExpired() )
|
||||
return true;
|
||||
#if !GTK_CHECK_VERSION(3,0,0)
|
||||
@@ -455,6 +491,7 @@ bool GtkInstance::AnyInput( sal_uInt16 nType )
|
||||
|
||||
GenPspGraphics *GtkInstance::CreatePrintGraphics()
|
||||
{
|
||||
EnsureInit();
|
||||
return new GenPspGraphics();
|
||||
}
|
||||
|
||||
|
@@ -172,27 +172,9 @@ gint RunDialog::run()
|
||||
return nStatus;
|
||||
}
|
||||
|
||||
// FIXME: this is pretty nasty ... we try to tell gtk+'s
|
||||
// gettext the locale it should use via the environment
|
||||
void SalGtkPicker::setGtkLanguage()
|
||||
{
|
||||
static bool bSet = false;
|
||||
if (bSet)
|
||||
return;
|
||||
|
||||
OUString aLocaleString( Application::GetSettings().GetUILanguageTag().getGlibcLocaleString( ".UTF-8"));
|
||||
if (!aLocaleString.isEmpty())
|
||||
{
|
||||
OUString envVar( "LANGUAGE" );
|
||||
osl_setEnvironment( envVar.pData, aLocaleString.pData );
|
||||
}
|
||||
bSet = true;
|
||||
}
|
||||
|
||||
SalGtkPicker::SalGtkPicker( const uno::Reference<uno::XComponentContext>& xContext )
|
||||
: m_pDialog( 0 ), m_xContext( xContext )
|
||||
{
|
||||
setGtkLanguage();
|
||||
}
|
||||
|
||||
SalGtkPicker::~SalGtkPicker()
|
||||
|
@@ -64,8 +64,6 @@ class SalGtkPicker
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
|
||||
OUString getResString( sal_Int32 aId );
|
||||
private:
|
||||
void setGtkLanguage();
|
||||
};
|
||||
|
||||
class GdkThreadLock
|
||||
|
Reference in New Issue
Block a user