home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / motifpg2.zip / ch02 / xgoodbye.c < prev    next >
C/C++ Source or Header  |  1992-07-08  |  2KB  |  73 lines

  1. /*
  2.  * Copyright 1989, 1992 O'Reilly and Associates, Inc.
  3.  * See ../Copyright for complete rights and liability information.
  4.  */
  5.  
  6. /*
  7.  * xgoodbye.c - simple program to put up a banner on the display
  8.  *      and callback an application function.
  9.  */
  10.  
  11. #include <stdio.h>
  12. /*
  13.  * Include files required for all Toolkit programs
  14.  */
  15. #include <X11/Intrinsic.h>  /* Intrinsics Definitions */
  16. #include <Xm/Xm.h>  /* Standard Motif definitions */
  17.  
  18. /*
  19.  * Public include file for widgets we actually use in this file.
  20.  */
  21. #include <Xm/PushB.h>    /* Motif PushButton Widget */
  22.  
  23. /*
  24.  * Quit button callback function
  25.  */
  26. /* ARGSUSED */
  27. void Quit(w, client_data, call_data)
  28. Widget w;
  29. XtPointer client_data, call_data;
  30.     fprintf(stderr, "It was nice knowing you.\n");
  31.     exit(0); 
  32. }
  33.  
  34. main(argc, argv)
  35. int argc;
  36. char **argv;
  37. {
  38.     XtAppContext app_context;
  39.     Widget topLevel, goodbye;
  40.  
  41.     /*
  42.      * Register the default language procedure
  43.      */
  44.     XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
  45.  
  46.     topLevel = XtVaAppInitialize(
  47.             &app_context,           /* Application context */
  48.             "XGoodbye",             /* Application class */
  49.             NULL, 0,                /* command line option list */
  50.             &argc, argv,            /* command line args */
  51.             NULL,                   /* for missing app-defaults file */
  52.             NULL);                  /* terminate varargs list */
  53.  
  54.     goodbye = XtVaCreateManagedWidget(
  55.             "goodbye",              /* arbitrary widget name */
  56.             xmPushButtonWidgetClass,     /* widget class from PushB.h */
  57.             topLevel,               /* parent widget*/
  58.             NULL);                  /* terminate varargs list */
  59.         
  60.     XtAddCallback(goodbye, XmNactivateCallback, Quit, 0 /* client_data */);
  61.  
  62.     /*
  63.      *  Create windows for widgets and map them.
  64.      */
  65.     XtRealizeWidget(topLevel);
  66.  
  67.     /*
  68.      *  Loop for events.
  69.      */
  70.     XtAppMainLoop(app_context);
  71. }
  72.