
On Jan 7, 2006, at 11:22 AM, MenTaLguY wrote:
Have we got a portable way in the tree to enumerate resource files (e.g. stuff in /usr/share/inkscape/[dir] and ~/.inkscape/[dir] ?)
I think we have some copy-n-paste duplication here and there involving such.
from src/widgets/icon.cpp we have ------------------------------------- // Fall back from user prefs dir into system locations. Glib::ustring iconsvg = name; iconsvg += ".svg"; std::list<gchar *> sources; sources.push_back(g_build_filename(profile_path ("icons"),iconsvg.c_str(), NULL)); sources.push_back(g_build_filename(profile_path ("icons"),"icons.svg", NULL)); sources.push_back(g_build_filename(INKSCAPE_PIXMAPDIR, iconsvg.c_str(), NULL)); sources.push_back(g_build_filename(INKSCAPE_PIXMAPDIR, "icons.svg", NULL));
// Try each document in turn until we successfully load the icon from one guchar *px=NULL; while ( !sources.empty() && !px ) { gchar *doc_filename = sources.front(); -------------------------------------
and from src/dialogs/swatches.cpp ------------------------------------- sources.push_back( profile_path("palettes") ); sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) );
// Use this loop to iterate through a list of possible document locations. while (!sources.empty()) { gchar *dirname = sources.front();
if ( Inkscape::IO::file_test( dirname, (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) ) { -------------------------------------
The latter snippet seems to correspond exactly to what your example has. Do these show what you need?
And... is there something more generic we should perhaps do? Should the building up code perhaps be pulled into a common function?