home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / clients / editres / editres.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-08  |  4.1 KB  |  135 lines

  1. /*
  2.  * $XConsortium: editres.c,v 1.13 91/07/08 11:54:32 rws Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <X11/Intrinsic.h>
  26. #include <X11/StringDefs.h>
  27.  
  28. #include <X11/Xaw/Cardinals.h>    
  29.  
  30. #define THIS_IS_MAIN        /* Don't get extern definitions of global
  31.                    variables. */
  32.  
  33. #include "editresP.h"
  34.  
  35. /*
  36.  * Global variables. 
  37.  */
  38.  
  39. int global_error_code;
  40. unsigned long global_serial_num;
  41. int (*global_old_error_handler)();
  42.  
  43. Boolean global_resource_box_up = FALSE;
  44. TreeInfo *global_tree_info = NULL;
  45. CurrentClient global_client;
  46. ScreenData global_screen_data;
  47. Widget global_tree_parent;
  48. AppResources global_resources;
  49.  
  50. extern void InternAtoms(), SetMessage(), BuildWidgetTree();
  51. extern void SetApplicationActions();
  52.  
  53. static void Syntax();
  54.  
  55. String fallback_resources[] = { 
  56.     NULL,
  57. };
  58.  
  59. #define Offset(field) (XtOffsetOf(AppResources, field))
  60.  
  61. static XtResource editres_resources[] = {
  62.   {"debug", "Debug", XtRBoolean, sizeof(Boolean),
  63.      Offset(debug), XtRImmediate, (XtPointer) FALSE},
  64.   {"numFlashes", "NumFlashes", XtRInt, sizeof(int),
  65.      Offset(num_flashes), XtRImmediate, (XtPointer) NUM_FLASHES},       
  66.   {"flashTime", "FlashTime", XtRInt, sizeof(int),
  67.      Offset(flash_time), XtRImmediate, (XtPointer) FLASH_TIME},       
  68.   {"flashColor", XtCForeground, XtRPixel, sizeof(Pixel),
  69.      Offset(flash_color), XtRImmediate, (XtPointer) XtDefaultForeground},
  70.   {"saveResourceFile", "SaveResourcesFile", XtRString, sizeof(String),
  71.      Offset(save_resources_file), XtRString, (XtPointer) ""},
  72. };
  73.  
  74. Atom wm_delete_window;
  75. Widget toplevel;
  76.  
  77. void
  78. main(argc, argv)
  79. int argc;
  80. char **argv;
  81. {
  82.     XtAppContext app_con;
  83.  
  84.     toplevel = XtAppInitialize(&app_con, "Editres", NULL, ZERO,
  85.                    &argc, argv, fallback_resources,
  86.                    NULL, ZERO);
  87.  
  88.     if (argc != 1)        
  89.     Syntax(app_con, argv[0]);
  90.  
  91.     SetApplicationActions(app_con);
  92.     XtGetApplicationResources(toplevel, (caddr_t) &global_resources, 
  93.                   editres_resources, XtNumber(editres_resources),
  94.                   NULL, (Cardinal) 0);
  95.     global_resources.allocated_save_resources_file = FALSE;
  96.  
  97.     XtOverrideTranslations
  98.       (toplevel, XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()"));  
  99.  
  100.     BuildWidgetTree(toplevel);
  101.  
  102.     SetMessage(global_screen_data.info_label, 
  103.            "Welcome to the X Resource Editor version 1.0");
  104.  
  105.     global_screen_data.set_values_popup = NULL;
  106.  
  107.     InternAtoms(XtDisplay(toplevel));
  108.  
  109.     XtRealizeWidget(toplevel);
  110.  
  111.     wm_delete_window = XInternAtom(XtDisplay(toplevel), "WM_DELETE_WINDOW",
  112.                    False);
  113.     (void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
  114.                             &wm_delete_window, 1);
  115.     XtAppMainLoop(app_con);
  116. }
  117.  
  118. /*    Function Name: Syntax
  119.  *    Description: Prints a the calling syntax for this function to stdout.
  120.  *    Arguments: app_con - the application context.
  121.  *                 call - the name of the application.
  122.  *    Returns: none - exits tho.
  123.  */
  124.  
  125. static void 
  126. Syntax(app_con, call)
  127. XtAppContext app_con;
  128. char *call;
  129. {
  130.     XtDestroyApplicationContext(app_con);
  131.     fprintf( stderr, "Usage: %s [ -vspace <value> ] [ -hspace <value> ]\n",
  132.         call);
  133.     exit(1);
  134. }
  135.