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