26 #define YUILogComponent "ui" 32 #include "YIconLoader.h" 36 #define FALLBACK_ICON_PATH "/usr/share/icons/hicolor/" 38 YIconLoader::YIconLoader()
40 addIconSearchPath(FALLBACK_ICON_PATH);
43 YIconLoader::~YIconLoader()
47 void YIconLoader::setIconBasePath( std::string path )
52 std::string YIconLoader::iconBasePath()
const 57 void YIconLoader::addIconSearchPath( std::string path )
59 icon_dirs.push_front( path );
62 std::string YIconLoader::findIcon( std::string name )
65 std::string::size_type loc = name.find(
".png");
66 if ( loc == std::string::npos )
76 if ( !_iconBasePath.empty () )
78 fullPath = _iconBasePath + name;
79 if ( fileExists ( fullPath ) )
81 yuiMilestone() <<
"Found " << name <<
" in global search path" << endl;
87 std::list<std::string>::iterator listIt = icon_dirs.begin();
89 while( listIt != icon_dirs.end() )
92 if ( name.find(
'/') != std::string::npos )
93 fullPath = *listIt + name;
96 fullPath = *listIt +
"22x22/apps/" + name;
98 yuiMilestone() << fullPath << endl;
99 if ( fileExists( fullPath ) )
101 yuiMilestone() <<
"Found " << name <<
" in " << *listIt <<
" search path" << endl;
105 yuiMilestone() << name <<
" not found in " << *listIt <<
" search path, skipping" << endl;
112 bool YIconLoader::fileExists( std::string fname )
114 struct stat fileInfo;
115 int ret = stat (fname.c_str(), &fileInfo);