[comp.windows.x] Xt, Xaw problems

gram@uctcs.uucp (Graham Wheeler) (09/27/90)

First, thanks to Stephen Gildea for his suggestion re the __XtInherit
link error - you were quite right, the program did not need to use the
toolkit at all, and worked fine when I took out the -lXt line in the
Makefile.

I am presently writing a screen editor (oh no! not another one) as part
of a Estelle development system under X11R4. I have a background work
routine which calls XawAsciiSourceChanged to see if the edit file has
been altered. If it has, my work routine modifies a status line (it adds
the text "(Modified)" before the edit file name) and uninstalls itself.
My Load File routine rebuilds the status line (a Label widget), and then
reinstalls the work routine.

My problem is that after loading up a new file, the work routine immediately
alters the status line and says the file has been modified, even before it
has. I suspect that this is because the internal change flag of the
AsciiSrc widget is not being cleared. According to the docs (Athena Widget
Set - C Language Interface, pg 83) this flag is reset whenever the string
is queried via XtGetValues or the buffer is saved via XawAsciiSave. I
don't necessarily want to save the old buffer before loading in the new
file, so what I do instead (after patching the status line and loading in
the file, but before reinstalling the work routine) is to query the string
with XtGetValues. However, this doesn't seem to work. The code looks
something like:

/* Work routine */

Boolean UpdateStatus(client_data)
XtPointer client_data;
{
	Arg arg;
	XtSetArg(arg,"textSource",NULL);
	XtGetValues(EditWidget,&arg,1);
	if (XawAsciiSourceChanged(arg.value))
		{
		sprintf(Statusline,"File: (Modified) %-59s",FileName);
		XtSetArg(arg,"label",Statusline);
		XtSetValues(StatusWidget,&arg,1);
		return True; /* Deregister work routine */
		}
	else return False;
}

/* Load file routine (excerpt )*/

static void LoadFile(w, client_data, call_data)
Widget w;
XtPointer client_data, call_data;
{
	/* Various stuff to get file name, etc omitted */

	/* Load in the new file */
	XtSetArg(arg,"string",FileName);
	XtSetValues(EditWidget,&arg,1);

	/* Redraw the status line */
	sprintf(Statusline,"File: %-70s",FileName);
	XtSetArg(arg,"label",Statusline);
	XtSetValues(StatusWidget,&arg,1);

	/* CLEAR THE SOURCE-MODIFIED FLAG */
	XtSetArg(arg,"textSource",NULL);
	XtGetValues(EditWidget,&arg,1);
	Source = (Widget)(arg.value);
	XtSetArg(arg,"string",NULL);
	XtGetValues(Source,&arg,1);

	/* Reregister work routine */
	XtAppAddWorkProc(EditContext, UpdateStatus, NULL);
}


Does anyone have any suggestions about this problem?

Thanks in advance.

Graham Wheeler		      |    
Dept. of Computer Science     | Internet: <gram.uctcs@f4.n494.z5.fidonet.org>
University of Cape Town       |     BANG: <...uunet!ddsw1!olsa99!uctcs!gram>