Пример #1
0
// locate bitmap
// this mimics XmGetPixmap's efforts to locate a path
static String locateBitmap(Display *display, const _XtString basename)
{
    SubstitutionRec subst;
    subst.match        = 'B';
    subst.substitution = CONST_CAST(char*,basename);

    return XtResolvePathname(
	display,      // the display we use
	"bitmaps",    // %T = bitmaps
	String(0),    // %N = application class name
	"",           // %S = "" (suffix)
	PATH.chars(), // path to use
	&subst, 1,    // %B = basename
	XtFilePredicate(0)); // no checking for valid bitmap
}
Пример #2
0
static int check_xkeysymdb(Display *display, bool verbose)
{
    if (verbose)
    {
	(void) xlibdir(display, verbose);
    }

    if (verbose)
    {
	std::cout << "Checking for XKeysymDB... ";
	std::cout.flush();
    }

    String me, my_class;
    XtGetApplicationNameAndClass(display, &me, &my_class);

    string xkeysymdb;

    {
	const _XtString s = getenv("XKEYSYMDB");
	if (s != 0)
	    xkeysymdb = s;
    }

    if (xkeysymdb.empty())
    {
	String s = XtResolvePathname(display, "", "XKeysymDB", "",
				     (String)0, Substitution(0), 0, 
				     XtFilePredicate(0));
	if (s != 0)
	    xkeysymdb = s;
	XtFree(s);
    }

    if (!xkeysymdb.empty())
    {
	if (verbose)
	{
	    std::cout << xkeysymdb << "\n";
	    std::cout.flush();
	}

	// Fix it now
	static string env;
	env = "XKEYSYMDB=" + xkeysymdb;
	putenv(CONST_CAST(char*,env.chars()));

	return 0;			// Okay
    }

    if (xlibdir(display) != 0)
    {
	string path = string(xlibdir(display)) + "/XKeysymDB";
	if (is_file(path))
	{
	    if (verbose)
	    {
		std::cout << path << "\n"
		     << "Note: this is not the default path compiled into " 
		     << me << ".\n"
		     << "    To avoid having " << me 
		     << " determine this setting each time it is started,\n"
		     << "    please set the XKEYSYMDB "
		     << "environment variable to\n"
		     << "    " << quote(path) << ".\n";
		std::cout.flush();
	    }

	    // Fix it
	    static string env;
	    env = "XKEYSYMDB=" + path;
	    putenv(CONST_CAST(char*,env.chars()));
	    return 0;
	}
    }