home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume19 / Jetedit / part03 / xmedialg.c next >
Encoding:
C/C++ Source or Header  |  1993-04-28  |  22.2 KB  |  652 lines

  1. /**---------------------------------------------------------------------
  2. ***     
  3. ***    file:        xmedialg.c
  4. ***
  5. ***    project:    jetedit - Motif Widgets text editor
  6. ***
  7. ***-------------------------------------------------------------------*/
  8.  
  9. #include "xme.h"
  10.  
  11. #define DIALOG_FSELECT        300
  12. #define DIALOG_OWARNING        301
  13. #define DIALOG_NWARNING        302
  14. #define DIALOG_CWARNING        303
  15. #define DIALOG_XWARNING        304
  16. #define DIALOG_NEW        305
  17. #define DIALOG_SAVE_AS        306
  18. #define DIALOG_HELP        307
  19. #define DIALOG_PRINT        308
  20. #define DIALOG_GOTO        309
  21. #define DIALOG_FIND        310
  22. #define DIALOG_F_EXISTS        311
  23. #define DIALOG_F_MODE        312
  24. #define DIALOG_EXISTS_AS    313
  25. #define DIALOG_PREF        314
  26.  
  27. extern char warningBits[];
  28.  
  29. char    find_help_string[] = "\n\
  30.      Regular Expressions Quick Reference\n\
  31. **********************************************\n\
  32.   RE refers to a regular expression.\n\
  33. ^RE$         Anchor the beginning and end of a line.\n\
  34. .            Matches any character.\n\
  35. [...]        Brackets match any characters they contain,\n\
  36.              unless the first character is ^, in which\n\
  37.              case they match characters NOT contained.\n\
  38. [a-e]        Matches a,b,c,d or e.\n\
  39. RE*          Matches zero or more occurences of RE.\n\
  40. RE\\{m,n\\}    Matches a minimum m and maximum n occurrences\n\
  41.              of RE.\n\
  42. **********************************************\n\
  43. To enter a Tab into the Find or Replace strings, type the Tab into the editor's main window, then copy it into the dialog.\n\
  44. ";
  45.  
  46. /*-------------------------------------------------------------
  47. **    DialogAcceptCB
  48. **        Process callback from Dialog "Ok" actions.
  49. */
  50. void DialogAcceptCB (w, client_data, call_data) 
  51. Widget         w;        /*  widget id           */
  52. caddr_t        client_data;    /*  data from application   */
  53. caddr_t        call_data;    /*  data from widget class  */
  54. {
  55.     char    *command;    /* command used in printing */
  56.     char    *goto_string=NULL;
  57.     char    line_string[15];
  58.     int        tfd;        /* temporary file descriptor */
  59.     Arg        al[1];
  60.     mode_t    mode_mask;
  61.     struct stat statbuf;    /* Information on a file. */
  62.     char    dir_string[120];
  63.     int        i,j;
  64.  
  65.     switch ((int)client_data)
  66.     {
  67.     case DIALOG_FSELECT:
  68.         /* open the file and read it into the text widget */
  69.         thefile = NULL;
  70.         {
  71.         XmFileSelectionBoxCallbackStruct *fcb =
  72.                 (XmFileSelectionBoxCallbackStruct *) call_data;
  73.  
  74.         /* get the thefile from the file selection box */
  75.         XmStringGetLtoR(fcb->value, charset, &thefile);
  76.         }
  77.         /* Open file, print error if it does not exist. */
  78.         if ((tfd = open(thefile, O_RDONLY)) == -1)  {
  79.             XtUnmanageChild (open_dialog);
  80.             XtManageChild (refused_dialog);
  81.         }
  82.         else {
  83.             if (stat(thefile, &statbuf) == 0) {
  84.                 file_mode = statbuf.st_mode;
  85.                 if (S_ISDIR(file_mode)) {
  86.                     /* This stuff allows directory traversal under Motif1.0 */
  87.                     strcpy(dir_string, thefile);
  88.                     i=strlen(dir_string);
  89.                     if (dir_string[i-1]=='.') {
  90.                         if (dir_string[i-2]=='.') {
  91.                             j=i-4;
  92.                             while (dir_string[j]!='/' && j>=0)
  93.                                 j--;
  94.                             if (j>=0)
  95.                                 dir_string[j+1] = '\0';
  96.                             else
  97.                                 dir_string[i-2] = '\0';
  98.                         }
  99.                         else dir_string[i-1] = '\0';
  100.                     }
  101.                     else 
  102.                         strcat(dir_string, "/");
  103.                     XmFileSelectionDoSearch(open_dialog,
  104.                       XmStringCreateLtoR(dir_string, charset)); 
  105.                 }
  106.                 if (S_ISREG(file_mode)) {
  107.                     XtUnmanageChild (open_dialog);
  108.                     OpenFile(tfd);
  109.                    /* close up the file */
  110.                     if (close(tfd) != NULL) 
  111.                         strcat (message_string, 
  112.                         "  \7Warning: unable to close file.");
  113.                 }
  114.             }
  115.         }
  116.         break;
  117.  
  118.     case DIALOG_OWARNING:
  119.         /* save the file */
  120.         if (SaveFile()) {
  121.             CloseFile(); /* close the file */
  122.             file_saved = True; /* reset the default */
  123.         }
  124.         break;
  125.  
  126.     case DIALOG_NEW:
  127.         /* Open the file and read it into the text widget. */
  128.         if (thefile != NULL) {
  129.             oldfile = XtMalloc (strlen (thefile) + 1);
  130.             strcpy (oldfile, thefile);
  131.             thefile = NULL;
  132.         }
  133.         {
  134.         XmSelectionBoxCallbackStruct *scb =
  135.             (XmSelectionBoxCallbackStruct *) call_data;
  136.  
  137.         /* get thefile string from the file name prompt box */
  138.         XmStringGetLtoR(scb->value, charset, &thefile);
  139.         }
  140.         XtUnmanageChild (new_dialog);
  141.         if ((tfd = open (thefile, O_RDONLY)) == -1) {
  142.             XtFree (oldfile);
  143.             no_undo = True;
  144.             XmTextSetString (text, "");
  145.             no_undo = False;
  146.             file_saved = True;
  147.             
  148.             lines = 1;
  149.             sprintf (line_string, " Line:  %4d", lines);
  150.             XtSetArg(al[0], XmNlabelString, 
  151.                 XmStringCreateLtoR(line_string, charset));
  152.             XtSetValues(line, al, 1);
  153.             
  154.             mode_mask = umask(0);
  155.             umask(mode_mask);
  156.             file_mode = ((S_IFREG | 0777) & ~mode_mask);
  157.             file_user = UID_NO_CHANGE;
  158.             file_group = GID_NO_CHANGE;
  159.             
  160.             XtSetSensitive(text, True);
  161.             XtSetSensitive(cut_button, True);
  162.             XtSetSensitive(copy_button, True);
  163.             XtSetSensitive(paste_button, True);
  164.             XtSetSensitive(find_button, True);
  165.             XtSetSensitive(goto_button, True);
  166.             InitUndoBuffer();
  167.             
  168.             sprintf (message_string, " Editing:  %s", thefile);
  169.             XtSetArg(al[0], XmNlabelString, 
  170.                 XmStringCreateLtoR(message_string, charset));
  171.             XtSetValues(message, al, 1);
  172.         }
  173.         else {
  174.             close (tfd);
  175.             XtManageChild (file_exists_dialog);
  176.         }
  177.         break;
  178.  
  179.     case DIALOG_NWARNING:
  180.         /* save the file */
  181.         if (SaveFile()) {
  182.             CloseFile(); /* close the file */
  183.             file_saved = True; /* reset the default */
  184.         }
  185.         break;
  186.  
  187.     case DIALOG_F_EXISTS:
  188.         XtFree (oldfile);
  189.         XmTextSetString (text, "");
  190.         XtSetSensitive(text, True);
  191.         XtSetSensitive(cut_button, True);
  192.         XtSetSensitive(copy_button, True);
  193.         XtSetSensitive(paste_button, True);
  194.         XtSetSensitive(find_button, True);
  195.         XtSetSensitive(goto_button, True);
  196.         file_saved = True; /* reset the default */
  197.         sprintf (message_string, " Editing:  %s", thefile);
  198.         XtSetArg(al[0], XmNlabelString, 
  199.             XmStringCreateLtoR(message_string, charset));
  200.         XtSetValues(message, al, 1);
  201.         break;
  202.  
  203.     case DIALOG_CWARNING:
  204.         /* save the file */
  205.         if (SaveFile()) {
  206.             CloseFile(); /* close the file */
  207.             file_saved = True; /* reset the default */
  208.             XtSetSensitive(text, False);
  209.             XtSetSensitive(cut_button, False);
  210.             XtSetSensitive(copy_button, False);
  211.             XtSetSensitive(paste_button, False);
  212.             XtSetSensitive(find_button, False);
  213.             XtSetSensitive(goto_button, False);
  214.             sprintf (message_string, " Editing:");
  215.             XtSetArg(al[0], XmNlabelString, 
  216.                 XmStringCreateLtoR(message_string, charset));
  217.             XtSetValues(message, al, 1);
  218.         }
  219.         break;
  220.  
  221.     case DIALOG_XWARNING:
  222.         /* save the file */
  223.         if (SaveFile()) {
  224.             CloseFile(); /* close the file */
  225.             CloseUndoBuffer ();
  226.             exit(0);
  227.         }
  228.         break;
  229.  
  230.     case DIALOG_SAVE_AS:
  231.         /* open the file and read it into the text widget */
  232.         if (thefile != NULL) {
  233.             oldfile = XtMalloc (strlen (thefile) + 1);
  234.             strcpy (oldfile, thefile);
  235.             thefile = NULL;
  236.         }
  237.         {
  238.         XmSelectionBoxCallbackStruct *scb =
  239.             (XmSelectionBoxCallbackStruct *) call_data;
  240.  
  241.         /* get the thefile string from the file name prompt box */
  242.         XmStringGetLtoR(scb->value, charset, &thefile);
  243.         }
  244.         XtUnmanageChild (save_as_dialog);
  245.         if ((tfd = open (thefile, O_RDONLY)) == -1) {
  246.             XtFree (oldfile);
  247.             SaveFile();
  248.         }
  249.         else {
  250.             close (tfd);
  251.             XtManageChild (exists_as_dialog);
  252.         }
  253.         break;
  254.  
  255.     case DIALOG_EXISTS_AS:
  256.         XtFree (oldfile);
  257.         SaveFile();
  258.         break;  
  259.     
  260.     case DIALOG_F_MODE:
  261.         break;
  262.     
  263.     case DIALOG_GOTO:
  264.         {
  265.         XmSelectionBoxCallbackStruct *scb =
  266.                 (XmSelectionBoxCallbackStruct *) call_data;
  267.  
  268.         /* get the find string from the prompt box */
  269.         XmStringGetLtoR(scb->value, charset, &goto_string);
  270.         GotoString(goto_string);
  271.         }
  272.         break;
  273.  
  274.     case DIALOG_HELP:
  275.         /* no help at this time */
  276.         break;
  277.  
  278.     default:
  279.         /* unknown callback type */
  280.         fprintf (stderr, "\7Warning: in accept callback\n");
  281.         break;
  282.     }
  283. }
  284.  
  285.  
  286.  
  287. /*-------------------------------------------------------------
  288. **    DialogApplyCB
  289. **        Process callback from Dialog "Discard" actions.
  290. */
  291. void DialogApplyCB (w, client_data, call_data) 
  292. Widget        w;        /*  widget id            */
  293. caddr_t        client_data;    /*  data from application    */
  294. caddr_t        call_data;    /*  data from widget class    */
  295. {
  296.     char *command;        /* command used in printing */
  297.  
  298.     switch ((int)client_data)
  299.     {
  300.         case DIALOG_OWARNING:
  301.             CloseFile();
  302.             file_saved = True;
  303.             XtUnmanageChild (open_warning);
  304.             break;
  305.  
  306.         case DIALOG_NWARNING:
  307.             CloseFile();
  308.             file_saved = True;
  309.             XtUnmanageChild (new_warning);
  310.             break;
  311.  
  312.         case DIALOG_CWARNING:
  313.             CloseFile();
  314.             file_saved = True;
  315.             XtUnmanageChild (close_warning);
  316.             break;
  317.  
  318.         case DIALOG_XWARNING:
  319.             CloseFile();
  320.             CloseUndoBuffer();
  321.             XtUnmanageChild (exit_warning);
  322.             exit();
  323.             break;          
  324.  
  325.         default:
  326.             /* unknown client_data was recieved and
  327.                there is no setup to handle this */
  328.             fprintf (stderr, "\7Warning: in apply callback\n");
  329.             break;
  330.  
  331.     }
  332. }
  333.  
  334.  
  335. /*-------------------------------------------------------------
  336. **    DialogCancelCB
  337. **        Process callback from Dialog "Cancel" actions.
  338. */
  339. void DialogCancelCB (w, client_data, call_data) 
  340. Widget        w;        /*  widget id           */
  341. caddr_t        client_data;    /*  data from application   */
  342. caddr_t        call_data;    /*  data from widget class  */
  343. {
  344.     int  theerror;
  345.     
  346.     switch ((int)client_data)
  347.     {
  348.         case DIALOG_FSELECT:
  349.         case DIALOG_OWARNING:
  350.             /* popdown the file selection box */
  351.             XtUnmanageChild (open_dialog);
  352.             break;
  353.  
  354.         case DIALOG_NWARNING:
  355.             /* popdown the file selection box */
  356.             XtUnmanageChild (new_dialog);
  357.             break;
  358.         case DIALOG_F_EXISTS:
  359.         case DIALOG_EXISTS_AS:
  360.             strcpy (thefile, oldfile);
  361.             XtFree (oldfile);
  362.             break;
  363.             
  364.         case DIALOG_F_MODE:
  365.             chmod (thefile, file_mode);
  366.             CloseFile();
  367.             file_saved = True;
  368.             break;
  369.         
  370.         case DIALOG_GOTO:
  371.             XtUnmanageChild (goto_dialog);
  372.             break;
  373.         
  374.         case DIALOG_CWARNING:
  375.         case DIALOG_XWARNING:
  376.         case DIALOG_NEW:
  377.         case DIALOG_SAVE_AS:
  378.         case DIALOG_HELP:
  379.             /* no action is necessary at this time */
  380.             break;
  381.  
  382.         default:
  383.             /* a unknown client_data was recieved and
  384.                there is no setup to handle this */
  385.             fprintf (stderr, "\7Warning: in cancel callback\n");
  386.             break;
  387.     }
  388. }
  389.  
  390.  
  391. /*-------------------------------------------------------------
  392. **    CreateMenuDialogs
  393. **        Create the popup dialogs.
  394. */
  395. void CreateMenuDialogs (menu_bar)
  396. Widget menu_bar;
  397. {
  398.     Arg        al[10];
  399.     Cardinal    ac;
  400.     XImage     *image;         /*  image for warning pixmap    */
  401.     Widget    button;
  402.  
  403.  
  404.     image = CreateDefaultImage (warningBits, 32, 32);
  405.     XmInstallImage (image, "warning_image");
  406.                                         
  407.     ac = 0;
  408.     XtSetArg(al[ac], XmNdirMask, ""); ac++;
  409.     XtSetArg(al[ac], XmNwidth, 220); ac++;
  410. #ifdef HARDCODE
  411.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  412. #endif
  413.     XtSetArg (al[ac], XmNdialogTitle, 
  414.         XmStringCreateLtoR("File Selection", charset));  ac++;
  415.     open_dialog = XmCreateFileSelectionDialog(menu_bar,
  416.             "file selection dialog", al, ac);
  417.     XtAddCallback (open_dialog, XmNokCallback,
  418.             DialogAcceptCB, DIALOG_FSELECT);
  419.     XtAddCallback (open_dialog, XmNcancelCallback,
  420.             DialogCancelCB, DIALOG_FSELECT);
  421.     button = XmFileSelectionBoxGetChild (open_dialog, XmDIALOG_HELP_BUTTON);
  422.     XtUnmanageChild (button);
  423.  
  424.     ac = 0;
  425.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  426. #ifdef HARDCODE
  427.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  428. #endif
  429.     XtSetArg (al[ac], XmNdialogTitle, 
  430.         XmStringCreateLtoR("Open Warning", charset));  ac++;
  431.     open_warning = CreateSpecialWarningDialog(menu_bar, "open warning",
  432.             "warning_image", "Save Changes?", al, ac);
  433.     XtAddCallback (open_warning, XmNapplyCallback,
  434.             DialogApplyCB, DIALOG_OWARNING);
  435.     XtAddCallback (open_warning, XmNokCallback,
  436.             DialogAcceptCB, DIALOG_OWARNING);
  437.     XtAddCallback (open_warning, XmNcancelCallback,
  438.             DialogCancelCB, DIALOG_OWARNING);
  439.  
  440.     ac = 0;
  441.     XtSetArg(al[ac], XmNselectionLabelString, XmStringCreateLtoR
  442.            ("Enter name of new file (including complete path).", charset));  ac++;
  443. #ifdef HARDCODE
  444.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  445. #endif
  446.     XtSetArg (al[ac], XmNdialogTitle, 
  447.         XmStringCreateLtoR("New File", charset));  ac++;
  448.     new_dialog = XmCreatePromptDialog(menu_bar,
  449.            "new file dialog", al, ac);
  450.     XtAddCallback (new_dialog, XmNokCallback,
  451.             DialogAcceptCB, DIALOG_NEW);
  452.     XtAddCallback (new_dialog, XmNcancelCallback,
  453.             DialogCancelCB, DIALOG_NEW);
  454.     button = XmSelectionBoxGetChild (new_dialog, XmDIALOG_HELP_BUTTON);
  455.     XtUnmanageChild (button);
  456.  
  457.     ac = 0;
  458.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  459. #ifdef HARDCODE
  460.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  461. #endif
  462.     XtSetArg (al[ac], XmNdialogTitle, 
  463.         XmStringCreateLtoR("New Warning", charset));  ac++;
  464.     new_warning = CreateSpecialWarningDialog(menu_bar, "new_warning",
  465.            "warning_image", "Save Changes?", al, ac);
  466.     XtAddCallback (new_warning, XmNapplyCallback,
  467.            DialogApplyCB, DIALOG_NWARNING);
  468.     XtAddCallback (new_warning, XmNokCallback,
  469.            DialogAcceptCB, DIALOG_NWARNING);
  470.     XtAddCallback (new_warning, XmNcancelCallback,
  471.            DialogCancelCB, DIALOG_NWARNING);
  472.  
  473.     ac = 0;
  474.     XtSetArg(al[ac], XmNmessageString, XmStringCreateLtoR
  475.            ("This file already exists.", charset));  ac++;
  476.     XtSetArg(al[ac], XmNokLabelString,
  477.          XmStringCreateLtoR("Overwrite", charset)); ac++;
  478.     XtSetArg(al[ac], XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON);  ac++;
  479.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  480. #ifdef HARDCODE
  481.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  482. #endif
  483.     XtSetArg (al[ac], XmNdialogTitle, 
  484.         XmStringCreateLtoR("File Exists Warning", charset));  ac++;
  485.     file_exists_dialog = XmCreateWarningDialog(menu_bar,
  486.            "file exists dialog", al, ac);
  487.     XtAddCallback (file_exists_dialog, XmNokCallback,
  488.             DialogAcceptCB, DIALOG_F_EXISTS);
  489.     XtAddCallback (file_exists_dialog, XmNcancelCallback,
  490.             DialogCancelCB, DIALOG_F_EXISTS);
  491.     button = XmMessageBoxGetChild (file_exists_dialog, XmDIALOG_HELP_BUTTON);
  492.     XtUnmanageChild (button);
  493.  
  494.     ac = 0;
  495.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  496. #ifdef HARDCODE
  497.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  498. #endif
  499.     XtSetArg (al[ac], XmNdialogTitle, 
  500.         XmStringCreateLtoR("Close Warning", charset));  ac++;
  501.     close_warning = CreateSpecialWarningDialog(menu_bar, "close_warning",
  502.            "warning_image", "Save Changes?", al, ac);
  503.     XtAddCallback (close_warning, XmNapplyCallback,
  504.            DialogApplyCB, DIALOG_CWARNING);
  505.     XtAddCallback (close_warning, XmNokCallback,
  506.            DialogAcceptCB, DIALOG_CWARNING);
  507.     XtAddCallback (close_warning, XmNcancelCallback,
  508.            DialogCancelCB, DIALOG_CWARNING);
  509.  
  510.     ac = 0;
  511.     XtSetArg(al[ac], XmNselectionLabelString, XmStringCreateLtoR
  512.            ("Save As...", charset));  ac++;
  513.     XtSetArg(al[ac], XmNtextString, XmStringCreateLtoR
  514.            (thefile, charset));  ac++;
  515. #ifdef HARDCODE
  516.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  517. #endif
  518.     XtSetArg (al[ac], XmNdialogTitle, 
  519.         XmStringCreateLtoR("Save As", charset));  ac++;
  520.     save_as_dialog = XmCreatePromptDialog(menu_bar, "save as dialog", al, ac);
  521.     XtAddCallback (save_as_dialog, XmNokCallback,
  522.            DialogAcceptCB, DIALOG_SAVE_AS);
  523.     button = XmSelectionBoxGetChild (save_as_dialog, XmDIALOG_HELP_BUTTON);
  524.     XtUnmanageChild (button);
  525.  
  526.     ac = 0;
  527.     XtSetArg(al[ac], XmNmessageString, XmStringCreateLtoR
  528.            ("This file already exists.", charset));  ac++;
  529.     XtSetArg(al[ac], XmNokLabelString,
  530.          XmStringCreateLtoR("Overwrite", charset)); ac++;
  531.     XtSetArg(al[ac], XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON);  ac++;
  532.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  533. #ifdef HARDCODE
  534.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  535. #endif
  536.     XtSetArg (al[ac], XmNdialogTitle, 
  537.         XmStringCreateLtoR("File Exists Warning", charset));  ac++;
  538.     exists_as_dialog = XmCreateWarningDialog(menu_bar,
  539.            "file exists as dialog", al, ac);
  540.     XtAddCallback (exists_as_dialog, XmNokCallback,
  541.             DialogAcceptCB, DIALOG_EXISTS_AS);
  542.     XtAddCallback (exists_as_dialog, XmNcancelCallback,
  543.             DialogCancelCB, DIALOG_EXISTS_AS);
  544.     button = XmMessageBoxGetChild (exists_as_dialog, XmDIALOG_HELP_BUTTON);
  545.     XtUnmanageChild (button);
  546.  
  547.     ac = 0;
  548.     XtSetArg(al[ac], XmNmessageString, XmStringCreateLtoR
  549.            ("This file does not have write permission.", charset));  ac++;
  550.     XtSetArg(al[ac], XmNokLabelString,
  551.          XmStringCreateLtoR("Continue", charset)); ac++;
  552.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  553.     XtSetArg (al[ac], XmNdialogTitle, 
  554.         XmStringCreateLtoR("Permission Warning", charset));  ac++;
  555.     file_mode_dialog = XmCreateWarningDialog(menu_bar,
  556.            "file mode dialog", al, ac);
  557.     XtAddCallback (file_mode_dialog, XmNokCallback,
  558.             DialogAcceptCB, DIALOG_F_MODE);
  559.     XtAddCallback (file_mode_dialog, XmNcancelCallback,
  560.             DialogCancelCB, DIALOG_F_MODE);
  561.     button = XmMessageBoxGetChild (file_mode_dialog, XmDIALOG_HELP_BUTTON);
  562.     XtUnmanageChild (button);
  563.  
  564.     ac = 0;
  565.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  566.     XtSetArg(al[ac], XmNmessageString, XmStringCreateLtoR
  567.            ("Access permission Denied.", charset));  ac++;
  568. #ifdef HARDCODE
  569.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  570. #endif
  571.     XtSetArg (al[ac], XmNdialogTitle, 
  572.         XmStringCreateLtoR("Refused Warning", charset));  ac++;
  573.     refused_dialog = XmCreateMessageDialog(menu_bar, "refused", al, ac);
  574.     button = XmMessageBoxGetChild (refused_dialog, XmDIALOG_CANCEL_BUTTON);
  575.     XtUnmanageChild (button);
  576.     button = XmMessageBoxGetChild (refused_dialog, XmDIALOG_HELP_BUTTON);
  577.     XtUnmanageChild (button);
  578.  
  579.     ac = 0;
  580.     XtSetArg(al[ac], XmNdialogStyle, XmDIALOG_APPLICATION_MODAL); ac++;
  581. #ifdef HARDCODE
  582.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  583. #endif
  584.     XtSetArg (al[ac], XmNdialogTitle, 
  585.         XmStringCreateLtoR("Exit Warning", charset));  ac++;
  586.     exit_warning = CreateSpecialWarningDialog(menu_bar, "exit_warning",
  587.           "warning_image", "Save Changes?", al, ac);
  588.     XtAddCallback (exit_warning, XmNapplyCallback,
  589.         DialogApplyCB, DIALOG_XWARNING);
  590.     XtAddCallback (exit_warning, XmNokCallback,
  591.         DialogAcceptCB, DIALOG_XWARNING);
  592.  
  593.     ac = 0;
  594. #ifdef HARDCODE
  595.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  596.     XtSetArg (al[ac], XmNautoUnmanage, False);  ac++;
  597. #endif
  598.     XtSetArg (al[ac], XmNdialogTitle, 
  599.         XmStringCreateLtoR("Find/Replace", charset));  ac++;
  600.     find_dialog = CreateSpecialFindDialog(menu_bar,
  601.          "Find", al, ac);
  602.  
  603.     ac = 0;
  604. #ifdef HARDCODE
  605.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  606. #endif
  607.     XtSetArg (al[ac], XmNdialogTitle, 
  608.         XmStringCreateLtoR("Find Help", charset));  ac++;
  609.     find_help_dialog = CreateSpecialHelpDialog(menu_bar, &find_help_text,
  610.          "find_help", al, ac);
  611.     XmTextSetString(find_help_text, find_help_string);
  612.  
  613.     ac = 0;
  614.     XtSetArg(al[ac], XmNselectionLabelString,
  615.         XmStringCreateLtoR ("Go to line:", charset));  ac++;
  616.     XtSetArg(al[ac], XmNcancelLabelString,
  617.         XmStringCreateLtoR ("Done", charset));  ac++;
  618. #ifdef HARDCODE
  619.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  620.     XtSetArg (al[ac], XmNautoUnmanage, False);  ac++;
  621. #endif
  622.     XtSetArg (al[ac], XmNdialogTitle, 
  623.         XmStringCreateLtoR("GoTo", charset));  ac++;
  624.     goto_dialog = XmCreatePromptDialog(menu_bar,
  625.            "goto dialog", al, ac);
  626.     XtAddCallback (goto_dialog, XmNokCallback,
  627.             DialogAcceptCB, DIALOG_GOTO);
  628.     XtAddCallback (goto_dialog, XmNcancelCallback,
  629.             DialogCancelCB, DIALOG_GOTO);
  630.     button = XmSelectionBoxGetChild (goto_dialog, XmDIALOG_HELP_BUTTON);
  631.     XtUnmanageChild (button);
  632.  
  633.     ac = 0;
  634. #ifdef HARDCODE
  635.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  636. #endif
  637.     XtSetArg (al[ac], XmNdialogTitle, 
  638.         XmStringCreateLtoR("Preferences", charset));  ac++;
  639.     prefer_dialog = CreatePreferencesDialog(menu_bar,
  640.          "preferences", al, ac);
  641.  
  642.     ac = 0;
  643. #ifdef HARDCODE
  644.     XtSetArg (al[ac], XmNtextFontList, fontlist);  ac++;
  645. #endif
  646.     XtSetArg (al[ac], XmNdialogTitle, 
  647.         XmStringCreateLtoR("Preferences Help", charset));  ac++;
  648.     help_dialog = CreateSpecialHelpDialog(menu_bar, &help_text,
  649.          "help", al, ac);
  650. }
  651.  
  652.