29 #define YUILogComponent "ui" 32 #include "YIconLoader.h" 34 #define FALLBACK_ICON_PATH "/usr/share/icons/hicolor/" 40 YIconLoader::YIconLoader()
42 addIconSearchPath( FALLBACK_ICON_PATH );
46 YIconLoader::~YIconLoader()
51 void YIconLoader::setIconBasePath(
string path )
57 string YIconLoader::iconBasePath()
const 63 void YIconLoader::addIconSearchPath(
string path )
65 icon_dirs.push_front( path );
69 string YIconLoader::findIcon(
string name )
72 string::size_type loc = name.find(
".png");
73 if ( loc == string::npos )
83 if ( !_iconBasePath.empty () )
85 fullPath = _iconBasePath + name;
86 if ( fileExists ( fullPath ) )
88 yuiMilestone() <<
"Found " << name <<
" in global search path" << endl;
94 std::list<string>::iterator listIt = icon_dirs.begin();
96 while( listIt != icon_dirs.end() )
99 if ( name.find(
'/') != string::npos )
100 fullPath = *listIt + name;
103 fullPath = *listIt +
"22x22/apps/" + name;
105 if ( fileExists( fullPath ) )
107 yuiMilestone() <<
"Found " << name <<
" in " << *listIt <<
" search path" << endl;
111 yuiMilestone() << name <<
" not found in " << *listIt <<
" search path, skipping" << endl;
119 bool YIconLoader::fileExists(
string fname )
121 struct stat fileInfo;
122 int ret = stat (fname.c_str(), &fileInfo);