X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fxio.c;h=0c5b225013cfba61330ad603757c130fb20095e3;hb=6804507f66d59ffb74687439b09abdc2376f3a5d;hp=ea13d0554cc1f044dee0267736149648972a10c6;hpb=38a3852bd4f39e5798588d94b958dabc3e56cc7a;p=super-star-trek.git diff --git a/src/xio.c b/src/xio.c index ea13d05..0c5b225 100644 --- a/src/xio.c +++ b/src/xio.c @@ -7,9 +7,14 @@ #include XtAppContext app_context; -Widget toplevel, form, quit, text; +Widget toplevel, form, buttons, quit, destruct, text; -void quit_proc (Widget w, XtPointer client_data, XtPointer call_data) +String fallback[] = { + "*destruct.fromHoriz: quit", + NULL, +}; + +static void quit_proc (Widget w, XtPointer client_data, XtPointer call_data) { XtDestroyApplicationContext (app_context); exit (0); @@ -18,23 +23,32 @@ void quit_proc (Widget w, XtPointer client_data, XtPointer call_data) int main (int argc, char **argv) { toplevel = XtVaOpenApplication (&app_context, "XThird", NULL, 0, &argc, - argv, NULL, applicationShellWidgetClass, + argv, fallback, + applicationShellWidgetClass, XtNallowShellResize, True, NULL); - form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL); - quit = XtVaCreateManagedWidget ("quit", commandWidgetClass, form, XtNlabel, - "Quit", NULL); - text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, - XtNfromVert, quit, XtNresize, - XawtextResizeBoth, XtNresizable, True, NULL); + form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL); + /* The button panel */ + buttons = XtVaCreateManagedWidget ("form", formWidgetClass, form, NULL); + quit = XtVaCreateManagedWidget("quit", + commandWidgetClass, buttons, + XtNlabel, "Quit", NULL); XtAddCallback (quit, XtNcallback, quit_proc, NULL); - if (argc <= 1) - XtVaSetValues (text, XtNtype, XawAsciiString, - XtNstring, "Fool! You should" - " supply a file name!", NULL); - else - XtVaSetValues (text, XtNtype, XawAsciiFile, XtNstring, argv [1], NULL); + destruct = XtVaCreateManagedWidget("destruct", + commandWidgetClass, buttons, + XtNlabel, "Destruct", NULL); + /* the command window */ + text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, + XtNfromVert, buttons, + XtNresize, XawtextResizeBoth, + XtNresizable, True, NULL); + + /* sample text so the widget will be identifiable */ + XtVaSetValues (text, XtNtype, XawAsciiString, + XtNstring, "Command window", NULL); XtVaSetValues (text, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL); XtRealizeWidget (toplevel); XtAppMainLoop (app_context); + /* loop may be interrupted */ + XtDestroyApplicationContext (app_context); exit(0); }