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