editres.c revision 352bf44e
133c89af1Smrg/* 233c89af1Smrg * 333c89af1SmrgCopyright 1989, 1998 The Open Group 433c89af1Smrg 533c89af1SmrgPermission to use, copy, modify, distribute, and sell this software and its 633c89af1Smrgdocumentation for any purpose is hereby granted without fee, provided that 733c89af1Smrgthe above copyright notice appear in all copies and that both that 833c89af1Smrgcopyright notice and this permission notice appear in supporting 933c89af1Smrgdocumentation. 1033c89af1Smrg 1133c89af1SmrgThe above copyright notice and this permission notice shall be included in 1233c89af1Smrgall copies or substantial portions of the Software. 1333c89af1Smrg 1433c89af1SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1533c89af1SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1633c89af1SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1733c89af1SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1833c89af1SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1933c89af1SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2033c89af1Smrg 2133c89af1SmrgExcept as contained in this notice, the name of The Open Group shall not be 2233c89af1Smrgused in advertising or otherwise to promote the sale, use or other dealings 2333c89af1Smrgin this Software without prior written authorization from The Open Group. 2433c89af1Smrg */ 2533c89af1Smrg 2633c89af1Smrg#include <stdio.h> 2733c89af1Smrg#include <stdlib.h> 2833c89af1Smrg#include <X11/Intrinsic.h> 2933c89af1Smrg#include <X11/StringDefs.h> 30ad47b356Smrg#include <X11/Xaw/Cardinals.h> 3133c89af1Smrg 3233c89af1Smrg#define THIS_IS_MAIN /* Don't get extern definitions of global 3333c89af1Smrg variables. */ 3433c89af1Smrg 3533c89af1Smrg#include "editresP.h" 3633c89af1Smrg 3733c89af1Smrg/* 38ad47b356Smrg * Global variables. 3933c89af1Smrg */ 4033c89af1Smrg 4133c89af1Smrg/* array of toolkit dependent labels taken from the resource file */ 4233c89af1SmrgString res_labels[NUM_RES_LABELS]; 4333c89af1Smrg 4433c89af1Smrg/* decremented if the target client does not speak the current version */ 4533c89af1Smrgint global_effective_protocol_version = CURRENT_PROTOCOL_VERSION; 4633c89af1Smrg 4733c89af1Smrg/* toolkit type of client whose "resources" we are currently editing */ 48352bf44eSmrgString global_effective_toolkit = "xt"; 4933c89af1Smrg 5033c89af1Smrgint global_error_code; 5133c89af1Smrgunsigned long global_serial_num; 5233c89af1Smrgint (*global_old_error_handler)(Display *, XErrorEvent *); 5333c89af1Smrg 5433c89af1SmrgBoolean global_resource_box_up = FALSE; 5533c89af1SmrgTreeInfo *global_tree_info = NULL; 5633c89af1SmrgCurrentClient global_client; 5733c89af1SmrgScreenData global_screen_data; 5833c89af1SmrgWidget global_tree_parent; 5933c89af1SmrgWidget global_paned = NULL; /* named after toolkit */ 6033c89af1SmrgWidget global_toplevel; 6133c89af1SmrgAppResources global_resources; 6233c89af1Smrg 6333c89af1Smrg 64ad47b356Smrgstatic void Syntax ( XtAppContext app_con, char *call ) _X_NORETURN; 6533c89af1Smrg 66ad47b356Smrgstatic String fallback_resources[] = { 6733c89af1Smrg NULL, 6833c89af1Smrg}; 6933c89af1Smrg 7033c89af1Smrg#define Offset(field) (XtOffsetOf(AppResources, field)) 7133c89af1Smrg 7233c89af1Smrgstatic XtResource editres_resources[] = { 7333c89af1Smrg {"debug", "Debug", XtRBoolean, sizeof(Boolean), 7433c89af1Smrg Offset(debug), XtRImmediate, (XtPointer) FALSE}, 7533c89af1Smrg {"numFlashes", "NumFlashes", XtRInt, sizeof(int), 76ad47b356Smrg Offset(num_flashes), XtRImmediate, (XtPointer) NUM_FLASHES}, 7733c89af1Smrg {"flashTime", "FlashTime", XtRInt, sizeof(int), 78ad47b356Smrg Offset(flash_time), XtRImmediate, (XtPointer) FLASH_TIME}, 7933c89af1Smrg {"flashColor", XtCForeground, XtRPixel, sizeof(Pixel), 8033c89af1Smrg Offset(flash_color), XtRImmediate, (XtPointer) XtDefaultForeground}, 8133c89af1Smrg {"saveResourceFile", "SaveResourcesFile", XtRString, sizeof(String), 8233c89af1Smrg Offset(save_resources_file), XtRString, (XtPointer) ""}, 8333c89af1Smrg}; 8433c89af1Smrg 8533c89af1SmrgAtom wm_delete_window; 8633c89af1Smrg 8733c89af1Smrgint 88278eca22Smrgmain(int argc, char **argv) 8933c89af1Smrg{ 9033c89af1Smrg XtAppContext app_con; 9133c89af1Smrg 9233c89af1Smrg global_toplevel = XtAppInitialize(&app_con, "Editres", NULL, ZERO, 9333c89af1Smrg &argc, argv, fallback_resources, 9433c89af1Smrg NULL, ZERO); 9533c89af1Smrg 96ad47b356Smrg if (argc != 1) 9733c89af1Smrg Syntax(app_con, argv[0]); 9833c89af1Smrg 9933c89af1Smrg SetApplicationActions(app_con); 100ad47b356Smrg XtGetApplicationResources(global_toplevel, (XtPointer) &global_resources, 10133c89af1Smrg editres_resources, XtNumber(editres_resources), 10233c89af1Smrg NULL, (Cardinal) 0); 10333c89af1Smrg global_resources.allocated_save_resources_file = FALSE; 10433c89af1Smrg 10533c89af1Smrg XtOverrideTranslations 106ad47b356Smrg (global_toplevel, 107ad47b356Smrg XtParseTranslationTable ("<Message>WM_PROTOCOLS: quit()")); 10833c89af1Smrg 10933c89af1Smrg /* build tree for Xt intrinsics */ 110ad47b356Smrg BuildWidgetTree(global_toplevel); 11133c89af1Smrg 112ad47b356Smrg SetMessage(global_screen_data.info_label, 11333c89af1Smrg res_labels[13]); 11433c89af1Smrg 11533c89af1Smrg global_screen_data.set_values_popup = NULL; 11633c89af1Smrg 11733c89af1Smrg InternAtoms(XtDisplay(global_toplevel)); 11833c89af1Smrg 11933c89af1Smrg XtRealizeWidget(global_toplevel); 12033c89af1Smrg 121ad47b356Smrg wm_delete_window = 12233c89af1Smrg XInternAtom(XtDisplay(global_toplevel), "WM_DELETE_WINDOW", 12333c89af1Smrg False); 124ad47b356Smrg (void) XSetWMProtocols (XtDisplay(global_toplevel), 12533c89af1Smrg XtWindow(global_toplevel), 12633c89af1Smrg &wm_delete_window, 1); 12733c89af1Smrg XtAppMainLoop(app_con); 12833c89af1Smrg exit(0); 12933c89af1Smrg} 13033c89af1Smrg 13133c89af1Smrg/* Function Name: Syntax 13233c89af1Smrg * Description: Prints a the calling syntax for this function to stdout. 13333c89af1Smrg * Arguments: app_con - the application context. 13433c89af1Smrg * call - the name of the application. 135352bf44eSmrg * Returns: none - exits though. 13633c89af1Smrg */ 13733c89af1Smrg 138ad47b356Smrgstatic void 139278eca22SmrgSyntax(XtAppContext app_con, char *call) 14033c89af1Smrg{ 14133c89af1Smrg XtDestroyApplicationContext(app_con); 14233c89af1Smrg fprintf(stderr, "Usage: %s\n", call); 14333c89af1Smrg exit(1); 14433c89af1Smrg} 145