r15483 by craig - Add in a XDG location finder to ScPaths, to be used for #9217 hopefully

scribus-commit scribus-commit at lists.scribus.net
Thu Sep 23 23:28:22 CEST 2010


Author: craig
Date: Thu Sep 23 21:28:22 2010
New Revision: 15483

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15483
Log:
Add in a XDG location finder to ScPaths, to be used for #9217 hopefully

Modified:
    trunk/Scribus/scribus/colorsetmanager.cpp
    trunk/Scribus/scribus/scpaths.cpp
    trunk/Scribus/scribus/scpaths.h

Modified: trunk/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15483&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp (original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp Thu Sep 23 21:28:22 2010
@@ -111,6 +111,7 @@
 {
 	paletteLocations.clear();
 	QStringList locations=ScPaths::instance().getSystemCreateSwatchesDirs();
+	locations << ScPaths::instance().getSystemXDGDirs("swatches");
 	locations << ScPaths::instance().libDir()+"swatches/";
 	for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it )
 	{

Modified: trunk/Scribus/scribus/scpaths.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15483&path=/trunk/Scribus/scribus/scpaths.cpp
==============================================================================
--- trunk/Scribus/scribus/scpaths.cpp (original)
+++ trunk/Scribus/scribus/scpaths.cpp Thu Sep 23 21:28:22 2010
@@ -8,6 +8,7 @@
 #include <QApplication>
 #include <QDebug>
 #include <QDir>
+#include <QProcess>
 
 #include "scconfig.h"
 
@@ -271,6 +272,52 @@
 	return iccProfDirs;
 }
 
+QStringList ScPaths::getSystemXDGDirs(const QString dirToFind)
+{
+	QChar sep(':');
+#ifdef _WIN32
+	sep=';';
+#endif
+	QStringList xdgDirs;
+#if defined(Q_OS_MAC) or defined(Q_OS_UNIX)
+	//qDebug()<<"Searching for XDG locations...";
+	//Get $XDG_DATA_HOME
+	QStringList env = QProcess::systemEnvironment();
+	QString path_xdg_home,path_xdg_data;
+	foreach (QString line, env)
+	{
+		if (line.indexOf("XDG_DATA_HOME") == 0)
+			path_xdg_home = line.mid(14); //Strip "XDG_DATA_HOME="
+		if (line.indexOf("XDG_DATA_DIRS") == 0)
+			path_xdg_data = line.mid(14); //Strip "XDG_DATA_DIRS="
+	}
+	QStringList splitpath_home,splitpath_data;
+	splitpath_home = path_xdg_home.split(sep, QString::SkipEmptyParts);
+	splitpath_data = path_xdg_data.split(sep, QString::SkipEmptyParts);
+	//qDebug()<<"splitpath_home: "<<splitpath_home;
+	//qDebug()<<"splitpath_data: "<<splitpath_data;
+	QString dirSuffix("scribus/"+dirToFind);
+	foreach (QString dir, splitpath_home)
+	{
+		QFileInfo info(dir+dirSuffix);
+		if (info.exists())
+		{
+			//qDebug()<<"XDG_HOME:"<<dir+dirSuffix;
+			xdgDirs.append(dir+dirSuffix);
+		}
+	}
+	foreach (QString dir, splitpath_data)
+	{
+		QFileInfo info(dir+dirSuffix);
+		if (info.exists())
+		{
+			//qDebug()<<"XDG_DATA:"<<dir+dirSuffix;
+			xdgDirs.append(dir+dirSuffix);
+		}
+	}
+#endif
+	return xdgDirs;
+}
 QStringList ScPaths::getSystemCreateSwatchesDirs(void)
 {
 	QStringList createDirs;

Modified: trunk/Scribus/scribus/scpaths.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15483&path=/trunk/Scribus/scribus/scpaths.h
==============================================================================
--- trunk/Scribus/scribus/scpaths.h (original)
+++ trunk/Scribus/scribus/scpaths.h Thu Sep 23 21:28:22 2010
@@ -60,7 +60,8 @@
 	static QStringList getSystemProfilesDirs(void);
 	/** @brief Return paths to system create project directories*/
 	static QStringList getSystemCreateSwatchesDirs(void);
-
+	/** @brief Return paths to system XDG directories*/
+	static QStringList getSystemXDGDirs(const QString dirToFind);
 	/** @brief Return path to application data dir*/
 	static QString getApplicationDataDir(void);
 	/** @brief Return path to image cache dir*/




More information about the scribus-commit mailing list