xbiff.c revision a39bb051
1c19de146Smrg/* $XConsortium: xbiff.c,v 1.19 94/04/17 20:43:28 rws Exp $ */ 2c19de146Smrg/* 3c19de146Smrg 4c19de146SmrgCopyright (c) 1988 X Consortium 5c19de146Smrg 6c19de146SmrgPermission is hereby granted, free of charge, to any person obtaining 7c19de146Smrga copy of this software and associated documentation files (the 8c19de146Smrg"Software"), to deal in the Software without restriction, including 9c19de146Smrgwithout limitation the rights to use, copy, modify, merge, publish, 10c19de146Smrgdistribute, sublicense, and/or sell copies of the Software, and to 11c19de146Smrgpermit persons to whom the Software is furnished to do so, subject to 12c19de146Smrgthe following conditions: 13c19de146Smrg 14c19de146SmrgThe above copyright notice and this permission notice shall be included 15c19de146Smrgin all copies or substantial portions of the Software. 16c19de146Smrg 17c19de146SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18c19de146SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19c19de146SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20c19de146SmrgIN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 21c19de146SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 22c19de146SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23c19de146SmrgOTHER DEALINGS IN THE SOFTWARE. 24c19de146Smrg 25c19de146SmrgExcept as contained in this notice, the name of the X Consortium shall 26c19de146Smrgnot be used in advertising or otherwise to promote the sale, use or 27c19de146Smrgother dealings in this Software without prior written authorization 28c19de146Smrgfrom the X Consortium. 29c19de146Smrg 30c19de146Smrg*/ 31c19de146Smrg/* $XFree86: xc/programs/xbiff/xbiff.c,v 1.3tsi Exp $ */ 32c19de146Smrg 33c19de146Smrg#include <stdio.h> 34c19de146Smrg#include <stdlib.h> 35c19de146Smrg#include <X11/Xatom.h> 36c19de146Smrg#include <X11/Intrinsic.h> 37c19de146Smrg#include <X11/StringDefs.h> 38c19de146Smrg#include "Mailbox.h" 39c19de146Smrg#include <X11/Xaw/Cardinals.h> 40c19de146Smrg 419ef7378bSmrgstatic const char *ProgramName; 42c19de146Smrg 43c19de146Smrgstatic XrmOptionDescRec options[] = { 44c19de146Smrg{ "-update", "*mailbox.update", XrmoptionSepArg, (caddr_t) NULL }, 45c19de146Smrg{ "-file", "*mailbox.file", XrmoptionSepArg, (caddr_t) NULL }, 46c19de146Smrg{ "-volume", "*mailbox.volume", XrmoptionSepArg, (caddr_t) NULL }, 47c19de146Smrg{ "-shape", "*mailbox.shapeWindow", XrmoptionNoArg, (caddr_t) "on" }, 48c19de146Smrg}; 49c19de146Smrg 50c19de146Smrgstatic Atom wm_delete_window; 51c19de146Smrg 529ef7378bSmrgstatic void quit (Widget w, XEvent *event, String *params, Cardinal *num_params) 53c19de146Smrg{ 54c19de146Smrg if (event->type == ClientMessage && 55a39bb051Smrg ((Atom) event->xclient.data.l[0]) != wm_delete_window) { 56c19de146Smrg XBell (XtDisplay(w), 0); 57c19de146Smrg return; 58c19de146Smrg } 59c19de146Smrg XCloseDisplay (XtDisplay(w)); 60c19de146Smrg exit (0); 61c19de146Smrg} 62c19de146Smrg 63c19de146Smrgstatic XtActionsRec xbiff_actions[] = { 64c19de146Smrg { "quit", quit }, 65c19de146Smrg}; 66c19de146Smrg 679ef7378bSmrgstatic void Usage (void) 68c19de146Smrg{ 69c19de146Smrg static const char *help_message[] = { 70c19de146Smrg"where options include:", 71c19de146Smrg" -display host:dpy X server to contact", 72c19de146Smrg" -geometry geom size of mailbox", 73c19de146Smrg" -file file file to watch", 74c19de146Smrg" -update seconds how often to check for mail", 75c19de146Smrg" -volume percentage how loud to ring the bell", 76c19de146Smrg" -bg color background color", 77c19de146Smrg" -fg color foreground color", 78c19de146Smrg" -rv reverse video", 79c19de146Smrg" -shape shape the window", 80c19de146SmrgNULL}; 81c19de146Smrg const char **cpp; 82c19de146Smrg 83c19de146Smrg fprintf (stderr, "usage: %s [-options ...]\n", ProgramName); 84c19de146Smrg for (cpp = help_message; *cpp; cpp++) 85c19de146Smrg fprintf (stderr, "%s\n", *cpp); 86c19de146Smrg fprintf (stderr, "\n"); 87c19de146Smrg exit (1); 88c19de146Smrg} 89c19de146Smrg 90c19de146Smrg 91c19de146Smrgint 929ef7378bSmrgmain (int argc, char **argv) 93c19de146Smrg{ 94c19de146Smrg XtAppContext xtcontext; 95c19de146Smrg Widget toplevel; 96c19de146Smrg 97c19de146Smrg ProgramName = argv[0]; 98c19de146Smrg 99c19de146Smrg XtSetLanguageProc(NULL, (XtLanguageProc) NULL, NULL); 100c19de146Smrg 101c19de146Smrg toplevel = XtAppInitialize(&xtcontext, "XBiff", options, XtNumber (options), 102c19de146Smrg &argc, argv, NULL, NULL, 0); 103c19de146Smrg if (argc != 1) Usage (); 104c19de146Smrg 105c19de146Smrg /* 106c19de146Smrg * This is a hack so that f.delete will do something useful in this 107c19de146Smrg * single-window application. 108c19de146Smrg */ 109c19de146Smrg wm_delete_window = XInternAtom (XtDisplay(toplevel), "WM_DELETE_WINDOW", 110c19de146Smrg False); 111c19de146Smrg XtAppAddActions (xtcontext, xbiff_actions, XtNumber(xbiff_actions)); 112c19de146Smrg XtOverrideTranslations(toplevel, 113c19de146Smrg XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()")); 114c19de146Smrg 115c19de146Smrg (void) XtCreateManagedWidget ("mailbox", mailboxWidgetClass, toplevel, 116c19de146Smrg NULL, 0); 117c19de146Smrg XtRealizeWidget (toplevel); 118c19de146Smrg (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel), 119c19de146Smrg &wm_delete_window, 1); 120c19de146Smrg XtAppMainLoop (xtcontext); 121c19de146Smrg 122c19de146Smrg return 0; 123c19de146Smrg} 124