mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
rework framebuffer getIconPath
This commit is contained in:
@@ -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 CFrameBuffer::getIconPath(std::string icon_name, std::string file_type)
|
||||||
{
|
{
|
||||||
std::string path, filetype = "";
|
// why search when we have an absolut path ?
|
||||||
if (!file_type.empty())
|
if (icon_name.find("/", 0) != std::string::npos)
|
||||||
filetype = "." + file_type;
|
return icon_name;
|
||||||
|
|
||||||
std::string dir[] = { THEMESDIR_VAR "/" + g_settings.theme_name + "/icons",
|
std::vector<std::string> 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<std::string> dir =
|
||||||
|
{
|
||||||
|
THEMESDIR_VAR "/" + g_settings.theme_name + "/icons",
|
||||||
THEMESDIR "/" + g_settings.theme_name + "/icons",
|
THEMESDIR "/" + g_settings.theme_name + "/icons",
|
||||||
ICONSDIR_VAR,
|
ICONSDIR_VAR,
|
||||||
iconBasePath
|
iconBasePath
|
||||||
};
|
};
|
||||||
|
|
||||||
for(int i=0; i<4 ; i++){
|
for(unsigned int t=0; t<filetypes.size(); t++)
|
||||||
path = std::string(dir[i]) + "/" + icon_name + filetype;
|
{
|
||||||
if (access(path.c_str(), F_OK) == 0){
|
for(unsigned int i=0; i<dir.size(); i++)
|
||||||
|
{
|
||||||
|
path = std::string(dir[i]) + "/" + icon_name + filetypes[t];
|
||||||
|
if (access(path.c_str(), F_OK) == 0)
|
||||||
|
{
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (icon_name.find("/", 0) != std::string::npos)
|
// nothing found, return empty string
|
||||||
path = icon_name;
|
return "";
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFrameBuffer::getIconSize(const char * const filename, int* width, int *height)
|
void CFrameBuffer::getIconSize(const char * const filename, int* width, int *height)
|
||||||
@@ -1572,7 +1593,7 @@ void CFrameBuffer::Clear()
|
|||||||
|
|
||||||
bool CFrameBuffer::showFrame(const std::string & filename, int fallback_mode)
|
bool CFrameBuffer::showFrame(const std::string & filename, int fallback_mode)
|
||||||
{
|
{
|
||||||
std::string picture = getIconPath(filename, "");
|
std::string picture = getIconPath(filename);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if (access(picture.c_str(), F_OK) == 0 && !(fallback_mode & SHOW_FRAME_FALLBACK_MODE_IMAGE_UNSCALED))
|
if (access(picture.c_str(), F_OK) == 0 && !(fallback_mode & SHOW_FRAME_FALLBACK_MODE_IMAGE_UNSCALED))
|
||||||
|
@@ -233,7 +233,7 @@ class CFrameBuffer : public sigc::trackable
|
|||||||
|
|
||||||
void setIconBasePath(const std::string & iconPath);
|
void setIconBasePath(const std::string & iconPath);
|
||||||
std::string getIconBasePath(){return iconBasePath;};
|
std::string getIconBasePath(){return iconBasePath;};
|
||||||
std::string getIconPath(std::string icon_name, std::string file_type = "png");
|
std::string getIconPath(std::string icon_name, std::string file_type = "");
|
||||||
|
|
||||||
void getIconSize(const char * const filename, int* width, int *height);
|
void getIconSize(const char * const filename, int* width, int *height);
|
||||||
/* h is the height of the target "window", if != 0 the icon gets centered in that window */
|
/* h is the height of the target "window", if != 0 the icon gets centered in that window */
|
||||||
|
Reference in New Issue
Block a user