diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:58 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:48:58 +0000 |
commit | 248f03b4a519c635bdfa16ae1c7aa708a006c580 (patch) | |
tree | 0513ee6bd7ecccf70152633aa72a490a83c117fa |
Initial revisionXORG-STABLE
-rw-r--r-- | Mailbox.c | 687 | ||||
-rw-r--r-- | Mailbox.h | 74 | ||||
-rw-r--r-- | MailboxP.h | 101 | ||||
-rw-r--r-- | bitmaps/mail-down | 27 | ||||
-rw-r--r-- | bitmaps/mail-down-mask | 29 | ||||
-rw-r--r-- | bitmaps/mail-up | 27 | ||||
-rw-r--r-- | bitmaps/mail-up-mask | 29 | ||||
-rw-r--r-- | xbiff.c | 129 | ||||
-rw-r--r-- | xbiff.man | 216 |
9 files changed, 1319 insertions, 0 deletions
diff --git a/Mailbox.c b/Mailbox.c new file mode 100644 index 0000000..eb6aad6 --- /dev/null +++ b/Mailbox.c @@ -0,0 +1,687 @@ +/* $XConsortium: Mailbox.c,v 1.64 94/04/17 20:43:26 rws Exp $ */ +/* + +Copyright (c) 1988 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ +/* $XFree86: xc/programs/xbiff/Mailbox.c,v 1.5 2001/10/28 03:34:25 tsi Exp $ */ + +/* + * Author: Jim Fulton, MIT X Consortium + * + * I recommend that you use the new mailfull and mailempty bitmaps instead of + * the ugly mailboxes: + * + * XBiff*fullPixmap: mailfull + * XBiff*emptyPixmap: mailempty + */ + +#include <X11/IntrinsicP.h> /* for toolkit stuff */ +#include <X11/StringDefs.h> /* for useful atom names */ +#include <X11/cursorfont.h> /* for cursor constants */ +#include <X11/Xosdefs.h> /* for X_NOT_POSIX def */ +#include <stdlib.h> +#ifdef WIN32 +#include <X11/Xw32defs.h> +#else +#include <pwd.h> /* for getting username */ +#endif +#include <sys/stat.h> /* for stat() ** needs types.h ***/ +#include <stdio.h> /* for printing error messages */ +#include <unistd.h> + +#ifndef X_NOT_POSIX +#ifdef _POSIX_SOURCE +# include <sys/wait.h> +#else +#define _POSIX_SOURCE +# include <sys/wait.h> +#undef _POSIX_SOURCE +#endif +# define waitCode(w) WEXITSTATUS(w) +# define waitSig(w) WIFSIGNALED(w) +typedef int waitType; +# define INTWAITTYPE +#else /* ! X_NOT_POSIX */ +#ifdef SYSV +# define waitCode(w) (((w) >> 8) & 0x7f) +# define waitSig(w) ((w) & 0xff) +typedef int waitType; +# define INTWAITTYPE +#else +#ifdef WIN32 +#include <process.h> +# define INTWAITTYPE +typedef int waitType; +# define waitCode(w) (w) +# define waitSig(w) (0) +#else +# include <sys/wait.h> +# define waitCode(w) ((w).w_T.w_Retcode) +# define waitSig(w) ((w).w_T.w_Termsig) +typedef union wait waitType; +#endif /* WIN32 else */ +#endif /* SYSV else */ +#endif /* ! X_NOT_POSIX else */ + +#include <X11/bitmaps/mailfull> /* for flag up (mail present) bits */ +#include <X11/bitmaps/mailempty> /* for flag down (mail not here) */ + +#include <X11/Xaw/XawInit.h> +#include "MailboxP.h" /* for implementation mailbox stuff */ +#include <X11/Xmu/Drawing.h> +#include <X11/extensions/shape.h> + +/* + * The default user interface is to have the mailbox turn itself off whenever + * the user presses a button in it. Expert users might want to make this + * happen on EnterWindow. It might be nice to provide support for some sort of + * exit callback so that you can do things like press q to quit. + */ + +static char defaultTranslations[] = + "<ButtonPress>: unset()"; + +static void Check(), Set(), Unset(); + +static XtActionsRec actionsList[] = { + { "check", Check }, + { "unset", Unset }, + { "set", Set }, +}; + + +/* Initialization of defaults */ + +#define offset(field) XtOffsetOf(MailboxRec, mailbox.field) +#define goffset(field) XtOffsetOf(WidgetRec, core.field) + +static Dimension defDim = 48; +static Pixmap nopix = None; + +static XtResource resources[] = { + { XtNwidth, XtCWidth, XtRDimension, sizeof (Dimension), + goffset (width), XtRDimension, (XtPointer)&defDim }, + { XtNheight, XtCHeight, XtRDimension, sizeof (Dimension), + goffset (height), XtRDimension, (XtPointer)&defDim }, + { XtNupdate, XtCInterval, XtRInt, sizeof (int), + offset (update), XtRString, "30" }, + { XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel), + offset (foreground_pixel), XtRString, XtDefaultForeground }, + { XtNfile, XtCFile, XtRString, sizeof (String), + offset (filename), XtRString, NULL }, + { XtNcheckCommand, XtCCheckCommand, XtRString, sizeof(char*), + offset (check_command), XtRString, NULL}, + { XtNvolume, XtCVolume, XtRInt, sizeof(int), + offset (volume), XtRString, "33"}, + { XtNonceOnly, XtCBoolean, XtRBoolean, sizeof(Boolean), + offset (once_only), XtRImmediate, (XtPointer)False }, + { XtNfullPixmap, XtCPixmap, XtRBitmap, sizeof(Pixmap), + offset (full.bitmap), XtRString, "flagup" }, + { XtNfullPixmapMask, XtCPixmapMask, XtRBitmap, sizeof(Pixmap), + offset (full.mask), XtRBitmap, (XtPointer) &nopix }, + { XtNemptyPixmap, XtCPixmap, XtRBitmap, sizeof(Pixmap), + offset (empty.bitmap), XtRString, "flagdown" }, + { XtNemptyPixmapMask, XtCPixmapMask, XtRBitmap, sizeof(Pixmap), + offset (empty.mask), XtRBitmap, (XtPointer) &nopix }, + { XtNflip, XtCFlip, XtRBoolean, sizeof(Boolean), + offset (flipit), XtRString, "true" }, + { XtNshapeWindow, XtCShapeWindow, XtRBoolean, sizeof(Boolean), + offset (shapeit), XtRString, "false" }, +}; + +#undef offset +#undef goffset + +static void GetMailFile(), CloseDown(); +static void check_mailbox(), redraw_mailbox(), beep(); +static void Initialize(), Realize(), Destroy(), Redisplay(); +static Boolean SetValues(); + +MailboxClassRec mailboxClassRec = { + { /* core fields */ + /* superclass */ (WidgetClass) &simpleClassRec, + /* class_name */ "Mailbox", + /* widget_size */ sizeof(MailboxRec), + /* class_initialize */ XawInitializeWidgetSet, + /* class_part_initialize */ NULL, + /* class_inited */ FALSE, + /* initialize */ Initialize, + /* initialize_hook */ NULL, + /* realize */ Realize, + /* actions */ actionsList, + /* num_actions */ XtNumber(actionsList), + /* resources */ resources, + /* resource_count */ XtNumber(resources), + /* xrm_class */ NULLQUARK, + /* compress_motion */ TRUE, + /* compress_exposure */ TRUE, + /* compress_enterleave */ TRUE, + /* visible_interest */ FALSE, + /* destroy */ Destroy, + /* resize */ NULL, + /* expose */ Redisplay, + /* set_values */ SetValues, + /* set_values_hook */ NULL, + /* set_values_almost */ XtInheritSetValuesAlmost, + /* get_values_hook */ NULL, + /* accept_focus */ NULL, + /* version */ XtVersion, + /* callback_private */ NULL, + /* tm_table */ defaultTranslations, + /* query_geometry */ XtInheritQueryGeometry, + /* display_accelerator */ XtInheritDisplayAccelerator, + /* extension */ NULL + }, + { /* simple fields */ + /* change_sensitive */ XtInheritChangeSensitive + }, + { /* mailbox fields */ + /* ignore */ 0 + } +}; + +WidgetClass mailboxWidgetClass = (WidgetClass) &mailboxClassRec; + + +/* + * widget initialization + */ + +static GC get_mailbox_gc (w) + MailboxWidget w; +{ + XtGCMask valuemask; + XGCValues xgcv; + + valuemask = GCForeground | GCBackground | GCFunction | GCGraphicsExposures; + xgcv.foreground = w->mailbox.foreground_pixel; + xgcv.background = w->core.background_pixel; + xgcv.function = GXcopy; + xgcv.graphics_exposures = False; /* this is Bool, not Boolean */ + return (XtGetGC ((Widget) w, valuemask, &xgcv)); +} + + +/* ARGSUSED */ +static void Initialize (request, new, args, num_args) + Widget request, new; + ArgList args; + Cardinal *num_args; +{ + MailboxWidget w = (MailboxWidget) new; + int shape_event_base, shape_error_base; + + if (w->core.width <= 0) w->core.width = 1; + if (w->core.height <= 0) w->core.height = 1; + + if (w->mailbox.shapeit && !XShapeQueryExtension (XtDisplay (w), + &shape_event_base, + &shape_error_base)) + w->mailbox.shapeit = False; + w->mailbox.shape_cache.mask = None; + w->mailbox.gc = get_mailbox_gc (w); + w->mailbox.interval_id = (XtIntervalId) 0; + w->mailbox.full.pixmap = None; + w->mailbox.empty.pixmap = None; + w->mailbox.flag_up = FALSE; + w->mailbox.last_size = 0; + if (!w->mailbox.filename) GetMailFile (w); + return; +} + + +/* + * action procedures + */ + +/* + * pretend there is new mail; put widget in flagup state + */ + +/* ARGSUSED */ +static void Set (gw, event, params, nparams) + Widget gw; + XEvent *event; + String *params; + Cardinal *nparams; +{ + MailboxWidget w = (MailboxWidget) gw; + + w->mailbox.last_size = -1; + + check_mailbox (w, TRUE, FALSE); /* redraw, no reset */ + + return; +} + + +/* + * ack the existing mail; put widget in flagdown state + */ + +/* ARGSUSED */ +static void Unset (gw, event, params, nparams) + Widget gw; + XEvent *event; + String *params; + Cardinal *nparams; +{ + MailboxWidget w = (MailboxWidget) gw; + + check_mailbox (w, TRUE, TRUE); /* redraw, reset */ + + return; +} + + +/* + * look to see if there is new mail; if so, Set, else Unset + */ + +/* ARGSUSED */ +static void Check (gw, event, params, nparams) + Widget gw; + XEvent *event; + String *params; + Cardinal *nparams; +{ + MailboxWidget w = (MailboxWidget) gw; + + check_mailbox (w, TRUE, FALSE); /* redraw, no reset */ + + return; +} + + +/* ARGSUSED */ +static void clock_tic (client_data, id) + XtPointer client_data; + XtIntervalId *id; +{ + MailboxWidget w = (MailboxWidget) client_data; + + check_mailbox (w, FALSE, FALSE); /* no redraw, no reset */ + + /* + * and reset the timer + */ + + w->mailbox.interval_id = + XtAppAddTimeOut (XtWidgetToApplicationContext((Widget) w), + w->mailbox.update * 1000, clock_tic, client_data); + + return; +} + +static Pixmap make_pixmap (dpy, w, bitmap, depth, flip, widthp, heightp) + Display *dpy; + MailboxWidget w; + Pixmap bitmap; + Boolean flip; + int depth; + int *widthp, *heightp; +{ + Window root; + int x, y; + unsigned int width, height, bw, dep; + unsigned long fore, back; + + if (!XGetGeometry (dpy, bitmap, &root, &x, &y, &width, &height, &bw, &dep)) + return None; + + *widthp = (int) width; + *heightp = (int) height; + if (flip) { + fore = w->core.background_pixel; + back = w->mailbox.foreground_pixel; + } else { + fore = w->mailbox.foreground_pixel; + back = w->core.background_pixel; + } + return XmuCreatePixmapFromBitmap (dpy, w->core.window, bitmap, + width, height, depth, fore, back); +} + +static void Realize (gw, valuemaskp, attr) + Widget gw; + XtValueMask *valuemaskp; + XSetWindowAttributes *attr; +{ + MailboxWidget w = (MailboxWidget) gw; + register Display *dpy = XtDisplay (w); + int depth = w->core.depth; + + *valuemaskp |= (CWBitGravity | CWCursor); + attr->bit_gravity = ForgetGravity; + attr->cursor = XCreateFontCursor (dpy, XC_top_left_arrow); + + (*mailboxWidgetClass->core_class.superclass->core_class.realize) + (gw, valuemaskp, attr); + + /* + * build up the pixmaps that we'll put into the image + */ + if (w->mailbox.full.bitmap == None) { + w->mailbox.full.bitmap = + XCreateBitmapFromData (dpy, w->core.window, (char *) mailfull_bits, + mailfull_width, mailfull_height); + } + if (w->mailbox.empty.bitmap == None) { + w->mailbox.empty.bitmap = + XCreateBitmapFromData (dpy, w->core.window, (char *) mailempty_bits, + mailempty_width, mailempty_height); + } + + w->mailbox.empty.pixmap = make_pixmap (dpy, w, w->mailbox.empty.bitmap, + depth, False, + &w->mailbox.empty.width, + &w->mailbox.empty.height); + w->mailbox.full.pixmap = make_pixmap (dpy, w, w->mailbox.full.bitmap, + depth, w->mailbox.flipit, + &w->mailbox.full.width, + &w->mailbox.full.height); + + if (w->mailbox.empty.mask == None && w->mailbox.full.mask == None) + w->mailbox.shapeit = False; + + w->mailbox.interval_id = + XtAppAddTimeOut (XtWidgetToApplicationContext((Widget) w), + w->mailbox.update * 1000, clock_tic, (XtPointer) w); + + w->mailbox.shape_cache.mask = None; + + check_mailbox (w, TRUE, FALSE); + + return; +} + + +static void Destroy (gw) + Widget gw; +{ + MailboxWidget w = (MailboxWidget) gw; + Display *dpy = XtDisplay (gw); + + XtFree (w->mailbox.filename); + if (w->mailbox.interval_id) XtRemoveTimeOut (w->mailbox.interval_id); + XtReleaseGC(gw, w->mailbox.gc); +#define freepix(p) if (p) XFreePixmap (dpy, p) + freepix (w->mailbox.full.bitmap); /* until cvter does ref cnt */ + freepix (w->mailbox.full.mask); /* until cvter does ref cnt */ + freepix (w->mailbox.full.pixmap); + freepix (w->mailbox.empty.bitmap); /* until cvter does ref cnt */ + freepix (w->mailbox.empty.mask); /* until cvter does ref cnt */ + freepix (w->mailbox.empty.pixmap); + freepix (w->mailbox.shape_cache.mask); +#undef freepix + return; +} + + +static void Redisplay (gw, event, region) + Widget gw; + XEvent *event; + Region region; +{ + MailboxWidget w = (MailboxWidget) gw; + + check_mailbox (w, TRUE, FALSE); +} + + +static void check_mailbox (w, force_redraw, reset) + MailboxWidget w; + Boolean force_redraw, reset; +{ + long mailboxsize = 0; + Boolean readSinceLastWrite = FALSE; + + if (w->mailbox.check_command != NULL) { + waitType wait_status; + int check_status; +#ifdef INTWAITTYPE + wait_status = system(w->mailbox.check_command); +#else + wait_status.w_status = system(w->mailbox.check_command); +#endif + check_status = waitCode(wait_status); + + /* error in sh checkCommand execution */ + if (waitSig(wait_status)) + check_status = 2; /* act as if there is no mail */ + + switch (check_status) { + case 0: + mailboxsize = w->mailbox.last_size + 1; + break; + case 2: + mailboxsize = 0; + break; + default: /* treat everything else as no change */ + /* case 1 is no change */ + mailboxsize = w->mailbox.last_size; + } + } else { + struct stat st; + if (stat (w->mailbox.filename, &st) == 0) { + mailboxsize = st.st_size; + readSinceLastWrite = (st.st_atime > st.st_mtime); + } + } + + /* + * Now check for changes. If reset is set then we want to pretent that + * there is no mail. If the mailbox is empty then we want to turn off + * the flag. Otherwise if the mailbox has changed size then we want to + * put the flag up, unless the mailbox has been read since the last + * write. + * + * The cases are: + * o forced reset by user DOWN + * o no mailbox or empty (zero-sized) mailbox DOWN + * o if read after most recent write DOWN + * o same size as last time no change + * o bigger than last time UP + * o smaller than last time but non-zero UP + * + * The last two cases can be expressed as different from last + * time and non-zero. + */ + + if (reset) { /* forced reset */ + w->mailbox.flag_up = FALSE; + force_redraw = TRUE; + } else if (mailboxsize == 0) { /* no mailbox or empty */ + w->mailbox.flag_up = FALSE; + if (w->mailbox.last_size > 0) force_redraw = TRUE; /* if change */ + } else if (readSinceLastWrite) { /* only when checkCommand is NULL */ + /* mailbox has been read after most recent write */ + if (w->mailbox.flag_up) { + w->mailbox.flag_up = FALSE; + force_redraw = TRUE; + } + } else if (mailboxsize != w->mailbox.last_size) { /* different size */ + if (!w->mailbox.once_only || !w->mailbox.flag_up) + beep(w); + if (!w->mailbox.flag_up) + force_redraw = w->mailbox.flag_up = TRUE; + } + + w->mailbox.last_size = mailboxsize; + if (force_redraw) redraw_mailbox (w); + return; +} + +/* + * get user name for building mailbox + */ + +static void GetMailFile (w) + MailboxWidget w; +{ + char *username; + char *mailpath; +#ifdef WIN32 + if (!(username = getenv("USERNAME"))) { + fprintf (stderr, "%s: unable to find a username for you.\n", + "Mailbox widget"); + CloseDown (w, 1); + } +#else + char *getlogin(); + + username = getlogin (); + if (!username) { + struct passwd *pw = getpwuid (getuid ()); + + if (!pw) { + fprintf (stderr, "%s: unable to find a username for you.\n", + "Mailbox widget"); + CloseDown (w, 1); + } + username = pw->pw_name; + } +#endif + if ((mailpath = getenv("MAIL"))) { + w->mailbox.filename = (String) XtMalloc (strlen (mailpath) + 1); + strcpy (w->mailbox.filename, mailpath); + } else { + w->mailbox.filename = (String) XtMalloc (strlen (MAILBOX_DIRECTORY) + 1 + + strlen (username) + 1); + strcpy (w->mailbox.filename, MAILBOX_DIRECTORY); + strcat (w->mailbox.filename, "/"); + strcat (w->mailbox.filename, username); + } + return; +} + +static void CloseDown (w, status) + MailboxWidget w; + int status; +{ + Display *dpy = XtDisplay (w); + + XtDestroyWidget ((Widget)w); + XCloseDisplay (dpy); + exit (status); +} + + +/* ARGSUSED */ +static Boolean SetValues (gcurrent, grequest, gnew, args, num_args) + Widget gcurrent, grequest, gnew; + ArgList args; + Cardinal *num_args; +{ + MailboxWidget current = (MailboxWidget) gcurrent; + MailboxWidget new = (MailboxWidget) gnew; + Boolean redisplay = FALSE; + + if (current->mailbox.update != new->mailbox.update) { + if (current->mailbox.interval_id) + XtRemoveTimeOut (current->mailbox.interval_id); + new->mailbox.interval_id = + XtAppAddTimeOut (XtWidgetToApplicationContext(gnew), + new->mailbox.update * 1000, clock_tic, + (XtPointer) gnew); + } + + if (current->mailbox.foreground_pixel != new->mailbox.foreground_pixel || + current->core.background_pixel != new->core.background_pixel) { + XtReleaseGC (gcurrent, current->mailbox.gc); + new->mailbox.gc = get_mailbox_gc (new); + redisplay = TRUE; + } + + return (redisplay); +} + + +/* + * drawing code + */ + +static void redraw_mailbox (w) + MailboxWidget w; +{ + register Display *dpy = XtDisplay (w); + register Window win = XtWindow (w); + register int x, y; + GC gc = w->mailbox.gc; + Pixel back = w->core.background_pixel; + struct _mbimage *im; + + /* center the picture in the window */ + + if (w->mailbox.flag_up) { /* paint the "up" position */ + im = &w->mailbox.full; + if (w->mailbox.flipit) back = w->mailbox.foreground_pixel; + } else { /* paint the "down" position */ + im = &w->mailbox.empty; + } + x = (((int)w->core.width) - im->width) / 2; + y = (((int)w->core.height) - im->height) / 2; + + XSetWindowBackground (dpy, win, back); + XClearWindow (dpy, win); + XCopyArea (dpy, im->pixmap, win, gc, 0, 0, im->width, im->height, x, y); + + /* + * XXX - temporary hack; walk up widget tree to find top most parent (which + * will be a shell) and mash it to have our shape. This will be replaced + * by a special shell widget. + */ + if (w->mailbox.shapeit) { + Widget parent; + + for (parent = (Widget) w; XtParent(parent); + parent = XtParent(parent)) { + x += parent->core.x + parent->core.border_width; + y += parent->core.y + parent->core.border_width; + } + + if (im->mask != w->mailbox.shape_cache.mask || + x != w->mailbox.shape_cache.x || y != w->mailbox.shape_cache.y) { + XShapeCombineMask (XtDisplay(parent), XtWindow(parent), + ShapeBounding, x, y, im->mask, ShapeSet); + w->mailbox.shape_cache.mask = im->mask; + w->mailbox.shape_cache.x = x; + w->mailbox.shape_cache.y = y; + } + } + + return; +} + + +static void beep (w) + MailboxWidget w; +{ + XBell (XtDisplay (w), w->mailbox.volume); + return; +} diff --git a/Mailbox.h b/Mailbox.h new file mode 100644 index 0000000..dc7f1eb --- /dev/null +++ b/Mailbox.h @@ -0,0 +1,74 @@ +/* $XConsortium: Mailbox.h,v 1.21 94/04/17 20:43:27 rws Exp $ */ +/* + +Copyright (c) 1988 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ + +#ifndef _XawMailbox_h +#define _XawMailbox_h + +/* + * Mailbox widget; looks a lot like the clock widget, don't it... + */ + +/* resource names used by mailbox widget that aren't defined in StringDefs.h */ + +#ifndef _XtStringDefs_h_ +#define XtNupdate "update" +#endif + +/* command to exec */ +#define XtNcheckCommand "checkCommand" +#define XtNonceOnly "onceOnly" + +/* Int: volume for bell */ +#define XtNvolume "volume" +#define XtNfullPixmap "fullPixmap" +#define XtNfullPixmapMask "fullPixmapMask" +#define XtNemptyPixmap "emptyPixmap" +#define XtNemptyPixmapMask "emptyPixmapMask" +#define XtNflip "flip" +#define XtNshapeWindow "shapeWindow" + +#define XtCCheckCommand "CheckCommand" +#define XtCVolume "Volume" +#define XtCPixmapMask "PixmapMask" +#define XtCFlip "Flip" +#define XtCShapeWindow "ShapeWindow" + + +/* structures */ + +typedef struct _MailboxRec *MailboxWidget; /* see MailboxP.h */ +typedef struct _MailboxClassRec *MailboxWidgetClass; /* see MailboxP.h */ + + +extern WidgetClass mailboxWidgetClass; + +#endif /* _XawMailbox_h */ +/* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/MailboxP.h b/MailboxP.h new file mode 100644 index 0000000..c95d241 --- /dev/null +++ b/MailboxP.h @@ -0,0 +1,101 @@ +/* $XConsortium: MailboxP.h,v 1.22 94/04/17 20:43:27 rws Exp $ */ +/* + +Copyright (c) 1988 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ +/* $XFree86: xc/programs/xbiff/MailboxP.h,v 1.2 2001/04/19 19:54:51 dawes Exp $ */ + +#ifndef _XawMailboxP_h +#define _XawMailboxP_h + +#include "Mailbox.h" +#include <X11/Xaw/SimpleP.h> + +#if defined(SYSV) +#define MAILBOX_DIRECTORY "/usr/mail" +#elif defined(SVR4) +#define MAILBOX_DIRECTORY "/var/mail" +#elif defined(CSRG_BASED) +#include <paths.h> +#ifdef _PATH_MAILDIR +#define MAILBOX_DIRECTORY _PATH_MAILDIR +#endif +#elif defined(__linux__) +#define MAILBOX_DIRECTORY "/var/spool/mail" +#endif + +#ifndef MAILBOX_DIRECTORY +#define MAILBOX_DIRECTORY "/usr/spool/mail" +#endif + +typedef struct { /* new fields for mailbox widget */ + /* resources */ + int update; /* seconds between updates */ + Pixel foreground_pixel; /* color index of normal state fg */ + String filename; /* filename to watch */ + String check_command; /* command to exec for mail check */ + Boolean flipit; /* do flip of full pixmap */ + int volume; /* bell volume */ + Boolean once_only; /* ring bell only once on new mail */ + /* local state */ + GC gc; /* normal GC to use */ + long last_size; /* size in bytes of mailboxname */ + XtIntervalId interval_id; /* time between checks */ + Boolean flag_up; /* is the flag up? */ + struct _mbimage { + Pixmap bitmap, mask; /* depth 1, describing shape */ + Pixmap pixmap; /* full depth pixmap */ + int width, height; /* geometry of pixmaps */ + } full, empty; + Boolean shapeit; /* do shape extension */ + struct { + Pixmap mask; + int x, y; + } shape_cache; /* last set of info */ +} MailboxPart; + +typedef struct _MailboxRec { /* full instance record */ + CorePart core; + SimplePart simple; + MailboxPart mailbox; +} MailboxRec; + + +typedef struct { /* new fields for mailbox class */ + int dummy; /* stupid C compiler */ +} MailboxClassPart; + +typedef struct _MailboxClassRec { /* full class record declaration */ + CoreClassPart core_class; + SimpleClassPart simple_class; + MailboxClassPart mailbox_class; +} MailboxClassRec; + +extern MailboxClassRec mailboxClassRec; /* class pointer */ + +#endif /* _XawMailboxP_h */ diff --git a/bitmaps/mail-down b/bitmaps/mail-down new file mode 100644 index 0000000..9d8a59d --- /dev/null +++ b/bitmaps/mail-down @@ -0,0 +1,27 @@ +#define mail_down_width 48 +#define mail_down_height 48 +static char mail_down_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/bitmaps/mail-down-mask b/bitmaps/mail-down-mask new file mode 100644 index 0000000..5f5a62f --- /dev/null +++ b/bitmaps/mail-down-mask @@ -0,0 +1,29 @@ +#define mail_down_mask_width 48 +#define mail_down_mask_height 48 +#define mail_down_mask_x_hot -1 +#define mail_down_mask_y_hot -1 +static char mail_down_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/bitmaps/mail-up b/bitmaps/mail-up new file mode 100644 index 0000000..2aabbdd --- /dev/null +++ b/bitmaps/mail-up @@ -0,0 +1,27 @@ +#define mail_up_width 48 +#define mail_up_height 48 +static char mail_up_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, + 0x00, 0xfa, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, + 0x00, 0x3a, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2e, + 0xe0, 0xff, 0xff, 0xff, 0xff, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x21, + 0xa0, 0x03, 0x00, 0x00, 0x70, 0x21, 0x20, 0x00, 0x00, 0x00, 0x50, 0x21, + 0xa0, 0x1f, 0x00, 0x00, 0x50, 0x21, 0x20, 0x00, 0x00, 0x00, 0x70, 0x21, + 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21, + 0xfa, 0x01, 0x00, 0x80, 0x0b, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0a, 0x21, + 0xba, 0x01, 0x00, 0x80, 0x0a, 0x21, 0x02, 0x00, 0x00, 0x80, 0x0b, 0x21, + 0x3a, 0x00, 0x00, 0x00, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x21, + 0x02, 0xc0, 0xfb, 0x03, 0x08, 0x21, 0x02, 0x00, 0x00, 0x00, 0x08, 0x3f, + 0x02, 0xc0, 0xbd, 0x0f, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, + 0x02, 0xc0, 0x7f, 0x7b, 0x08, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x01, + 0x02, 0x00, 0x00, 0x00, 0xf8, 0x01, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, + 0xfe, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/bitmaps/mail-up-mask b/bitmaps/mail-up-mask new file mode 100644 index 0000000..002e54e --- /dev/null +++ b/bitmaps/mail-up-mask @@ -0,0 +1,29 @@ +#define mail_up_mask_width 48 +#define mail_up_mask_height 48 +#define mail_up_mask_x_hot -1 +#define mail_up_mask_y_hot -1 +static char mail_up_mask_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xf0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xf0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xf0, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, + 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; @@ -0,0 +1,129 @@ +/* $XConsortium: xbiff.c,v 1.19 94/04/17 20:43:28 rws Exp $ */ +/* + +Copyright (c) 1988 X Consortium + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of the X Consortium shall +not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization +from the X Consortium. + +*/ +/* $XFree86: xc/programs/xbiff/xbiff.c,v 1.3 2000/02/17 14:00:34 dawes Exp $ */ + +#include <stdio.h> +#include <stdlib.h> +#include <X11/Xatom.h> +#include <X11/Intrinsic.h> +#include <X11/StringDefs.h> +#include "Mailbox.h" +#include <X11/Xaw/Cardinals.h> + +const char *ProgramName; + +static XrmOptionDescRec options[] = { +{ "-update", "*mailbox.update", XrmoptionSepArg, (caddr_t) NULL }, +{ "-file", "*mailbox.file", XrmoptionSepArg, (caddr_t) NULL }, +{ "-volume", "*mailbox.volume", XrmoptionSepArg, (caddr_t) NULL }, +{ "-shape", "*mailbox.shapeWindow", XrmoptionNoArg, (caddr_t) "on" }, +}; + +static Atom wm_delete_window; + +static void quit (w, event, params, num_params) + Widget w; + XEvent *event; + String *params; + Cardinal *num_params; +{ + if (event->type == ClientMessage && + event->xclient.data.l[0] != wm_delete_window) { + XBell (XtDisplay(w), 0); + return; + } + XCloseDisplay (XtDisplay(w)); + exit (0); +} + +static XtActionsRec xbiff_actions[] = { + { "quit", quit }, +}; + +static void Usage () +{ + static const char *help_message[] = { +"where options include:", +" -display host:dpy X server to contact", +" -geometry geom size of mailbox", +" -file file file to watch", +" -update seconds how often to check for mail", +" -volume percentage how loud to ring the bell", +" -bg color background color", +" -fg color foreground color", +" -rv reverse video", +" -shape shape the window", +NULL}; + const char **cpp; + + fprintf (stderr, "usage: %s [-options ...]\n", ProgramName); + for (cpp = help_message; *cpp; cpp++) + fprintf (stderr, "%s\n", *cpp); + fprintf (stderr, "\n"); + exit (1); +} + + +int +main (argc, argv) + int argc; + char **argv; +{ + XtAppContext xtcontext; + Widget toplevel, w; + + ProgramName = argv[0]; + + XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); + + toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options), + &argc, argv, NULL, NULL, 0); + if (argc != 1) Usage (); + + /* + * This is a hack so that f.delete will do something useful in this + * single-window application. + */ + wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW", + False); + XtAppAddActions (xtcontext, xbiff_actions, XtNumber(xbiff_actions)); + XtOverrideTranslations(toplevel, + XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()")); + + w = XtCreateManagedWidget ("mailbox", mailboxWidgetClass, toplevel, + NULL, 0); + XtRealizeWidget (toplevel); + (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), + &wm_delete_window, 1); + XtAppMainLoop (xtcontext); + + return 0; +} diff --git a/xbiff.man b/xbiff.man new file mode 100644 index 0000000..c000d6d --- /dev/null +++ b/xbiff.man @@ -0,0 +1,216 @@ +.\" $XConsortium: xbiff.man,v 1.22 94/04/17 20:43:28 gildea Exp $ +.\" Copyright (c) 1988 X Consortium +.\" +.\" Permission is hereby granted, free of charge, to any person obtaining +.\" a copy of this software and associated documentation files (the +.\" "Software"), to deal in the Software without restriction, including +.\" without limitation the rights to use, copy, modify, merge, publish, +.\" distribute, sublicense, and/or sell copies of the Software, and to +.\" permit persons to whom the Software is furnished to do so, subject to +.\" the following conditions: +.\" +.\" The above copyright notice and this permission notice shall be included +.\" in all copies or substantial portions of the Software. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR +.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +.\" OTHER DEALINGS IN THE SOFTWARE. +.\" +.\" Except as contained in this notice, the name of the X Consortium shall +.\" not be used in advertising or otherwise to promote the sale, use or +.\" other dealings in this Software without prior written authorization +.\" from the X Consortium. +.\" +.\" $XFree86: xc/programs/xbiff/xbiff.man,v 1.4 2001/04/19 19:54:51 dawes Exp $ +.\" +.TH XBIFF 1 __xorgversion__ +.SH NAME +xbiff \- mailbox flag for X +.SH SYNOPSIS +.B xbiff +[ \-\fItoolkitoption\fP ... ] [ \fI\-option\fP ... ] +.SH DESCRIPTION +The +.I xbiff +program displays a little image of a mailbox. When there is no mail, +the flag on the mailbox is down. When mail arrives, the flag goes up +and the mailbox beeps. By default, pressing any mouse button in the +image forces \fIxbiff\fP to remember the current size of the mail file +as being the ``empty'' size and to lower the flag. +.SH OPTIONS +.I Xbiff +accepts all of the standard X Toolkit command line options along with the +additional options listed below: +.TP 8 +.B \-help +This option indicates that a brief summary of the allowed options should be +printed on the standard error. +.TP 8 +.B \-update \fIseconds\fP +This option specifies the frequency in seconds at which \fIxbiff\fP +should update its display. If the mailbox is obscured and then exposed, +it will be updated immediately. The default is 30 seconds. +.TP 8 +.B \-file \fIfilename\fP +This option specifies the name of the file which should be monitored. By +default it watches your inbox in the default location for your +system (some examples are +.RI /var/mail/ username , +.RI /usr/spool/mail/ username , +.RI /var/spool/mail/ username +(where +.I username +is your login name). If the MAIL environment variable is set, +the file specified by it will be monitored. +.TP 8 +.B \-volume \fIpercentage\fP +This option specifies how loud the bell should be rung when new mail comes in. +.TP 8 +.B \-shape +This option indicates that the mailbox window should be shaped if masks for +the empty or full images are given. +.PP +The following standard X Toolkit command line arguments are commonly used with +.I xbiff: +.TP 8 +.B \-display \fIdisplay\fP +This option specifies the X server to contact. +.TP 8 +.B \-geometry \fIgeometry\fP +This option specifies the preferred size and position of the mailbox window. +The mailbox is 48 pixels wide and 48 pixels high and will be centered in +the window. +.TP 8 +.B \-bg \fIcolor\fP +This option specifies the color to use for the background of the window. +.TP 8 +.B \-bd \fIcolor\fP +This option specifies the color to use for the border of the window. +.TP 8 +.B \-bw \fInumber\fP +This option specifies the width in pixels of the border surrounding the window. +.TP 8 +.B \-fg \fIcolor\fP +This option specifies the color to use for the foreground of the window. +.TP 8 +.B \-rv +This option indicates that reverse video should be simulated by swapping +the foreground and background colors. +.TP 8 +.B \-xrm \fIresourcestring\fP +This option specifies a resource string to be used. This is especially +useful for setting resources that do not have separate command line options. +.SH X DEFAULTS +The application class name is XBiff. +This program uses the +.I Mailbox +widget. +It understands all of the core resource names and +classes as well as: +.PP +.TP 8 +.B checkCommand (\fPclass\fB CheckCommand) +Specifies a shell command to be executed to check for new mail rather than +examining the size of \fBfile\fP. The specified string value is used as the +argument to a \fIsystem\fP(3) call and may therefore contain i/o redirection. +An exit status of 0 indicates that new mail is waiting, 1 indicates that there +has been no change in size, and 2 indicates that the mail has been cleared. +By default, no shell command is provided. +.TP 8 +.B file (\fPclass\fB File) +Specifies the name of the file to monitor. The default is as described +above for the +.B \-file +command line option. +.TP 8 +.B onceOnly (\fPclass\fB Boolean) +Specifies that the bell is only rung the first time new mail is found +and is not rung again until at least one interval has passed with +no mail waiting. The window will continue to indicate the presence +of new mail until it has been retrieved. The default is false. +.TP 8 +.B width (\fPclass\fB Width) +Specifies the width of the mailbox. +.TP 8 +.B height (\fPclass\fB Height) +Specifies the height of the mailbox. +.TP 8 +.B update (\fPclass\fB Interval) +Specifies the frequency in seconds at which the mail should be checked. +The default is 30. +.TP 8 +.B volume (\fPclass\fB Volume) +Specifies how loud the bell should be rung. The default is 33 percent. +.TP 8 +.B foreground (\fPclass\fB Foreground) +Specifies the color for the foreground. +.TP 8 +.B reverseVideo (\fPclass\fB ReverseVideo) +Specifies that the foreground and background should be reversed. +.TP 8 +.B flip (\fPclass\fB Flip) +Specifies whether or not the image that is shown when mail has arrived +should be inverted. The default is ``true.'' +.TP 8 +.B fullPixmap (\fPclass\fB Pixmap) +Specifies a bitmap to be shown when new mail has arrived. +The default is flagup. +.TP 8 +.B emptyPixmap (\fPclass\fB Pixmap) +Specifies a bitmap to be shown when no new mail is present. +The default is flagdown. +.TP 8 +.B shapeWindow (\fPclass\fB ShapeWindow) +Specifies whether or not the mailbox window should be shaped to the +given fullPixmapMask and emptyPixmapMask. The default is false. +.TP 8 +.B fullPixmapMask (\fPclass\fB PixmapMask) +Specifies a mask for the bitmap to be shown when new mail has arrived. +The default is none. +.TP 8 +.B emptyPixmapMask (\fPclass\fB PixmapMask) +Specifies a mask for the bitmap to be shown when no new mail is present. +The default is none. +.SH ACTIONS +The \fIMailbox\fP widget provides the following actions for use in event +translations: +.TP 8 +.B check() +This action causes the widget to check for new mail and display the flag +appropriately. +.TP 8 +.B unset() +This action causes the widget to lower the flag until new mail comes in. +.TP 8 +.B set() +This action causes the widget to raise the flag until the user resets it. +.PP +The default translation is +.sp +.nf + <ButtonPress>: unset() +.fi +.sp +.SH ENVIRONMENT +.PP +.TP 8 +.B DISPLAY +to get the default host and display number. +.TP 8 +.B XENVIRONMENT +to get the name of a resource file that overrides the global resources +stored in the RESOURCE_MANAGER property. +.SH "SEE ALSO" +X(__miscmansuffix__), +xrdb(1), +stat(2) +.SH BUGS +The mailbox bitmaps are ugly. +.SH AUTHOR +Jim Fulton, MIT X Consortium +.br +Additional hacks by Ralph Swick, DEC/MIT Project Athena |