diff --git a/src/driver/fb_generic.cpp b/src/driver/fb_generic.cpp index 51fbeebe1..83e43799d 100644 --- a/src/driver/fb_generic.cpp +++ b/src/driver/fb_generic.cpp @@ -706,27 +706,48 @@ void CFrameBuffer::setIconBasePath(const std::string & iconPath) std::string CFrameBuffer::getIconPath(std::string icon_name, std::string file_type) { - std::string path, filetype = ""; - if (!file_type.empty()) - filetype = "." + file_type; + // why search when we have an absolut path ? + if (icon_name.find("/", 0) != std::string::npos) + return icon_name; - std::string dir[] = { THEMESDIR_VAR "/" + g_settings.theme_name + "/icons", - THEMESDIR "/" + g_settings.theme_name + "/icons", - ICONSDIR_VAR, - iconBasePath + std::vector filetypes = { ".svg", ".png", ".jpg" }; + std::string path = icon_name; + + std::string::size_type pos = icon_name.find_last_of("."); + if (pos != std::string::npos && file_type.empty()) + if (std::find(filetypes.begin(), filetypes.end(), icon_name.substr(pos)) != filetypes.end()) + { + icon_name = path.substr(0,pos); + file_type = path.substr(pos+1); + } + if (!file_type.empty()) + { + filetypes.clear(); + filetypes.push_back("." + file_type); + } + + std::vector dir = + { + THEMESDIR_VAR "/" + g_settings.theme_name + "/icons", + THEMESDIR "/" + g_settings.theme_name + "/icons", + ICONSDIR_VAR, + iconBasePath }; - for(int i=0; i<4 ; i++){ - path = std::string(dir[i]) + "/" + icon_name + filetype; - if (access(path.c_str(), F_OK) == 0){ - return path; + for(unsigned int t=0; t