From d59b713e9be91c98d20bc72ecbc952ecf4f01999 Mon Sep 17 00:00:00 2001 From: Ayla Date: Tue, 29 Mar 2011 20:39:41 +0200 Subject: [PATCH] Rewrote the function SurfaceCollection::getSkinFilePath() so that it'll search inside the right directories. --- src/surfacecollection.cpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/surfacecollection.cpp b/src/surfacecollection.cpp index bcd8a51..3e6f2a2 100644 --- a/src/surfacecollection.cpp +++ b/src/surfacecollection.cpp @@ -22,6 +22,7 @@ #include "surface.h" #include "utilities.h" #include "debug.h" +#include "gmenu2x.h" using std::endl; using std::string; @@ -37,16 +38,26 @@ void SurfaceCollection::setSkin(const string &skin) { this->skin = skin; } -string SurfaceCollection::getSkinFilePath(const string &file) { - string prefix = "/usr/share/gmenu2x/"; - if (fileExists("skins/"+skin+"/"+file)) - return "skins/"+skin+"/"+file; - else if (fileExists("skins/Default/"+file)) - return "skins/Default/"+file; - else if (fileExists(prefix+"skins/Default/"+file)) - return prefix+"skins/Default/"+file; - else - return ""; +string SurfaceCollection::getSkinFilePath(const string &file) +{ + /* We first search the skin file on the user-specific directory. */ + string path = GMenu2X::getHome() + "/skins/" + skin + "/" + file; + if (fileExists(path)) + return path; + + /* If not found, we search that skin file on the system directory. */ + path = GMENU2X_SYSTEM_DIR "/skins/" + skin + "/" + file; + if (fileExists(path)) + return path; + + /* If it is nowhere to be found, as a last resort we check the + * "Default" skin on the system directory for a corresponding + * (but probably not similar) file. */ + path = GMENU2X_SYSTEM_DIR "/skins/Default/" + file; + if (fileExists(path)) + return path; + + return ""; } void SurfaceCollection::debug() {