Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.csd.uwm.edu!uakari.primate.wisc.edu!indri!ames!nap1!asdcds!staatsvr From: staatsvr@asdcds.cds.wpafb.af.mil (Vern Staats; ASD/SCED;) Newsgroups: comp.windows.x Subject: Re: Visuals, colors, resource db Summary: program-specific defaults vs. app-defaults file Message-ID: <274@nap1.cds.wpafb.af.mil> Date: 25 Aug 89 18:41:05 GMT References: Sender: news@nap1.cds.wpafb.af.mil Reply-To: staatsvr@asdcds.UUCP (Vern Staats) Organization: US. Air Force, ASD, Wright-Patterson AFB Lines: 66 In article ado@hutcs.hut.fi (Andre Dolenc) writes: >>> Resource database question: I have an application-dependent resource >>> db which I would like to merge with the one returned by XtDatabase. >> How about using an app-defaults file instead? This way the toolkit >> will merge your resources in for you. > Yes, I thought of that. But I have at least 2 resource files which > must be loaded; one of them is (human) language dependent. I have a similar question on X Philosophy and resource databases: Should program-specific defaults for resources be rigorously avoided, or are they OK provided they have the absolute rock-bottom precedence? I get the feeling that requiring an app-defaults file is the "philisophically correct" thing to do, but I'd really prefer to have my applications stay somewhat sane in its absence. Here's what I'm doing. I think its OK, please zap me if its wrong. ------------------------------------------------------------------------ main() { ... XtToolkitInitialize(); dpy = XtOpenDisplay((XtAppContext) NULL,displayname,app_name,app_class, opTable,opTableEntries,&argc,argv); toplevel = XtAppCreateShell(app_name,app_class,topLevelShellWidgetClass, dpy,top_args,XtNumber(top_args)); merge_default_prefs(); ... } /* Adds application-specific hardcoded defaults to current database, ** at a lower precedence than the existing database. */ merge_default_prefs() { int i; static XrmDatabase finalDB = NULL; XrmDatabase currentDB; static char *pgmdefaults[] = { "*button.background: gray50\n", "*button.foreground: cyan\n", /* and etc */ }; for (i=0; i < sizeof(pgmdefaults) / sizeof(char *); i++) { XrmPutLineResource(&finalDB,pgmdefaults[i]); } currentDB = XtDatabase(dpy); XrmMergeDatabases(currentDB,&finalDB); /* so now the currentDB (from .Xdefaults, etc) has overwritten my pgmdefaults in finalDB. Now all we have to do is install finalDB. */ /* Which of these is better form? Peeking at Xlib.h and Xresource.h: */ dpy->db = finalDB; /* or this?: currentDB = XtDatabase(dpy); XrmMergeDatabases(finalDB,¤tDB); */ } ---- INET: staatsvr@asd.wpafb.af.mil Vern Staats (513) 255-2714 /// Save UUCP: nap1!asd!staatsvr ASD/SCED \\\/// The Opinions: my!own! WPAFB OH 45433 \XX/ Guru