[comp.windows.x] Resource Retrieval & Usage problem

aw@dukvlsi3.cs.duke.edu (Angus Wang) (08/03/88)

Can anyone tell me why this does not work as I think it is suppose to?
I am working on a text editor that allows you to open another text
window from the one you are currently working in and pipe things from
one to the other.  I would like to be able to read a resource file and
specify colors and positions for each window that is opened.  Window A
is the start up window, so I would like to specify in a resource file
${HOME}/.SigEdrc the following:

SigEd*VPaneA.x:	200
SigEd*VPaneA.y:	0
SigEd*VPaneB.x:	220
SigEd*VPaneB.y:	20
SigEd*VPaneC.x:	240
SigEd*VPaneC.y:	40
SigEd*VPaneD.x:	260
SigEd*VPaneD.y:	60
SigEd*VPaneE.x:	280
SigEd*VPaneE.y:	80   ... etc

I am using the following routine to read in the database and can print
it backout in ASCII but I need to specify when to use these resources
some how.

  ...
    /* Load resources. */
    db = XrmGetFileDatabase(fname);
  ...

=======================================================================
  UUCP :  {ihnp4, decvax}!duke!aw   
  CSNET:  aw@romeo
  ARPA :  aw@romeo.cs.duke.edu

diamant@hpfclp.SDE.HP.COM (John Diamant) (08/06/88)

> Can anyone tell me why this does not work as I think it is suppose to?

That's easy.  You loaded the database into memory, but you never told
your program to use it.  Out of curiosity, why do you want this in
${HOME}/.SIgEdrc?  Normally, defaults like this go in
/usr/lib/X11/app-defaults, with user customizations in .Xdefaults (or some
other file loaded in via xrdb).  One thing you can do to merge this into
.Xdefaults is to use xrdb as follows:

xrdb $HOME/.Xdefaults
xrdb -merge $HOME/.SigEdrc

You may need to use the -nocpp option if you have any "#" comments in your
file.

> Window A
> is the start up window, so I would like to specify in a resource file
> ${HOME}/.SigEdrc the following:
> 
> SigEd*VPaneA.x:	200
> SigEd*VPaneA.y:	0
...
> SigEd*VPaneE.y:	80   ... etc
> 
> I am using the following routine to read in the database and can print
> it backout in ASCII but I need to specify when to use these resources
> some how.
> 
>   ...
>     /* Load resources. */
>     db = XrmGetFileDatabase(fname);

I have found that after loading my own database, I can merge it into the
Xt Intrinsics database to activate it (make the widgets see it).

I do this with the additional piece of code:

	extern XrmDatabase XtDefaultDB;

      XrmMergeDatabases(db, &XtDefaultDB);

This will make your new database override any of the other ones (like
.Xdefaults), which normally isn't quite right.  What you can do to get
around that is:

  XrmMergeDatabases(XtDefaultDB, &db); /* cause existing DB to have precedence*/
/*  XtFree(XtDefaultDB);*/
  XtDefaultDB = db;

I still haven't figured out if I should be freeing the XtDefaultDB or if it
is reusing that database in the merged one.

Anyway, in a sense this isn't kosher because XtDefaultDB is neither documented
nor marked extern in any of the public include files.  I would like to suggest
that it, as well as XtApplicationName and XtApplicationClass become public.

Is there a problem with doing that?  Am I taking a risk with doing what I'm
doing?  It is the only practical way I've found to make a library have an
app-defaults file (since they are keyed off the application class, the library
needs a separate one, but there is no standard way to do that).


John Diamant
Software Development Environments
Hewlett-Packard Co.		ARPA Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		UUCP:  {hplabs,hpfcla}!hpfclp!diamant

swick@ATHENA.MIT.EDU (Ralph R. Swick) (08/10/88)

> Is there a problem with doing that?  Am I taking a risk with doing what I'm
> doing?

Yes and Yes.  The next version of the Intrinsics will have a supported
way to retrieve the resource database associated with a display.  Your
'discovery' is going to disappear in the next release and your code
will break.

swick@oracle (Ralph R. Swick) (08/15/88)

> Will the new supported way allow me to merge in
> entries into the standard databases (not just give me a read-only
> copy of the database)?

There is no such thing as a read-only resource database.
Having the resource database handle gives you more rope...

diamant@oracle (John Diamant) (08/15/88)

> From:  Ralph R. Swick <swick@ATHENA.MIT.EDU>
> Subject:  Re: Resource Retrieval & Usage problem 

> > Will the new supported way allow me to merge in
> > entries into the standard databases (not just give me a read-only
> > copy of the database)?

> There is no such thing as a read-only resource database.
> Having the resource database handle gives you more rope...

I didn't necessarily mean that literally.  I meant one that I couldn't
modify and have it affect the Toolkit globally.  For instance, if it
gave me a copy of the database instead of the one that is actually
used by the Toolkit, that wouldn't be adequate.  Sounds to me like
it gives me the same thing I have now, but in a documented way.

That's great.

Thanks,


John Diamant
Software Development Environments
Hewlett Packard Co.		ARPA Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		UUCP:  {ihnp4!hpfcla,hplabs}!hpfclp!diamant