1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 18:47:19 +03:00

Rewrote the function SurfaceCollection::getSkinFilePath() so that it'll search inside the right directories.

This commit is contained in:
Ayla 2011-03-29 20:39:41 +02:00
parent ead9706ffd
commit d59b713e9b

View File

@ -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() {