More resources into fallback.
[super-star-trek.git] / src / xio.c
index 63faceada62e4320fc425ff2f14af61b19a22360..a84ee44192a077809e8da3bb7be703b3a89fa84b 100644 (file)
--- a/src/xio.c
+++ b/src/xio.c
@@ -7,9 +7,26 @@
 #include <X11/Xaw/AsciiText.h>
 
 XtAppContext app_context;
-Widget toplevel, form, buttons, quit, destruct, text;
+Widget toplevel, form, text; 
+Widget buttons, phasers, photons, destruct, quit;
 
-void quit_proc (Widget w, XtPointer client_data, XtPointer call_data)
+String fallback[] = {
+    /* button labels */
+    "*phasers.label: Phasers",
+    "*photons.label: Torps",
+    "*destruct.label: Destruct",
+    "*quit.label: Quit",
+    /* text window resources */
+    "*text.resizable: true",
+    "*text.resize: ResizeBoth",
+    /* layout constraints */
+    "*photons.fromHoriz: phasers",
+    "*destruct.fromHoriz: photons",
+    "*quit.fromHoriz: destruct",
+    NULL,
+};
+
+static void quit_proc (Widget w, XtPointer client_data, XtPointer call_data)
 { 
     XtDestroyApplicationContext (app_context);
     exit (0);
@@ -17,22 +34,30 @@ 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,
+    toplevel = XtVaOpenApplication (&app_context, "sst2k", NULL, 0, &argc,
+                                   argv, fallback, 
+                                   applicationShellWidgetClass,
                                    XtNallowShellResize, True, NULL);
-    form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL); 
-    buttons = XtVaCreateManagedWidget ("form", formWidgetClass, form, NULL); 
-    quit     = XtVaCreateManagedWidget("quit", 
+    form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL);
+    /* The button panel */
+    buttons  = XtVaCreateManagedWidget ("form", formWidgetClass, form, NULL); 
+    phasers  = XtVaCreateManagedWidget("phasers", 
                                       commandWidgetClass, buttons, 
-                                      XtNlabel, "Quit", NULL);
+                                      NULL);
+    photons  = XtVaCreateManagedWidget("photons", 
+                                      commandWidgetClass, buttons, 
+                                      NULL);
     destruct = XtVaCreateManagedWidget("destruct", 
                                       commandWidgetClass, buttons, 
-                                      XtNfromHoriz, quit,
-                                      XtNlabel, "Destruct", NULL);
-    text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, 
-                                   XtNfromVert, buttons, XtNresize,
-                                   XawtextResizeBoth, XtNresizable, True, NULL);
+                                      NULL);
+    quit     = XtVaCreateManagedWidget("quit", 
+                                      commandWidgetClass, buttons, 
+                                      NULL);
     XtAddCallback (quit, XtNcallback, quit_proc, NULL);
+    /* the command window */
+    text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, 
+                                   XtNfromVert, buttons, 
+                                   NULL);
 
     /* sample text so the widget will be identifiable */
     XtVaSetValues (text, XtNtype, XawAsciiString, 
@@ -40,5 +65,7 @@ int main (int argc, char **argv)
     XtVaSetValues (text, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL);
     XtRealizeWidget (toplevel);
     XtAppMainLoop (app_context);
+    /* loop may be interrupted */
+    XtDestroyApplicationContext (app_context);
     exit(0);
 }