diff options
author | Philipp Lohmann <pl@openoffice.org> | 2009-12-08 18:21:07 +0000 |
---|---|---|
committer | Philipp Lohmann <pl@openoffice.org> | 2009-12-08 18:21:07 +0000 |
commit | d0b307e10caaa858d1ef91bd98240da9bba0a78c (patch) | |
tree | 4ce307b029cd8285b7fb245ac10121c30fe8597e | |
parent | f8ada8f2a93659e27928f3b5244c813de2c3847b (diff) |
#i107529# change fallback mechanism
-rw-r--r-- | vcl/unx/source/plugadapt/salplug.cxx | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/vcl/unx/source/plugadapt/salplug.cxx b/vcl/unx/source/plugadapt/salplug.cxx index 14de25b13e4d..f1c63b8abee7 100644 --- a/vcl/unx/source/plugadapt/salplug.cxx +++ b/vcl/unx/source/plugadapt/salplug.cxx @@ -149,34 +149,53 @@ static const rtl::OUString& get_desktop_environment() return aRet; } -static const char* autodetect_plugin() +static SalInstance* autodetect_plugin() { + static const char* pKDEFallbackList[] = + { + "kde4", "kde", "gtk", "gen", 0 + }; + + static const char* pStandardFallbackList[] = + { + "gtk", "gen", 0 + }; + + static const char* pHeadlessFallbackList[] = + { + "svp", 0 + }; + const rtl::OUString& desktop( get_desktop_environment() ); - const char * pRet = "gen"; + const char ** pList = pStandardFallbackList; + int nListEntry = 0; // no server at all: dummy plugin if ( desktop.equalsAscii( desktop_strings[DESKTOP_NONE] ) ) - pRet = "svp"; + pList = pHeadlessFallbackList; else if ( desktop.equalsAscii( desktop_strings[DESKTOP_GNOME] ) ) - pRet = "gtk"; + pList = pStandardFallbackList; else if( desktop.equalsAscii( desktop_strings[DESKTOP_KDE] ) ) - pRet = "kde"; - else if( desktop.equalsAscii( desktop_strings[DESKTOP_KDE4] ) ) - pRet = "kde4"; - else { - // #i95296# use the much nicer looking gtk plugin - // on desktops that set gtk variables (e.g. XFCE) - static const char* pEnv = getenv( "GTK2_RC_FILES" ); - if( pEnv && *pEnv ) // check for existance and non emptiness - pRet = "gtk"; + pList = pKDEFallbackList; + nListEntry = 1; } + else if( desktop.equalsAscii( desktop_strings[DESKTOP_KDE4] ) ) + pList = pKDEFallbackList; -#if OSL_DEBUG_LEVEL > 1 - std::fprintf( stderr, "plugin autodetection: %s\n", pRet ); -#endif + SalInstance* pInst = NULL; + while( pList[nListEntry] && pInst == NULL ) + { + rtl::OUString aTry( rtl::OUString::createFromAscii( pList[nListEntry] ) ); + pInst = tryInstance( aTry ); + #if OSL_DEBUG_LEVEL > 1 + if( pInst ) + std::fprintf( stderr, "plugin autodetection: %s\n", pList[nListEntry] ); + #endif + nListEntry++; + } - return pRet; + return pInst; } static SalInstance* check_headless_plugin() @@ -202,10 +221,7 @@ SalInstance *CreateSalInstance() pInst = check_headless_plugin(); if( ! pInst && !(pUsePlugin && *pUsePlugin) ) - pUsePlugin = autodetect_plugin(); - - if( ! pInst && pUsePlugin && *pUsePlugin ) - pInst = tryInstance( OUString::createFromAscii( pUsePlugin ) ); + pInst = autodetect_plugin(); // fallback to gen if( ! pInst ) |