/*
** Generated by X-Designer 
*/
/*
**LIBS: -lXm -lXt -lX11
*/

#include <X11/Xatom.h>
#include <X11/Intrinsic.h>
#include <X11/Shell.h>

#include <Xm/Xm.h>
#include <Xm/CascadeB.h>
#include <Xm/DialogS.h>
#include <Xm/FileSB.h>
#include <Xm/Form.h>
#include <Xm/Label.h>
#include <Xm/List.h>
#include <Xm/ToggleB.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/ScrollBar.h>
#include <Xm/SelectioB.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/LabelG.h>
#include <Xm/PushBG.h>
#include <Xm/SeparatoG.h>
#include <stdio.h>

#include "grib1profile.h"

extern void help_help_quit_cb ();
extern void help_about_quit_cb ();
extern void file_open_cb ();
extern void file_select_ok_cb ();
extern void list_select_cb ();
extern void file_quit_cb ();
extern void help_about_cb ();
extern void help_help_cb ();
extern void file_toggle_cb ();
extern void setInitialFileState ( char ** , int );

void XDmanage_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtManageChild ( *(Widget *)client_data );
}

void XDunmanage_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtUnmanageChild ( *(Widget *)client_data );
}

void XDpopup_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtPopup ( *(Widget *)client_data, XtGrabNone );
}

void XDpopdown_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtPopdown ( *(Widget *)client_data );
}

void XDmap_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtMapWidget (*(Widget *)client_data);
}

void XDunmap_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtUnmapWidget (*(Widget *)client_data);
}

void XDenable_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtSetSensitive (*(Widget *)client_data, TRUE);
}

void XDdisable_link(
  Widget w,
  XtPointer client_data,
  XtPointer call_data) {

    XtSetSensitive (*(Widget *)client_data, FALSE);
}


Widget help_help_toplevel = (Widget) NULL;
Widget help_help_dialog = (Widget) NULL;
Widget help_help_scroll_text = (Widget) NULL;
Widget help_help_text = (Widget) NULL;
Widget help_help_quit = (Widget) NULL;
Widget help_about_toplevel = (Widget) NULL;
Widget help_about_dialog = (Widget) NULL;
Widget help_about_quit = (Widget) NULL;
Widget help_about_text = (Widget) NULL;
Widget file_select_dialog = (Widget) NULL;
Widget file_select = (Widget) NULL;
Widget file_text = (Widget) NULL;
Widget grib1profile = (Widget) NULL;
Widget frame = (Widget) NULL;
Widget scrolled_list_label = (Widget) NULL;
Widget scrolled_list = (Widget) NULL;
Widget list = (Widget) NULL;
Widget scrolled_text = (Widget) NULL;
Widget current_filename = (Widget) NULL;
Widget menubar = (Widget) NULL;
Widget file = (Widget) NULL;
Widget file_pulldown_menu = (Widget) NULL;
Widget file_open = (Widget) NULL;
Widget file_quit = (Widget) NULL;
Widget help = (Widget) NULL;
Widget help_pulldown_menu = (Widget) NULL;
Widget help_about = (Widget) NULL;
Widget help_help = (Widget) NULL;
Widget full_toggle = (Widget) NULL;



void create_help_help_toplevel (Widget parent) {
Display *display = XtDisplay ( parent );
Widget children[5];            /* Children to manage */
Arg al[64];                    /* Arg List */
register int ac = 0;           /* Arg Count */
XmString xmstrings[16];        /* temporary storage for XmStrings */

    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
    XtSetArg(al[ac], XmNtitle, "Grib1profile Help"); ac++;
    XtSetArg(al[ac], XmNminWidth, 400); ac++;
    XtSetArg(al[ac], XmNminHeight, 400); ac++;
    XtSetArg(al[ac], XmNmaxWidth, 800); ac++;
    XtSetArg(al[ac], XmNmaxHeight, 1000); ac++;
    XtSetArg(al[ac], XmNinput, FALSE); ac++;
    XtSetArg(al[ac], XmNbaseWidth, 600); ac++;
    XtSetArg(al[ac], XmNbaseHeight, 750); ac++;
    help_help_toplevel =
      XmCreateDialogShell ( parent, "help_help_toplevel", al, ac );
    ac = 0;

    XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
    help_help_dialog =
      XmCreateForm ( help_help_toplevel, "help_help_dialog", al, ac );
    ac = 0;

    XtSetArg(al[ac], XmNeditable, FALSE); ac++;
    XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
    help_help_text =
      XmCreateScrolledText ( help_help_dialog, "help_help_text", al, ac );
    ac = 0;

    help_help_scroll_text = XtParent ( help_help_text );

    xmstrings[0] =
      XmStringCreateLtoR("Quit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    help_help_quit =
      XmCreatePushButton ( help_help_dialog, "help_help_quit", al, ac );
    ac = 0;

    XmStringFree ( xmstrings [ 0 ] );

    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
    XtSetArg(al[ac], XmNbottomWidget, help_help_quit); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
    XtSetValues ( help_help_scroll_text,al, ac );
    ac = 0;

    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
    XtSetValues ( help_help_quit,al, ac );
    ac = 0;

    XtManageChild(help_help_text);
    XtAddCallback (help_help_quit, XmNactivateCallback, help_help_quit_cb,NULL);
    children[ac++] = help_help_quit;
    XtManageChildren(children, ac);
    ac = 0;
}


void create_help_about_toplevel ( Widget parent) {
Display *display = XtDisplay ( parent );
Widget children[5];            /* Children to manage */
Arg al[64];                    /* Arg List */
register int ac = 0;           /* Arg Count */
XmString xmstrings[16];        /* temporary storage for XmStrings */

    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
    XtSetArg(al[ac], XmNtitle, "About grib1profile"); ac++;
    XtSetArg(al[ac], XmNminWidth, 400); ac++;
    XtSetArg(al[ac], XmNminHeight, 300); ac++;
    XtSetArg(al[ac], XmNmaxWidth, 400); ac++;
    XtSetArg(al[ac], XmNmaxHeight, 300); ac++;
    XtSetArg(al[ac], XmNbaseWidth, 400); ac++;
    XtSetArg(al[ac], XmNbaseHeight, 300); ac++;
    help_about_toplevel =
      XmCreateDialogShell ( parent, "help_about_toplevel", al, ac );
    ac = 0;

    XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
    help_about_dialog =
      XmCreateForm ( help_about_toplevel, "help_about_dialog", al, ac );
    ac = 0;

    xmstrings[0] =
      XmStringCreateLtoR("Quit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
    help_about_quit =
      XmCreatePushButton ( help_about_dialog, "help_about_quit", al, ac );
    ac = 0;

    XmStringFree ( xmstrings [ 0 ] );
    XtSetArg(al[ac], XmNeditable, FALSE); ac++;
    XtSetArg(al[ac], XmNeditMode, XmMULTI_LINE_EDIT); ac++;
    help_about_text =
      XmCreateText ( help_about_dialog, "help_about_text", al, ac );
    ac = 0;

    XmTextSetString ( help_about_text,
      "\n\n\n"
      "  GRIB1 product file viewer\n"
      "  -------------------------\n\n\n"
      "  John Chambers\n\n"
      "  Meteorological Applications Section, ECMWF\n\n"
      "  August, 2001\n\n" );

    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++;
    XtSetValues ( help_about_quit,al, ac );
    ac = 0;

    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
    XtSetArg(al[ac], XmNbottomWidget, help_about_quit); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
    XtSetValues ( help_about_text,al, ac );
    ac = 0;

    XtAddCallback(help_about_quit,XmNactivateCallback,help_about_quit_cb,NULL);
    children[ac++] = help_about_quit;
    children[ac++] = help_about_text;
    XtManageChildren(children, ac);
    ac = 0;
}


void create_file_select_dialog ( Widget parent) {
Display *display = XtDisplay ( parent );
Arg al[64];                    /* Arg List */
register int ac = 0;           /* Arg Count */
Widget widget26;

    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
    XtSetArg(al[ac], XmNtitle, "File_select"); ac++;
    file_select_dialog =
      XmCreateDialogShell ( parent, "file_select_dialog", al, ac );
    ac = 0;

    XtAddCallback (file_select_dialog, XmNpopupCallback, file_open_cb,NULL);
    file_select =
      XmCreateFileSelectionBox ( file_select_dialog, "file_select", al, ac );
    file_text = XmSelectionBoxGetChild ( file_select, XmDIALOG_TEXT );
    widget26 =
      XmFileSelectionBoxGetChild ( file_select, XmDIALOG_FILTER_TEXT );

    XtAddCallback (file_select, XmNokCallback, file_select_ok_cb,NULL);
    XtAddCallback (file_select, XmNapplyCallback, file_select_ok_cb,NULL);
    XtAddCallback (file_select, XmNcancelCallback, file_select_ok_cb,NULL);
    XtAddCallback (file_select, XmNnoMatchCallback, file_select_ok_cb,NULL);
}


void create_grib1profile (
  Display *display,
  char *app_name,
  int app_argc,
  char **app_argv) {
Widget children[5];            /* Children to manage */
Arg al[64];                    /* Arg List */
register int ac = 0;           /* Arg Count */
XrmValue from_value, to_value; /* For resource conversion */
XmString xmstrings[16];        /* temporary storage for XmStrings */

    XtSetArg(al[ac], XmNallowShellResize, TRUE); ac++;
    XtSetArg(al[ac], XmNtitle, "Xgrib1profile"); ac++;
    XtSetArg(al[ac], XmNminWidth, 700); ac++;
    XtSetArg(al[ac], XmNbaseWidth, 700); ac++;
    XtSetArg(al[ac], XmNinput, FALSE); ac++;
    XtSetArg(al[ac], XmNargc, app_argc); ac++;
    XtSetArg(al[ac], XmNargv, app_argv); ac++;
    grib1profile =
      XtAppCreateShell ( app_name, "XGrib1profile", applicationShellWidgetClass,
                         display, al, ac );

    ac = 0;
    XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++;
    frame = XmCreateForm ( grib1profile, "frame", al, ac );

    ac = 0;
    xmstrings[0] =
      XmStringCreateLtoR(" ", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++;
    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
    from_value.addr = "9x15";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (frame, XmRString, &from_value, XmRFontList, &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNfontList, *(unsigned int *)to_value.addr); ac++;
    }
    scrolled_list_label =
      XmCreateLabel ( frame, "scrolled_list_label", al, ac );

    ac = 0; 
    XmStringFree ( xmstrings [ 0 ] );
    XtSetArg(al[ac], XmNvisibleItemCount, 10); ac++;
    from_value.addr = "9x15";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (frame, XmRString, &from_value, XmRFontList,
                       &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNfontList, *(unsigned int *)to_value.addr); ac++;
    }
    XtSetArg(al[ac], XmNselectionPolicy, XmSINGLE_SELECT); ac++;
    XtSetArg(al[ac], XmNlistSizePolicy, XmRESIZE_IF_POSSIBLE); ac++;
    list = XmCreateScrolledList ( frame, "list", al, ac );

    ac = 0;
    scrolled_list = XtParent ( list );

    ac = 0;
    xmstrings[0] =
      XmStringCreateLtoR("No file open.",
                         (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
    current_filename = XmCreateLabel ( frame, "current_filename", al, ac );

    ac = 0;
    XmStringFree ( xmstrings [ 0 ] );
    menubar = XmCreateMenuBar ( frame, "menubar", al, ac );
    xmstrings[0] =
      XmStringCreateLtoR("File", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    from_value.addr = "F";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (menubar, XmRString, &from_value, XmRKeySym, &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
    }
    file = XmCreateCascadeButton ( menubar, "file", al, ac );

    ac = 0;
    XmStringFree ( xmstrings [ 0 ] );
    file_pulldown_menu =
      XmCreatePulldownMenu ( menubar, "file_pulldown_menu", al, ac );
    xmstrings[0] =
      XmStringCreateLtoR("Open", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    from_value.addr = "O";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (file_pulldown_menu, XmRString, &from_value, XmRKeySym,
                       &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
    }
    file_open =
      XmCreatePushButton ( file_pulldown_menu, "file_open", al, ac );

    ac = 0;
    XmStringFree ( xmstrings [ 0 ] );
    xmstrings[0] =
      XmStringCreateLtoR("Quit", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    from_value.addr = "Q";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (file_pulldown_menu, XmRString, &from_value, XmRKeySym,
                       &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
    }
    file_quit =
      XmCreatePushButton ( file_pulldown_menu, "file_quit", al, ac );

    ac = 0;
    XmStringFree ( xmstrings [ 0 ] );
    xmstrings[0] =
      XmStringCreateLtoR("Help", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    from_value.addr = "H";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (menubar, XmRString, &from_value, XmRKeySym, &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
    }
    help = XmCreateCascadeButton ( menubar, "help", al, ac );

    ac = 0;
    XmStringFree ( xmstrings [ 0 ] );
    help_pulldown_menu =
      XmCreatePulldownMenu ( menubar, "help_pulldown_menu", al, ac );
    xmstrings[0] =
      XmStringCreateLtoR("About", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    from_value.addr = "A";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (help_pulldown_menu, XmRString, &from_value, XmRKeySym,
                       &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
    }
    help_about =
      XmCreatePushButton ( help_pulldown_menu, "help_about", al, ac );

    ac = 0;
    XmStringFree ( xmstrings [ 0 ] );
    xmstrings[0] =
      XmStringCreateLtoR("Help", (XmStringCharSet)XmFONTLIST_DEFAULT_TAG);
    XtSetArg(al[ac], XmNlabelString, xmstrings[0]); ac++;
    from_value.addr = "H";
    from_value.size = strlen( from_value.addr ) + 1;
    to_value.addr = NULL;
    XtConvertAndStore (help_pulldown_menu, XmRString, &from_value, XmRKeySym,
                       &to_value);
    if ( to_value.addr ) {
      XtSetArg(al[ac], XmNmnemonic, *(unsigned int *)to_value.addr); ac++;
    }
    help_help =
      XmCreatePushButton ( help_pulldown_menu, "help_help", al, ac );

    ac = 0;
    XmStringFree ( xmstrings [ 0 ] );
    XtSetArg(al[ac], XmNmenuHelpWidget, help); ac++;
    XtSetValues ( menubar,al, ac );

    ac = 0;
    XtSetArg(al[ac], XmNheight, 50); ac++;
    XtSetArg(al[ac], XmNrecomputeSize, FALSE); ac++;
    XtSetArg(al[ac], XmNindicatorType, XmONE_OF_MANY); ac++;
    XtSetArg(al[ac], XmNhighlightThickness, 0); ac++;

    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
    XtSetValues ( menubar,al, ac );

    ac = 0;
    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
    XtSetArg(al[ac], XmNtopWidget, menubar); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
    XtSetValues ( current_filename,al, ac );

    ac = 0;
    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
    XtSetArg(al[ac], XmNtopWidget, current_filename); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
    XtSetValues ( scrolled_list_label,al, ac );

    ac = 0;
    XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++;
    XtSetArg(al[ac], XmNtopOffset, 5); ac++;
    XtSetArg(al[ac], XmNtopWidget, scrolled_list_label); ac++;
    XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNbottomOffset, 5); ac++;
    XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNleftOffset, 5); ac++;
    XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++;
    XtSetArg(al[ac], XmNrightOffset, 5); ac++;
    XtSetValues ( scrolled_list,al, ac );

    ac = 0;
    XtAddCallback (list, XmNsingleSelectionCallback, list_select_cb,NULL);
    XtManageChild(list);
    children[ac++] = scrolled_list_label;
    XtManageChildren(children, ac);

    ac = 0;
    XtAddCallback (file_open, XmNactivateCallback, file_open_cb,NULL);
    XtAddCallback (file_quit, XmNactivateCallback, file_quit_cb,NULL);
    children[ac++] = file_open;
    children[ac++] = file_quit;
    XtManageChildren(children, ac);

    ac = 0;
    XtSetArg(al[ac], XmNsubMenuId, file_pulldown_menu); ac++;
    XtSetValues ( file, al, ac );

    ac = 0;
    XtAddCallback (help_about, XmNactivateCallback, help_about_cb,NULL);
    XtAddCallback (help_help, XmNactivateCallback, help_help_cb,NULL);
    children[ac++] = help_about;
    children[ac++] = help_help;
    XtManageChildren(children, ac);

    ac = 0;
    XtSetArg(al[ac], XmNsubMenuId, help_pulldown_menu); ac++;
    XtSetValues ( help, al, ac );

    ac = 0;
    children[ac++] = file;
    children[ac++] = help;
    XtManageChildren(children, ac);

    ac = 0;
    children[ac++] = scrolled_list;
    children[ac++] = current_filename;
    children[ac++] = menubar;
    XtManageChildren(children, ac);

    ac = 0;
    XtManageChild ( frame);
}



XtAppContext app_context;
Display *display;       /*  Display             */
static String fallbacks [] =
{
"XGrib1profile*fontList: 7x13bold",
NULL
};

int main (argc,argv)
int    argc;
char            **argv;
{
#ifndef SUN
    XtSetLanguageProc((XtAppContext)NULL,(XtLanguageProc)NULL,(XtPointer)NULL);
#endif
    XtToolkitInitialize ();
    app_context = XtCreateApplicationContext ();
    XtAppSetFallbackResources(app_context,fallbacks);
    display =
      XtOpenDisplay (app_context, NULL, argv[0], "XGrib1profile",
                     NULL, 0, &argc, argv);
    if (!display) {
      printf("%s: can't open display, exiting...\n", argv[0]);
      exit (-1);
    }
    create_grib1profile ( display, argv[0], argc, argv );
    create_help_help_toplevel ( grib1profile );
    create_help_about_toplevel ( grib1profile );
    create_file_select_dialog ( grib1profile );

    XtRealizeWidget (grib1profile);
/*
//  If filename given on the control line, use it.
*/
    if( argc == 2 ) setInitialFileState( argv+1, (int) strlen(*(argv+1)) );


    XtAppMainLoop (app_context);
    exit (0);
}

