Index: AppImage-package/AppRun
===================================================================
--- AppImage-package/AppRun	(revision 22988)
+++ AppImage-package/AppRun	(working copy)
@@ -56,7 +56,10 @@
 # Make it look more native on Gtk+ based systems
 ############################################################################################
 
-export QT_QPA_PLATFORMTHEME=gtk2
+case "${XDG_CURRENT_DESKTOP}" in
+    *GNOME*|*gnome*)
+        export QT_QPA_PLATFORMTHEME=gtk2
+esac
 
 ############################################################################################
 # Run experimental bundle that bundles everything if a private ld-linux-x86-64.so.2 is there
Index: AppImage-package/bundle.sh
===================================================================
--- AppImage-package/bundle.sh	(revision 22988)
+++ AppImage-package/bundle.sh	(working copy)
@@ -2,23 +2,12 @@
 
 cat /proc/1/cgroup # Check if we run in Docker; https://github.com/AppImage/AppImageKit/issues/912
 
+# for docker images:
+# if qt is not in the standard path, load its environment variables
 . /opt/qt*/bin/qt*-env.sh || true
 
 ########################################################################
 # Build Plaform Theme for Gtk+
-########################################################################
-
-find /opt/qt*/| grep platform 
-#apt-get update
-#apt-get -y install libgtk-3-dev libnotify-dev qt5113d
-#git clone https://github.com/CrimsonAS/gtkplatform
-#cd gtkplatform
-#qmake
-#make -j$(nproc)
-#sudo make install 
-#cd -
-
-########################################################################
 # https://askubuntu.com/a/910143
 # https://askubuntu.com/a/748186
 # Deploy with linuxdeployqt using
@@ -37,13 +26,30 @@
 # Build Scribus and install to appdir/
 ########################################################################
 
-cmake . -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=/usr -DWANT_HUNSPELL=1 -DWITH_PODOFO=1 -DWANT_GRAPHICSMAGICK=1 -DWANT_DEBUG=0 -DWANT_SVNVERSION=0 -DWANT_GUI_LANG=en_US
+cmake . -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
+    -DCMAKE_C_COMPILER_LAUNCHER=ccache \
+    -DCMAKE_INSTALL_PREFIX=/usr \
+    -DWANT_RELOCATABLE=1 \
+    -DWANT_HUNSPELL=1 \
+    -DWITH_PODOFO=1 \
+    -DWANT_GRAPHICSMAGICK=1 \
+    -DWANT_DEBUG=0 \
+    -DWANT_SVNVERSION=0 \
+    -DWANT_GUI_LANG=en_US;de;fr;it \
 make -j$(nproc)
-make DESTDIR=appdir -j$(nproc) install ; find appdir/
-cp AppImage-package/AppRun appdir/ ; chmod +x appdir/AppRun
+
+make DESTDIR=appdir -j$(nproc) install
+find appdir/
+
+# TODO: make sure that the appdir directory exits
+cp AppImage-package/AppRun appdir/
+chmod +x appdir/AppRun
+
 cp ./appdir/usr/share/icons/hicolor/256x256/apps/scribus.png ./appdir/
-sed -i -e 's|^Icon=.*|Icon=scribus|g' ./appdir/usr/share/applications/scribus.desktop # Needed?
 
+# TODO: is this needed?
+sed -i -e 's|^Icon=.*|Icon=scribus|g' ./appdir/usr/share/applications/scribus.desktop
+
 ########################################################################
 # Bundle everyhting
 # to allow the AppImage to run on older systems as well
@@ -72,13 +78,17 @@
 cd -
 
 ########################################################################
-# Patch away absolute paths
-# FIXME: It would be nice if they were relative
+# Work around side effect of bundling everything
 ########################################################################
 
-sed -i -e 's|/usr/share/scribus|././/share/scribus|g' appdir/usr/bin/scribus
-sed -i -e 's|/usr/lib/scribus|././/lib/scribus|g' appdir/usr/bin/scribus
-sed -i -e 's|/usr/share/doc/scribus/|././/share/doc/scribus/|g' appdir/usr/bin/scribus
+# https://github.com/scribusproject/scribus/issues/111#issuecomment-457823282
+# applicationDirPath() is not usr/bin but lib/x86_64-linux-gnu/
+# when AppRun invokes the binary with
+# exec "${HERE}/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2" --inhibit-cache --library-path "${LIBRARY_PATH}" "${MAIN}" "$@"
+# hence we add a symlink here to mitigate this
+cd appdir/lib/
+ln -s ../usr/* .
+cd -
 
 ########################################################################
 # Also bundle Tcl/Tk, Tkinter (for Calendar script)
@@ -90,7 +100,8 @@
 cp -r /usr/share/tcltk appdir/usr/share/
 
 ########################################################################
-# Create extra qt.conf in a strange location; FIXME: why is this needed?
+# Create extra qt.conf in a strange location;
+# FIXME: why is this needed?
 ########################################################################
 
 mkdir -p appdir/lib/x86_64-linux-gnu/
@@ -112,4 +123,4 @@
 chmod a+x linuxdeployqt-continuous-x86_64.AppImage
 ARCH=x86_64 ./linuxdeployqt-continuous-x86_64.AppImage --appimage-extract-and-run appdir/usr/share/applications/scribus.desktop \
 -appimage -unsupported-bundle-everything \
--executable=appdir/usr/bin/python2.7 -executable=appdir/usr/_tkinter.so -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
\ No newline at end of file
+-executable=appdir/usr/bin/python2.7 -executable=appdir/usr/_tkinter.so -extra-plugins=platformthemes/libqgtk2.so,styles/libqgtk2style.so
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 22988)
+++ CMakeLists.txt	(working copy)
@@ -216,6 +216,20 @@
 message(STATUS "Building for target ${MACHINE}")
 
 ##############################################################################################################
+########## Relocatability                                                                           ##########
+
+if (APPLEBUNDLE OR WIN32)
+	if (WANT_RELOCATABLE)
+		message(STATUS "Ignoring relocatable option on Win32 or OSX when building bundle")
+		set(WANT_RELOCATABLE 0)
+	endif()
+endif()
+
+if (WANT_RELOCATABLE)
+	add_definitions(-DWANT_RELOCATABLE)
+endif()
+
+##############################################################################################################
 ########## Versioning Setup                                                                         ##########
 
 #On Apple, we ignore the versioning tag so all items are "scribus" not "scribus-version"
@@ -259,7 +273,7 @@
 ########## Install/Directory Setup                                                                  ##########
 
 if (APPLEBUNDLE)
-set (APPLE_APP_DIR "${CMAKE_INSTALL_PREFIX}")
+	set (APPLE_APP_DIR "${CMAKE_INSTALL_PREFIX}")
 	if ("${CMAKE_INSTALL_PREFIX}" MATCHES "[.]app/Contents/?$")
 		# all ok
 	else()
@@ -283,7 +297,10 @@
 else()
 	set(SHAREDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}/")
 endif()
-if(NOT IS_ABSOLUTE ${SHAREDIR})
+
+if(IS_ABSOLUTE ${SHAREDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: SHAREDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${SHAREDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DSHAREDIR="${CMAKE_INSTALL_PREFIX}/${SHAREDIR}")
 else()
 	add_definitions(-DSHAREDIR="${SHAREDIR}")
@@ -292,18 +309,17 @@
 #SHARE - use the default on Apple as TAG_VERSION is empty
 if(WIN32 OR OS2)
 	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/")
+elseif(TAG_VERSION OR BUILD_OSX_BUNDLE)
+	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
+elseif(NOT WANT_VERSIONING)
+	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}/")
 else()
-	if(TAG_VERSION OR BUILD_OSX_BUNDLE)
-		set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}${TAG_VERSION}/")
-	else()
-		if(NOT WANT_VERSIONING)
-			set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}/")
-		else()
-			set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}-${VERSION}/")
-		endif()
-	endif()
+	set(DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${MAIN_DIR_NAME}-${VERSION}/")
 endif()
-if(NOT IS_ABSOLUTE ${DOCDIR})
+
+if(IS_ABSOLUTE ${DOCDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: DOCDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${DOCDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DDOCDIR="${CMAKE_INSTALL_PREFIX}/${DOCDIR}")
 else()
 	add_definitions(-DDOCDIR="${DOCDIR}")
@@ -315,7 +331,10 @@
 else()
 	set(ICONDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/icons/")
 endif()
-if(NOT IS_ABSOLUTE ${ICONDIR})
+
+if(IS_ABSOLUTE ${ICONDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: ICONDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${ICONDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DICONDIR="${CMAKE_INSTALL_PREFIX}/${ICONDIR}")
 else()
 	add_definitions(-DICONDIR="${ICONDIR}")
@@ -322,8 +341,15 @@
 endif()
 
 #SAMPLES
-set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
-if(NOT IS_ABSOLUTE ${SAMPLESDIR})
+if(WIN32)
+	set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/samples/")
+else()
+	set(SAMPLESDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/samples/")
+endif()
+
+if(IS_ABSOLUTE ${SAMPLESDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: SAMPLESDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${SAMPLESDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DSAMPLESDIR="${CMAKE_INSTALL_PREFIX}/${SAMPLESDIR}")
 else()
 	add_definitions(-DSAMPLESDIR="${SAMPLESDIR}")
@@ -330,8 +356,15 @@
 endif()
 
 #SCRIPTS
-set(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
-if(NOT IS_ABSOLUTE ${SCRIPTSDIR})
+if(WIN32)
+	set(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/scripts/")
+else()
+	set(SCRIPTSDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/scripts/")
+endif()
+
+if(IS_ABSOLUTE ${SCRIPTSDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: SCRIPTSDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${SCRIPTSDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DSCRIPTSDIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTSDIR}")
 else()
 	add_definitions(-DSCRIPTSDIR="${SCRIPTSDIR}")
@@ -343,7 +376,10 @@
 else()
 	set(TEMPLATEDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/templates/")
 endif()
-if(NOT IS_ABSOLUTE ${TEMPLATEDIR})
+
+if(IS_ABSOLUTE ${TEMPLATEDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: TEMPLATEDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${TEMPLATEDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DTEMPLATEDIR="${CMAKE_INSTALL_PREFIX}/${TEMPLATEDIR}")
 else()
 	add_definitions(-DTEMPLATEDIR="${TEMPLATEDIR}")
@@ -355,11 +391,21 @@
 else()
 	set(QMLDIR "${CMAKE_INSTALL_DATAROOTDIR}/${MAIN_DIR_NAME}${TAG_VERSION}/qml/")
 endif()
-add_definitions(-DQMLDIR="${CMAKE_INSTALL_PREFIX}/${QMLDIR}")
 
+if(IS_ABSOLUTE ${QMLDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: QMLDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${QMLDIR} AND NOT WANT_RELOCATABLE)
+	add_definitions(-DQMLDIR="${CMAKE_INSTALL_PREFIX}/${QMLDIR}")
+else()
+	add_definitions(-DQMLDIR="${QMLDIR}")
+endif()
+
 #DESKTOP
 set(DESKTOPDIR "${CMAKE_INSTALL_DATAROOTDIR}/applications/")
-if(NOT IS_ABSOLUTE ${DESKTOPDIR})
+
+if(IS_ABSOLUTE ${DESKTOPDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: DESKTOPDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${DESKTOPDIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DDESKTOPDIR="${CMAKE_INSTALL_PREFIX}/${DESKTOPDIR}")
 else()
 	add_definitions(-DDESKTOPDIR="${DESKTOPDIR}")
@@ -366,9 +412,11 @@
 endif()
 
 #APPDATA
+set(APPDATADIR "${CMAKE_INSTALL_DATAROOTDIR}/metainfo/")
 
-set(APPDATADIR "${CMAKE_INSTALL_DATAROOTDIR}/metainfo/")
-if(NOT IS_ABSOLUTE ${APPDATADIRR})
+if(IS_ABSOLUTE ${APPDATADIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: APPDATADIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${APPDATADIR} AND NOT WANT_RELOCATABLE)
 	add_definitions(-DAPPDATADIR="${CMAKE_INSTALL_PREFIX}/${APPDATADIR}")
 else()
 	add_definitions(-DAPPDATADIR="${APPDATADIR}")
@@ -380,17 +428,17 @@
 # Example: I want to use special ~/.scribus135svn config directory for my trunk
 #          cmake -DAPPLICATION_DATA_DIR=.scribus135svn ...
 if (APPLICATION_DATA_DIR)
-    message(STATUS "Using ApplicationDataDir ${APPLICATION_DATA_DIR} instead of the platform default.")
+	message(STATUS "Using ApplicationDataDir ${APPLICATION_DATA_DIR} instead of the platform default.")
 	add_definitions(-DAPPLICATION_DATA_DIR="${APPLICATION_DATA_DIR}")
 else()
-    message(STATUS "Using standard ApplicationDataDir. You can change it with -DAPPLICATION_DATA_DIR")
+	message(STATUS "Using standard ApplicationDataDir. You can change it with -DAPPLICATION_DATA_DIR")
 endif()
 
 if (APPLICATION_CONFIG_DIR)
-    message(STATUS "Using ApplicationConfigDir ${APPLICATION_CONFIG_DIR} instead of the platform default.")
+	message(STATUS "Using ApplicationConfigDir ${APPLICATION_CONFIG_DIR} instead of the platform default.")
 	add_definitions(-DAPPLICATION_CONFIG_DIR="${APPLICATION_CONFIG_DIR}")
 else()
-    message(STATUS "Using standard ApplicationConfigDir. You can change it with -DAPPLICATION_CONFIG_DIR")
+	message(STATUS "Using standard ApplicationConfigDir. You can change it with -DAPPLICATION_CONFIG_DIR")
 endif()
 
 #LIB LOCATION - lib or lib64 normally
@@ -399,8 +447,9 @@
 	if(NOT ARCH_X86_64)
 		message(STATUS "WARNING: BUILDING 64 Bit build on non 64 bit architecture")
 	endif()
-	 set(LIB_SUFFIX "64" CACHE TYPE STRING)
+	set(LIB_SUFFIX "64" CACHE TYPE STRING)
 endif()
+
 set(LIB_DIR_NAME "lib${LIB_SUFFIX}")
 if (APPLEBUNDLE)
 	set(LIBDIR "lib/")
@@ -407,21 +456,33 @@
 else()
 	set(LIBDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/")
 endif()
-add_definitions(-DLIBDIR="${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
 
+if(IS_ABSOLUTE ${LIBDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: LIBDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${LIBDIR} AND NOT WANT_RELOCATABLE)
+	add_definitions(-DLIBDIR="${CMAKE_INSTALL_PREFIX}/${LIBDIR}")
+else()
+	add_definitions(-DLIBDIR="${LIBDIR}")
+endif()
+
 #PLUGINS
 if(WIN32)
 	set(PLUGINDIR "plugins")
+elseif (APPLEBUNDLE)
+	set(PLUGINDIR "${LIBDIR}")
 else()
-	if (APPLEBUNDLE)
-		set(PLUGINDIR "${LIBDIR}")
-	else()
-		set(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
-	endif()
+	set(PLUGINDIR "${LIB_DIR_NAME}/${MAIN_DIR_NAME}${TAG_VERSION}/plugins/")
 endif()
-add_definitions(-DPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}")
 
+if(IS_ABSOLUTE ${PLUGINDIR} AND WANT_RELOCATABLE)
+	message(FATAL_ERROR "ERROR: PLUGINDIR must be relative when using WANT_RELOCATABLE option")
+elseif(NOT IS_ABSOLUTE ${PLUGINDIR} AND NOT WANT_RELOCATABLE)
+	add_definitions(-DPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}")
+else()
+	add_definitions(-DPLUGINDIR="${PLUGINDIR}")
+endif()
 
+
 #INCLUDE
 set(INCLUDEDIR "include/${MAIN_DIR_NAME}${TAG_VERSION}/")
 #NO ADD DEFINITIONS, WE ONLY INSTALL WITH IT
Index: scribus/scpaths.cpp
===================================================================
--- scribus/scpaths.cpp	(revision 22988)
+++ scribus/scpaths.cpp	(working copy)
@@ -52,20 +52,33 @@
 }
 
 // Protected "real" constructor
-// All paths are initialized to compile-time defaults passed in
+ScPaths::ScPaths()
+{
+// On *nix, all paths are initialized to compile-time defaults passed in
 // as preprocessor macros and set by autoconf.
-ScPaths::ScPaths() :
-	m_docDir(DOCDIR),
-	m_fontDir(),
-	m_iconDir(ICONDIR),
-	m_libDir(LIBDIR),
-	m_pluginDir(PLUGINDIR),
-	m_qmlDir(QMLDIR),
-	m_sampleScriptDir(SAMPLESDIR),
-	m_scriptDir(SCRIPTSDIR),
-	m_shareDir(SHAREDIR),
-	m_templateDir(TEMPLATEDIR)
-{
+#if !defined(Q_OS_MAC) && !defined(_WIN32) && defined(WANT_RELOCATABLE)
+	QString appPath = qApp->applicationDirPath();
+	m_docDir = appPath + "/../" + QString(DOCDIR);
+	m_iconDir = appPath + "/../" + QString(ICONDIR);
+	m_libDir = appPath + "/../" + QString(LIBDIR);
+	m_pluginDir = appPath + "/../" + QString(PLUGINDIR);
+	m_qmlDir = appPath + "/../" + QString(QMLDIR);
+	m_sampleScriptDir = appPath + "/../" + QString(SAMPLESDIR);
+	m_scriptDir = appPath + "/../" + QString(SCRIPTSDIR);
+	m_shareDir = appPath + "/../" + QString(SHAREDIR);
+	m_templateDir = appPath + "/../" + QString(TEMPLATEDIR);
+#elif !defined(Q_OS_MAC) && !defined(_WIN32)
+	m_docDir = QString(DOCDIR);
+	m_iconDir = QString(ICONDIR);
+	m_libDir = QString(LIBDIR);
+	m_pluginDir = QString(PLUGINDIR);
+	m_qmlDir = QString(QMLDIR);
+	m_sampleScriptDir = QString(SAMPLESDIR);
+	m_scriptDir = QString(SCRIPTSDIR);
+	m_shareDir = QString(SHAREDIR);
+	m_templateDir = QString(TEMPLATEDIR);
+#endif
+
 // On MacOS/X, override the compile-time settings with a location
 // obtained from the system.
 #ifdef Q_OS_MAC
