summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-08-29 17:06:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2013-08-30 16:20:56 +0100
commitd07e7d692ddd2a9ab956a59bcc0f676c7d76bc10 (patch)
tree061cd16a65c19d423a96b2d52b097150b4373575 /vcl
parent1156d1b29af15c0d7f1d185f8ce1dc8668940286 (diff)
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
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/salinst.hxx3
-rw-r--r--vcl/inc/unx/gtk/gtkinst.hxx4
-rw-r--r--vcl/source/app/svmain.cxx2
-rw-r--r--vcl/unx/gtk/app/gtkinst.cxx59
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkPicker.cxx18
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkPicker.hxx2
6 files changed, 56 insertions, 32 deletions
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index ba9a9b5b2c14..6fcb1e245732 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -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;
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index cf901ccd3848..4787b211569e 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -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;
};
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index f9d571f85862..fdfe5809b99f 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -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 );
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
index caca8190a764..115550bdaed7 100644
--- a/vcl/unx/gtk/app/gtkinst.cxx
+++ b/vcl/unx/gtk/app/gtkinst.cxx
@@ -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();
}
diff --git a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
index ed976d7f8501..8cddab043376 100644
--- a/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkPicker.cxx
@@ -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()
diff --git a/vcl/unx/gtk/fpicker/SalGtkPicker.hxx b/vcl/unx/gtk/fpicker/SalGtkPicker.hxx
index fc8d2a2f2e83..db3fe634f322 100644
--- a/vcl/unx/gtk/fpicker/SalGtkPicker.hxx
+++ b/vcl/unx/gtk/fpicker/SalGtkPicker.hxx
@@ -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