#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;
ProgramName = argv[0];
XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL);
toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options),
&argc, argv, NULL, NULL, 0);
if (argc != 1) Usage ();
wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW",
False);
XtAppAddActions (xtcontext, xbiff_actions, XtNumber(xbiff_actions));
XtOverrideTranslations(toplevel,
XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));
(void) XtCreateManagedWidget ("mailbox", mailboxWidgetClass, toplevel,
NULL, 0);
XtRealizeWidget (toplevel);
(void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
&wm_delete_window, 1);
XtAppMainLoop (xtcontext);
return 0;
}