[comp.sources.x] v01i015: Mailwatch widget, Patch1

mikew@wyse.wyse.com (Mike Wexler) (08/26/88)

Submitted-by: dheller@cory.Berkeley.EDU (Dan Heller)
Posting-number: Volume 1, Issue 15
Archive-name: mailwatch/patch1

Here's some patches for the mailwatch widget.  This shar file contains
a new README-1.1 describing all the changes and a file called Diffs
which can be applied to the original sources.

Please ack this note :-)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	README-1.1
#	Diffs
# This archive created: Wed Aug 24 22:53:03 1988
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'README-1.1'" '(1341 characters)'
if test -f 'README-1.1'
then
	echo shar: "will not over-write existing file 'README-1.1'"
else
cat << \!Funky!Stuff! > 'README-1.1'

Contained with this distribution are the patches to upgrade the Mailwatch
widget from version 1.0 to 1.1.  The original README file has been upgraded
as well, so that should be re-read.

The major change to this version is the installment of a callback function
within the widget itself.  If the application which utilizes the mailwatch
widget installs a callback function, that function will be called if there
is new mail for the user who runs the application.  The callback function
will have the new mail information as the "call_data" parameter of the
callback function the programmer installs.  This means that the former
method of using XtGetValues() to obtain new mail information is gone away.

There is now an inverted GC to represent the "up flag" icon rather than
the old method of reading in the icon with the bits reversed.  This way,
a new icon may be installed at runtime and it will be inverted when
appropriate.

Mail User Agents which _remove_ the user's mailbox when empty will no
longer cause the mailbox flag to remain up.  If the file isn't found,
the flag goes down.

There have been fixes to the man page.

The mailbox directory may be defined in the Makefile as
-DMAILBOX_DIRECTORY=\"pathname...\" or in MailwatchP.h
This is so arbitrary applications can rename the default mailbox
directory in their makefiles...
!Funky!Stuff!
fi  # end of overwriting check
echo shar: "extracting 'Diffs'" '(22397 characters)'
if test -f 'Diffs'
then
	echo shar: "will not over-write existing file 'Diffs'"
else
cat << \!Funky!Stuff! > 'Diffs'
*** OLD/Mailwatch.c	Wed Aug 24 22:30:56 1988
--- Mailwatch.c	Mon Aug 22 23:23:00 1988
***************
*** 15,21 ****
   *
   * When new mail comes in, all new messages are scanned for author and subject
   * and are stored in the "mail" field of the mailwatch data structure.  This
!  * is intended for XtGetValues to obtain if the user desires this info.
   *
   * The mailbox flag goes up when there is new mail _and_ the user hasn't
   * read it yet.  As soon as the user updates the access time on the mailbox,
--- 15,21 ----
   *
   * When new mail comes in, all new messages are scanned for author and subject
   * and are stored in the "mail" field of the mailwatch data structure.  This
!  * data is passed as the call_data to a user supplied callback function.
   *
   * The mailbox flag goes up when there is new mail _and_ the user hasn't
   * read it yet.  As soon as the user updates the access time on the mailbox,
***************
*** 29,37 ****
   * Destroy() will now destroy the flagup and flagdown pixmaps.
   *
   * BUGS:
!  *    For verbose to work, it requires new mail be separated by the
!  * proverbial "From " string as the first 5 chars on a line.  This is
!  * how most mailers deposit mail in /usr/spool/mail.  Sorry MMDF users.
   *
   * It is assumed that when the user starts up this widget, he knows what
   * his mail status is (how much he's got, etc).  Only new mail arrived
--- 29,38 ----
   * Destroy() will now destroy the flagup and flagdown pixmaps.
   *
   * BUGS:
!  *    For Mailwatch to return any information to the callback routine(s),
!  * it requires new mail be separated by the common usage of the "From "
!  * string as the first 5 chars of a mail message.  This is how most mailers
!  * deposit mail in /usr/spool/mail.  Sorry MMDF users.
   *
   * It is assumed that when the user starts up this widget, he knows what
   * his mail status is (how much he's got, etc).  Only new mail arrived
***************
*** 53,59 ****
  static struct stat stbuf;
  static Pixmap ReadBitmapFile();
  static void GetMailFile(), CloseDown();
! static void check_mailbox(), redraw_mailbox(), beep();
  static void Initialize(), Realize(), Destroy(), Redisplay();
  static Boolean SetValues();
  
--- 54,60 ----
  static struct stat stbuf;
  static Pixmap ReadBitmapFile();
  static void GetMailFile(), CloseDown();
! static void check_mailbox(), redraw_mailbox();
  static void Initialize(), Realize(), Destroy(), Redisplay();
  static Boolean SetValues();
  
***************
*** 81,86 ****
--- 82,89 ----
  	offset(flagup), XtRString, NULL},
      {XtNmail, XtCString, XtRString, sizeof(String),
  	offset(mail), XtRString, NULL},
+     {XtNcallback, XtCCallback, XtRCallback, sizeof(caddr_t),
+ 	offset(callback), XtRCallback, NULL},
  };
  
  #undef offset
***************
*** 160,166 ****
  		flagup_bits,
  		pix_up_w = flagup_width,
  		pix_up_h = flagup_height,
! 		w->core.background_pixel, w->mailbox.foreground_pixel,
  		depth);
  
      if (w->mailbox.flagdown)
--- 163,169 ----
  		flagup_bits,
  		pix_up_w = flagup_width,
  		pix_up_h = flagup_height,
! 		w->mailbox.foreground_pixel, w->core.background_pixel,
  		depth);
  
      if (w->mailbox.flagdown)
***************
*** 215,221 ****
  }
  
  static GC
! get_mailbox_gc(w)
  MailwatchWidget w;
  {
      XtGCMask valuemask;
--- 218,224 ----
  }
  
  static GC
! GetNormalGC(w)
  MailwatchWidget w;
  {
      XtGCMask valuemask;
***************
*** 226,234 ****
      xgcv.background = w->core.background_pixel;
      xgcv.function = GXcopy;
      xgcv.graphics_exposures = False;	/* this is Bool, not Boolean */
!     return (XtGetGC((Widget) w, valuemask, &xgcv));
  }
  
  static Pixmap
  ReadBitmapFile(dpy, root, file, width, height)
  Display *dpy;
--- 229,252 ----
      xgcv.background = w->core.background_pixel;
      xgcv.function = GXcopy;
      xgcv.graphics_exposures = False;	/* this is Bool, not Boolean */
!     w->mailbox.normal_GC = XtGetGC((Widget) w, valuemask, &xgcv);
  }
  
+ static GC
+ GetInvertGC(w)
+ MailwatchWidget w;
+ {
+     XtGCMask valuemask;
+     XGCValues xgcv;
+ 
+     valuemask = GCForeground | GCBackground | GCFunction | GCGraphicsExposures;
+     xgcv.foreground = w->mailbox.foreground_pixel;
+     xgcv.background = w->core.background_pixel;
+     xgcv.function = GXcopyInverted;
+     xgcv.graphics_exposures = False;	/* this is Bool, not Boolean */
+     w->mailbox.invert_GC = XtGetGC((Widget) w, valuemask, &xgcv);
+ }
+ 
  static Pixmap
  ReadBitmapFile(dpy, root, file, width, height)
  Display *dpy;
***************
*** 266,272 ****
      XtCreateWindow(gw, InputOutput, (Visual *) CopyFromParent,
  	*valuemaskp, attr);
  
!     w->mailbox.gc = get_mailbox_gc(w);
  
      XtAddEventHandler(gw, ButtonPressMask, FALSE, HandleButtonPress, NULL);
  }
--- 284,291 ----
      XtCreateWindow(gw, InputOutput, (Visual *) CopyFromParent,
  	*valuemaskp, attr);
  
!     GetNormalGC(w);
!     GetInvertGC(w);
  
      XtAddEventHandler(gw, ButtonPressMask, FALSE, HandleButtonPress, NULL);
  }
***************
*** 280,286 ****
      XtFree(w->mailbox.mail);
      XtFree(w->mailbox.filename);
      XtRemoveTimeOut(w->mailbox.interval_id);
!     XtDestroyGC(w->mailbox.gc);
      XFreePixmap(XtDisplay(w), w->mailbox.flagup_pixmap);
      XFreePixmap(XtDisplay(w), w->mailbox.flagdown_pixmap);
  }
--- 299,306 ----
      XtFree(w->mailbox.mail);
      XtFree(w->mailbox.filename);
      XtRemoveTimeOut(w->mailbox.interval_id);
!     XtDestroyGC(w->mailbox.normal_GC);
!     XtDestroyGC(w->mailbox.invert_GC);
      XFreePixmap(XtDisplay(w), w->mailbox.flagup_pixmap);
      XFreePixmap(XtDisplay(w), w->mailbox.flagdown_pixmap);
  }
***************
*** 317,327 ****
  	return 1;
      *p = 0;
      if (!(fp = fopen(w->mailbox.filename, "r")) ||
! 	  fseek(fp, w->mailbox.last_size, 0)) {
! 	(void) sprintf(p, "can't go %ld bytes into %s",
! 	    w->mailbox.last_size, w->mailbox.filename);
  	goto the_end;
-     }
      while (fgets(buf, sizeof(buf), fp)) {
  	if (strncmp(buf, "From ", 5))
  	    continue;
--- 337,344 ----
  	return 1;
      *p = 0;
      if (!(fp = fopen(w->mailbox.filename, "r")) ||
! 	  fseek(fp, w->mailbox.last_size, 0L))
  	goto the_end;
      while (fgets(buf, sizeof(buf), fp)) {
  	if (strncmp(buf, "From ", 5))
  	    continue;
***************
*** 375,398 ****
      int redraw = 0;
  
      if (stat(w->mailbox.filename, &stbuf) == -1) {
! 	extern int errno;
! 	if (errno != ENOENT)
! 	    sprintf(w->mailbox.mail, "can't stat %s", w->mailbox.filename);
      } else {
  	if (stbuf.st_size > w->mailbox.last_size && from(w)) {
  	    redraw = TRUE;
  	    w->mailbox.flag_up = TRUE;
! 	    beep(w);
! 	} else if (stbuf.st_atime > w->mailbox.last_access) {
  	    w->mailbox.last_access = stbuf.st_atime;
  	    if (w->mailbox.flag_up == TRUE)
  		redraw = TRUE;
  	    w->mailbox.flag_up = FALSE;
  	}
  	/* else, no change -- leave it alone */
      }
! 
!     w->mailbox.last_size = stbuf.st_size;
      if (redraw || force_redraw)
  	redraw_mailbox(w);
  
--- 392,417 ----
      int redraw = 0;
  
      if (stat(w->mailbox.filename, &stbuf) == -1) {
!         if (w->mailbox.flag_up == TRUE)
!             redraw = TRUE;
!         w->mailbox.flag_up = FALSE;
!         w->mailbox.last_size = 0;
      } else {
  	if (stbuf.st_size > w->mailbox.last_size && from(w)) {
  	    redraw = TRUE;
  	    w->mailbox.flag_up = TRUE;
! 	    XBell(XtDisplay(w), MAILBOX_VOLUME);
! 	    XtCallCallbacks(w, XtNcallback, w->mailbox.mail);
  	    w->mailbox.last_access = stbuf.st_atime;
+ 	} else if (stbuf.st_atime > w->mailbox.last_access) {
  	    if (w->mailbox.flag_up == TRUE)
  		redraw = TRUE;
  	    w->mailbox.flag_up = FALSE;
  	}
+ 	w->mailbox.last_size = stbuf.st_size;
  	/* else, no change -- leave it alone */
      }
!     
      if (redraw || force_redraw)
  	redraw_mailbox(w);
  
***************
*** 428,436 ****
  	fprintf(stderr, "can't allocate enough memory for widget.\n");
  	exit(1);
      }
!     strcpy(w->mailbox.filename, MAILBOX_DIRECTORY);
!     strcat(w->mailbox.filename, "/");
!     strcat(w->mailbox.filename, username);
  }
  
  static void
--- 447,453 ----
  	fprintf(stderr, "can't allocate enough memory for widget.\n");
  	exit(1);
      }
!     sprintf(w->mailbox.filename, "%s/%s", MAILBOX_DIRECTORY, username);
  }
  
  static void
***************
*** 461,468 ****
      }
      if (current->mailbox.foreground_pixel != new->mailbox.foreground_pixel ||
  	current->core.background_pixel != new->core.background_pixel) {
! 	XtDestroyGC(current->mailbox.gc);
! 	new->mailbox.gc = get_mailbox_gc(new);
  	redisplay = TRUE;
      }
      return (redisplay);
--- 478,487 ----
      }
      if (current->mailbox.foreground_pixel != new->mailbox.foreground_pixel ||
  	current->core.background_pixel != new->core.background_pixel) {
! 	XtDestroyGC(current->mailbox.normal_GC);
! 	XtDestroyGC(current->mailbox.invert_GC);
! 	GetNormalGC(new);
! 	GetInvertGC(new);
  	redisplay = TRUE;
      }
      return (redisplay);
***************
*** 479,496 ****
      register Display *dpy = XtDisplay(mw);
      register Window win = XtWindow(mw);
      register int x, y, w, h;
!     GC  gc = mw->mailbox.gc;
      Pixmap picture;
      Pixel back;
  
      if (mw->mailbox.flag_up) {	/* paint the "up" position */
  	back = mw->mailbox.foreground_pixel;
  	picture = mw->mailbox.flagup_pixmap;
  	w = pix_up_w, h = pix_up_h;
      } else {		/* paint the "down" position */
  	back = mw->core.background_pixel;
  	picture = mw->mailbox.flagdown_pixmap;
  	w = pix_dn_w, h = pix_dn_h;
      }
  
      /* center the picture in the window */
--- 498,520 ----
      register Display *dpy = XtDisplay(mw);
      register Window win = XtWindow(mw);
      register int x, y, w, h;
!     GC gc;
      Pixmap picture;
      Pixel back;
  
      if (mw->mailbox.flag_up) {	/* paint the "up" position */
+ 	XFillRectangle(dpy, win, mw->mailbox.normal_GC,
+ 	    0, 0, mw->core.width, mw->core.height);
  	back = mw->mailbox.foreground_pixel;
  	picture = mw->mailbox.flagup_pixmap;
  	w = pix_up_w, h = pix_up_h;
+ 	gc = mw->mailbox.invert_GC;
      } else {		/* paint the "down" position */
+ 	XClearWindow(dpy, win);
  	back = mw->core.background_pixel;
  	picture = mw->mailbox.flagdown_pixmap;
  	w = pix_dn_w, h = pix_dn_h;
+ 	gc = mw->mailbox.normal_GC;
      }
  
      /* center the picture in the window */
***************
*** 497,513 ****
      x = (mw->core.width - w) / 2;
      y = (mw->core.height - h) / 2;
  
-     XSetWindowBackground(dpy, win, back);
-     XClearWindow(dpy, win);
      XCopyArea(dpy, picture, win, gc, 0, 0, w, h, x, y);
- }
- 
- static void
- beep(w)
- MailwatchWidget w;
- {
-     register Display *dpy = XtDisplay(w);
-     register Window win = XtWindow(w);
- 
-     XBell(dpy, MAILBOX_VOLUME);
  }
--- 521,525 ----
No differences encountered
*** OLD/MailwatchP.h	Wed Aug 24 22:30:58 1988
--- MailwatchP.h	Mon Aug 22 23:21:17 1988
***************
*** 7,30 ****
  #include "Mailwatch.h"
  #include <X11/CoreP.h>
  
  #define MAILBOX_DIRECTORY "/usr/spool/mail"
  #define MAILBOX_VOLUME 33		/* percentage */
  
  typedef struct {			/* new fields for mailwatch widget */
!     Pixel foreground_pixel;		/* color index of normal state fg */
!     GC gc;				/* normal GC to use */
!     int update;				/* seconds between updates */
!     String filename;			/* filename to watch */
!     long last_size;			/* size in bytes of mailboxname */
!     time_t last_access;			/* last time user accessed mailbox */
!     Boolean reverseVideo;		/* do reverse video? */
      XtIntervalId interval_id;		/* time between checks */
-     Boolean flag_up;			/* is the flag up? */
-     String mail;			/* author/subject/date info to "get" */
-     String flagup;			/* path to alternate icon to use */
-     String flagdown;			/* path to alternate icon to use */
-     Pixmap flagup_pixmap;		/* for when there is mail */
-     Pixmap flagdown_pixmap;		/* for when there isn't mail */
  } MailwatchPart;
  
  typedef struct _MailwatchRec {		/* full instance record */
--- 7,34 ----
  #include "Mailwatch.h"
  #include <X11/CoreP.h>
  
+ #ifndef MAILBOX_DIRECTORY
  #define MAILBOX_DIRECTORY "/usr/spool/mail"
+ #endif /* MAILBOX_DIRECTORY */
  #define MAILBOX_VOLUME 33		/* percentage */
  
  typedef struct {			/* new fields for mailwatch widget */
!     Pixel	foreground_pixel;	/* color index of normal state fg */
!     GC		normal_GC;		/* normal GC to use */
!     GC		invert_GC;		/* invert GC to use */
!     int		update;			/* seconds between updates */
!     String	filename;		/* filename to watch */
!     long	last_size;		/* size in bytes of mailboxname */
!     time_t	last_access;		/* last time user accessed mailbox */
!     Boolean	reverseVideo;		/* do reverse video? */
!     Boolean	flag_up;		/* is the flag up? */
!     String	mail;			/* author/subject/date info to "get" */
!     String	flagup;			/* path to alternate icon to use */
!     String	flagdown;		/* path to alternate icon to use */
!     Pixmap	flagup_pixmap;		/* for when there is mail */
!     Pixmap	flagdown_pixmap;	/* for when there isn't mail */
!     XtCallbackList callback;		/* Call func(s) when mail arrives */
      XtIntervalId interval_id;		/* time between checks */
  } MailwatchPart;
  
  typedef struct _MailwatchRec {		/* full instance record */
No differences encountered
*** OLD/Patchlevel.h	Wed Aug 24 22:31:00 1988
--- Patchlevel.h	Wed Aug 24 22:32:03 1988
***************
*** 1 ****
! #define PATHLEVEL 0
--- 1 ----
! #define PATCHLEVEL 1
*** OLD/README	Wed Aug 24 22:31:01 1988
--- README	Mon Aug 22 23:21:19 1988
***************
*** 19,43 ****
  be the flagup/flagdown icons that come with the Mailbox widget.
  
  When new mail comes in, all new messages are scanned for author and subject
! and are stored in the "mail" field of the mailwatch data structure.  This
! is intended for XtGetValues to obtain if the user desires this info.  This
! info is _always_ overwritten on each call (if there is new mail).  It is
! reset to the NULL string once the user xtGetValues() the XtNmail values so
! subsequent calls don't return already reported new mail.
  
  Left button causes the widget to check for new mail.  Middle button
  clears the flag and lets it think there is no new mail (reset).
  
  The program "xwatch" gives an example of the intended use of this widget:
! you XtGetValues() the update timout value, set the main program to timeout
! that often.  Once your program receives a SIGALRM, your routine which
! caught the signal XtGetValues() the XtNmail field of the widget to see
! if there has been new mail.  If so, you can print it to stdout or whatever
! else you want to do with it.  You can choose to ignore this and not ever
! read this value and xwatch will be effectively just like xbiff except for
! the following "feature" described below.
  
! New "Feature"?
  The mailbox flag goes up when there is new mail _and_ the user hasn't
  read it yet.  As soon as the user updates the access time on the mailbox,
  the flag goes down.  I had a pet peeve that xbiff had where you read some
--- 19,39 ----
  be the flagup/flagdown icons that come with the Mailbox widget.
  
  When new mail comes in, all new messages are scanned for author and subject
! and are stored in the "mail" field of the mailwatch data structure.  The user
! is supposed to supply a callback function which, upon the arrival of new mail,
! will be called.  The "call data" parameter to the callback function will
! contain the info about the new mail.
  
  Left button causes the widget to check for new mail.  Middle button
  clears the flag and lets it think there is no new mail (reset).
  
  The program "xwatch" gives an example of the intended use of this widget:
! The callback function installed does nothing more than print the callback
! data (new mail info) to stdout.  You can choose to ignore this and not install
! a callback function and and xwatch will be effectively just like xbiff except
! for the following "feature" described below.
  
! New "Feature"(?)
  The mailbox flag goes up when there is new mail _and_ the user hasn't
  read it yet.  As soon as the user updates the access time on the mailbox,
  the flag goes down.  I had a pet peeve that xbiff had where you read some
***************
*** 45,54 ****
  I'd always have to click on it to set it down.
  
  BUGS:
! Mail _must_ use the "From "-format string as the first 5 chars on a line.
  This is how most mailers deposit mail in /usr/spool/mail.  Sorry MMDF users.
- If your system doesn't use From to separate messages, then don't attempt to
- XtGetValues XtNmail and it'll still work just like the current xbiff.
  
  It is assumed that when the user starts up this widget, he knows what
  his mail status is (how much he's got, etc).  Only new mail arrived
--- 41,49 ----
  I'd always have to click on it to set it down.
  
  BUGS:
! Mail _must_ use the "From "-format string as the first 5 chars on a line
! to separate the message from other messages (a "message separator").
  This is how most mailers deposit mail in /usr/spool/mail.  Sorry MMDF users.
  
  It is assumed that when the user starts up this widget, he knows what
  his mail status is (how much he's got, etc).  Only new mail arrived
***************
*** 58,63 ****
  to check for new mail and behave similarly to what it described above
  only printing information on the status line of your terminal on the
  title bar of your window (X or suntools).  Requests for this program
! and other bug reports about Mailwatch.c etc can be made to me at:
  
      Dan Heller <island!argv@sun.com>
--- 53,58 ----
  to check for new mail and behave similarly to what it described above
  only printing information on the status line of your terminal on the
  title bar of your window (X or suntools).  Requests for this program
! and other bug reports about the enclosed software can be sent to me at:
  
      Dan Heller <island!argv@sun.com>
No differences encountered
*** OLD/xwatch.c	Wed Aug 24 22:31:06 1988
--- xwatch.c	Mon Aug 22 23:21:21 1988
***************
*** 4,23 ****
   * comments, flames and other humorous material to me (C.O.D.'s ok)
   */
  #include <stdio.h>
  #include <X11/Xatom.h>
  #include <X11/Xlib.h>
  #include <X11/Intrinsic.h>
! #include <X11/Atoms.h>
! #include <X11/Cardinals.h>
  #include "Mailwatch.h"
- #include <signal.h>
- #include <sys/time.h>
- #define SIGRET int /* define to of type void for sys-v and sun4's */
  
- extern void exit();
- 
- char *ProgramName;
- 
  static XrmOptionDescRec options[] = {
      {"-update",    "*Mailwatch.update",    XrmoptionSepArg, NULL},
      {"-file",      "*Mailwatch.file",      XrmoptionSepArg, NULL},
--- 4,16 ----
   * comments, flames and other humorous material to me (C.O.D.'s ok)
   */
  #include <stdio.h>
+ #include <X11/Xos.h>
  #include <X11/Xatom.h>
  #include <X11/Xlib.h>
  #include <X11/Intrinsic.h>
! #include <X11/StringDefs.h>
  #include "Mailwatch.h"
  
  static XrmOptionDescRec options[] = {
      {"-update",    "*Mailwatch.update",    XrmoptionSepArg, NULL},
      {"-file",      "*Mailwatch.file",      XrmoptionSepArg, NULL},
***************
*** 26,32 ****
  };
  
  static void
! Usage()
  {
      static char *help_message[] = {
  	"where options include:",
--- 19,26 ----
  };
  
  static void
! Usage(ProgramName)
! String ProgramName;
  {
      static char *help_message[] = {
  	"where options include:",
***************
*** 52,89 ****
  Widget w;
  
  /*
!  * When the timer goes off, query the mail and print it.  Always reset
!  * the buffer to NULL so the next query won't get the same information
!  * that you got the previous time.
   */
! SIGRET
! print_mail()
  {
!     char *buf, *file;
!     Arg arg[3];
! 
!     XtSetArg(arg[0], XtNmail, &buf);
!     XtSetArg(arg[1], XtNfile, &file);
!     XtGetValues(w, arg, TWO);
!     if (buf[0])
! 	fputs(buf, stdout);
!     /*
! 	printf("New mail in %s:\r\n%s", file, buf);
!     else
! 	printf("No new mail in %s\r\n", file);
!     */
!     buf[0] = 0;
  }
  
  void
  main(argc, argv)
  int argc;
! char **argv;
  {
      Widget toplevel;
!     struct itimerval timer;
!     long timeout;
!     Arg arg;
  
      ProgramName = argv[0];
  
--- 46,69 ----
  Widget w;
  
  /*
!  * Callback routine to print new mail when it arrives.
   */
! void
! print_mail(w, client_data, mail_info)
! MailwatchWidget w;
! caddr_t client_data; /* unused */
! String mail_info;    /* returned by the widget */
  {
!     (void) fputs(mail_info, stdout);
  }
  
  void
  main(argc, argv)
  int argc;
! char *argv[];
  {
      Widget toplevel;
!     String ProgramName;
  
      ProgramName = argv[0];
  
***************
*** 90,107 ****
      toplevel = XtInitialize("xwatch", "XWatch", options, XtNumber(options),
  	&argc, argv);
      if (argc != 1)
! 	Usage();
  
      w = XtCreateManagedWidget("xwatch", mailwatchWidgetClass, toplevel,NULL,0);
!     XtRealizeWidget(toplevel);
  
!     XtSetArg(arg, XtNupdate, &timeout);
!     XtGetValues(w, &arg, ONE);
!     (void) signal(SIGALRM, print_mail);
!     timerclear(&(timer.it_interval));
!     timerclear(&(timer.it_value));
!     timer.it_value.tv_sec = timer.it_interval.tv_sec = timeout;
!     setitimer(ITIMER_REAL, &timer, NULL);
! 
      XtMainLoop();
  }
--- 70,80 ----
      toplevel = XtInitialize("xwatch", "XWatch", options, XtNumber(options),
  	&argc, argv);
      if (argc != 1)
! 	Usage(ProgramName);
  
      w = XtCreateManagedWidget("xwatch", mailwatchWidgetClass, toplevel,NULL,0);
!     XtAddCallback(w, XtNcallback, print_mail, NULL);
  
!     XtRealizeWidget(toplevel);
      XtMainLoop();
  }
*** OLD/xwatch.man	Wed Aug 24 22:31:08 1988
--- xwatch.man	Wed Aug 24 22:29:44 1988
***************
*** 125,133 ****
  .B reverseVideo (\fPclass\fB ReverseVideo)
  Specifies that the foreground and background should be reversed.
  .TP 8
! .B up_flag (\fclass\fB File)
  .TP 8
! .B down_flag (\fclass\fB File)
  Specifies the filename to read for the up flag and the down flag icons
  respectively.
  .SH ENVIRONMENT
--- 125,133 ----
  .B reverseVideo (\fPclass\fB ReverseVideo)
  Specifies that the foreground and background should be reversed.
  .TP 8
! .B up_flag (\fPclass\fB File)
  .TP 8
! .B down_flag (\fPclass\fB File)
  Specifies the filename to read for the up flag and the down flag icons
  respectively.
  .SH ENVIRONMENT
!Funky!Stuff!
fi  # end of overwriting check
exit 0
#	End of shell archive
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330