diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-07-24 14:04:34 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-07-24 14:04:34 -0500 |
commit | 0d3ebd90203be2314e9c9fece66216f36dab3abe (patch) | |
tree | 4291bbfa32286d328059df54f4e3cc5b8cea98d0 | |
parent | 763b290f0123855a1d9e8fde0583297e0ce5941b (diff) | |
download | tdebase-0d3ebd90203be2314e9c9fece66216f36dab3abe.tar.gz tdebase-0d3ebd90203be2314e9c9fece66216f36dab3abe.zip |
Do not display screensavers in the configuration dialog that are not installed on the system
-rw-r--r-- | ConfigureChecks.cmake | 4 | ||||
-rw-r--r-- | FindXscreensaver.cmake | 82 | ||||
-rw-r--r-- | config.h.cmake | 3 | ||||
-rw-r--r-- | kcontrol/screensaver/scrnsave.cpp | 24 |
4 files changed, 111 insertions, 2 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index 9971e5538..e7e5709ad 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -161,6 +161,10 @@ if( WITH_XSCREENSAVER ) else( ) tde_message_fatal( "xscreensaver is requested, but was not found on your system" ) endif( ) + include( FindXscreensaver.cmake ) # not really good practise + if( NOT XSCREENSAVER_FOUND ) + message( FATAL_ERROR "\nxscreensaver is requested, but was not found on your system" ) + endif( ) endif( ) diff --git a/FindXscreensaver.cmake b/FindXscreensaver.cmake new file mode 100644 index 000000000..57236097c --- /dev/null +++ b/FindXscreensaver.cmake @@ -0,0 +1,82 @@ +#Macro to find xscreensaver directory + +# Copyright (c) 2006, Laurent Montel, <montel@kde.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# got from kde4 + +if (NOT XSCREENSAVER_FOUND) + set(xscreensaver_alldirs) + set(xscreensaver_checkdirs ${TDE_INCLUDE_DIR} + /usr/ + /usr/local/ + /opt/local/ + /usr/X11R6/ + /opt/kde/ + /opt/kde3/ + /usr/kde/ + /usr/local/kde/ + /usr/local/xscreensaver/ + /usr/openwin/lib/xscreensaver/ + /etc/ ) + foreach(suffix lib${LIB_SUFFIX}/xscreensaver lib${LIB_SUFFIX}/misc/xscreensaver lib/xscreensaver lib64/xscreensaver libexec/xscreensaver +bin/xscreensaver-hacks hacks) + foreach(xscreensaver_path ${xscreensaver_checkdirs} ) + set(xscreensaver_alldirs ${xscreensaver_alldirs} ${xscreensaver_path}/${suffix}) + endforeach(xscreensaver_path ${xscreensaver_checkdirs} ) + endforeach(suffix lib${LIB_SUFFIX}/xscreensaver lib/xscreensaver lib64/xscreensaver libexec/xscreensaver bin/xscreensaver-hacks hacks) + FIND_PATH(XSCREENSAVER_DIR deco ${xscreensaver_alldirs}) + + set(XSCREENSAVER_CONFIG_DIR) + FIND_PATH(XSCREENSAVER_CONFIG_DECO config/deco.xml + ${TDE_INCLUDE_DIR} + /usr/ + /usr/local/ + /opt/local/ + /usr/X11R6/ + /opt/kde/ + /opt/kde3/ + /usr/kde/ + /usr/share/xscreensaver/ + /usr/local/kde/ + /usr/local/xscreensaver/ + /usr/openwin/lib/xscreensaver/ + /etc/ + ) + #MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR :<${XSCREENSAVER_CONFIG_DIR}>") + + if(XSCREENSAVER_CONFIG_DECO) + set(XSCREENSAVER_CONFIG_DIR "${XSCREENSAVER_CONFIG_DECO}/config/") + #MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR <${XSCREENSAVER_CONFIG_DIR}>") + endif(XSCREENSAVER_CONFIG_DECO) + + + # Try and locate XScreenSaver config when path doesn't include config + if(NOT XSCREENSAVER_CONFIG_DIR) + FIND_PATH(XSCREENSAVER_CONFIG_DIR deco.xml + /etc/xscreensaver + ) + endif(NOT XSCREENSAVER_CONFIG_DIR) +endif(NOT XSCREENSAVER_FOUND) + +#MESSAGE(STATUS "XSCREENSAVER_CONFIG_DIR :<${XSCREENSAVER_CONFIG_DIR}>") +#MESSAGE(STATUS "XSCREENSAVER_DIR :<${XSCREENSAVER_DIR}>") + +# Need to fix hack +if(XSCREENSAVER_DIR AND XSCREENSAVER_CONFIG_DIR) + set(XSCREENSAVER_FOUND TRUE) +endif(XSCREENSAVER_DIR AND XSCREENSAVER_CONFIG_DIR) + +if (XSCREENSAVER_FOUND) + if (NOT Xscreensaver_FIND_QUIETLY) + message(STATUS "Found SCREENSAVER_CONFIG_DIR <${XSCREENSAVER_CONFIG_DIR}>") + endif (NOT Xscreensaver_FIND_QUIETLY) +else (XSCREENSAVER_FOUND) + if (Xscreensaver_FIND_REQUIRED) + message(FATAL_ERROR "XScreenSaver not found") + endif (Xscreensaver_FIND_REQUIRED) +endif (XSCREENSAVER_FOUND) + + +MARK_AS_ADVANCED(XSCREENSAVER_DIR XSCREENSAVER_CONFIG_DIR) diff --git a/config.h.cmake b/config.h.cmake index 4fbb33915..7cb3aa1fc 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -27,6 +27,9 @@ // xscreensaver #cmakedefine HAVE_XSCREENSAVER 1 +/* Defines where xscreensaver stores its graphic hacks */ +#define XSCREENSAVER_HACKS_DIR "@XSCREENSAVER_DIR@" + // libart #cmakedefine HAVE_LIBART 1 diff --git a/kcontrol/screensaver/scrnsave.cpp b/kcontrol/screensaver/scrnsave.cpp index 776c8e43a..8980c8e3c 100644 --- a/kcontrol/screensaver/scrnsave.cpp +++ b/kcontrol/screensaver/scrnsave.cpp @@ -27,6 +27,7 @@ #include <tqpushbutton.h> #include <tqslider.h> #include <tqtimer.h> +#include <tqfileinfo.h> #include <tqwhatsthis.h> #include <dcopclient.h> @@ -519,9 +520,28 @@ void KScreenSaver::findSavers() TQString file = mSaverFileList[mNumLoaded]; SaverConfig *saver = new SaverConfig; if (saver->read(file)) { - mSaverList.append(saver); - } else + TQString saverexec = TQString("%1/%2").arg(XSCREENSAVER_HACKS_DIR).arg(saver->exec()); + // find the xscreensaver executable + //work around a TDEStandardDirs::findExe() "feature" where it looks in $TDEDIR/bin first no matter what and sometimes finds the wrong executable + TQFileInfo checkExe; + checkExe.setFile(saverexec); + if (checkExe.exists() && checkExe.isExecutable() && checkExe.isFile()) { + mSaverList.append(saver); + } + else { + // Executable not present in XScreenSaver directory! + // Try standard paths + if (TDEStandardDirs::findExe(saver->exec()) != TQString::null) { + mSaverList.append(saver); + } + else { + delete saver; + } + } + } + else { delete saver; + } } if ( (unsigned)mNumLoaded == mSaverFileList.count() ) { |