From 3e37086b581d49d4112eafa3ae21df9b95314081 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Fri, 20 Aug 2010 20:56:17 +0200
Subject: Make resource paths comply with OpenDesktop standards.


diff --git a/Swiften/Application/UnixApplicationPathProvider.h b/Swiften/Application/UnixApplicationPathProvider.h
index 676cb94..92cb6dd 100644
--- a/Swiften/Application/UnixApplicationPathProvider.h
+++ b/Swiften/Application/UnixApplicationPathProvider.h
@@ -12,13 +12,25 @@
 #include <unistd.h>
 
 #include "Swiften/Base/ByteArray.h"
+#include "Swiften/Base/foreach.h"
 
 namespace Swift {
 	class UnixApplicationPathProvider : public ApplicationPathProvider {
 		public:
 			UnixApplicationPathProvider(const String& name) : ApplicationPathProvider(name) {
-				resourceDirs.push_back("/usr/share/swift");
 				resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
+				char* xdgDataDirs = getenv("XDG_DATA_DIRS");
+				if (xdgDataDirs) {
+					std::vector<String> dataDirs = String(xdgDataDirs).split(":");
+					if (!dataDirs.empty()) {
+						foreach(const String& dir, dataDirs) {
+							resourceDirs.push_back(boost::filesystem::path(dir.getUTF8String()) / "swift");
+						}
+						return;
+					}
+				}
+				resourceDirs.push_back("/usr/local/share/swift");
+				resourceDirs.push_back("/usr/share/swift");
 			}
 
 			virtual boost::filesystem::path getHomeDir() const {
-- 
cgit v0.10.2-6-g49f6