jsparkes@bcars85.bnr.ca (Jeff Sparkes) (07/26/90)
Is there any way get at the compiled and merged set of resources that Xt uses for widgets? I use my own calls to the resource manager to grab some special resources, but I only know how to get the server string, not all the resource with options and app-defaults mixed in. The relevant bits of code follow. The reason I am doing this is to get different translation tables based on (mostly) arbitrary keyboard names. Xt seems to 1. only deal with resource names that are compiled in 2. not deal with requests with emedded dots ... if ((s = XResourceManagerString(display)) != NULL) { char buf[100]; rdb = XrmGetStringDatabase(s); sprintf(buf, "keymap.%s", appres.keymap); kbdtrans = get_resource(rdb, argv[0], buf); sprintf(buf, "keymap.%s.user", appres.keymap); usertrans = get_resource(rdb, argv[0], buf); } else { XtWarning("No server resource database"); } ... /* * A way to work around bugs with Xt resources. It seems to be impossible * to get arbitrarily named resources. Someday this should be hacked to * add classes too. */ char * get_resource(rdb, prog, name) XrmDatabase rdb; char *prog, *name; { XrmValue value; char *type[20]; char buf[20], str[1024]; char *s; if ((s = rindex(prog, '/')) != 0) prog = s+1; sprintf(str, "%s.%s", prog, name); if (XrmGetResource(rdb, str, 0, type, &value) == True) { return XtNewString(value.addr); } else { return 0; } } -- Jeff Sparkes jsparkes@bnr.ca Another feature is that the seats float, so that the airline can recover them if the plane crashes into the ocean. -- Dave Barry
swick@ATHENA.MIT.EDU (Ralph Swick) (07/26/90)
Is there any way get at the compiled and merged set of resources that Xt uses for widgets? XtDatabase() will give you a handle for the merged resource database constructed by Xt. 1. only deal with resource names that are compiled in 2. not deal with requests with emedded dots In Xt, the name/class separators correspond to an arbitrary Object hierarchy. You can fetch these resources in multiple ways, but the way that looks most like your code example is XtGetApplicationResources(). Applications can easily "compile in" their own resources.