home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFM / XFM-1.3 / XFM-1 / xfm-1.3 / xfm / FmPopup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-16  |  19.2 KB  |  752 lines

  1. /*---------------------------------------------------------------------------
  2.   Module FmPopup
  3.  
  4.   (c) Simon Marlow 1990-92
  5.   (c) Albert Graef 1994
  6.  
  7.   Routines for creating and managing popup forms and dialog boxes
  8. ---------------------------------------------------------------------------*/
  9.  
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <unistd.h>
  13.  
  14. #include <X11/Intrinsic.h>
  15. #include <X11/StringDefs.h>
  16. #include <X11/Shell.h>
  17. #include <X11/Xaw/Dialog.h>
  18. #include <X11/Xaw/Toggle.h>
  19.  
  20. #include "Fm.h"
  21.  
  22. /*---------------------------------------------------------------------------
  23.   STATIC DATA
  24. ---------------------------------------------------------------------------*/
  25.  
  26. typedef struct {
  27.   FileWindowRec *fw;
  28.   Widget mkdir, createFile, goTo, move, copy, link, select;
  29.   char s[MAXPATHLEN], t[MAXPATHLEN];
  30. } PopupsRec;
  31.  
  32. static PopupsRec popups;
  33.  
  34. /*---------------------------------------------------------------------------
  35.   PRIVATE FUNCTIONS
  36. ---------------------------------------------------------------------------*/
  37.  
  38. char *dir_prefix(char *dir, char *path)
  39. {
  40.   char *p;
  41.   if ((p = strrchr(path, '/'))) {
  42.     strcpy(dir, path);
  43.     if (p == path)
  44.       dir[1] = '\0';
  45.     else
  46.       dir[p-path] = '\0';
  47.   } else
  48.     dir[0] = '\0';
  49.   return dir;
  50. }
  51.  
  52. static FmCallbackProc 
  53.   mkdirOkCb, mkdirCancelCb, createFileOkCb, createFileCancelCb, goToOkCb,
  54.   goToCancelCb, moveOkCb, moveCancelCb, copyOkCb, copyCancelCb, linkOkCb,
  55.   linkCancelCb, selectAddCb, selectRemoveCb, selectCancelCb, selectReplaceCb;
  56.  
  57. static void mkdirOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  58. {
  59.   XtPopdown(popups.mkdir);
  60.   fnexpand(popups.s);
  61.   if (chdir(popups.fw->directory))
  62.     sysError("System error:");
  63.   else if (mkdir(popups.s, user.umask & 0777)) {
  64.     char s[0xff];
  65.     sprintf(s, "Error creating folder %s:", popups.s);
  66.     sysError(s);
  67.   } else
  68.     intUpdate();
  69.   freeze = False;
  70. }
  71.  
  72. /*---------------------------------------------------------------------------*/
  73.  
  74. static void mkdirCancelCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  75. {
  76.   XtPopdown(popups.mkdir);
  77.   freeze = False;
  78. }
  79.  
  80. /*---------------------------------------------------------------------------*/
  81.  
  82. static void createFileOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  83. {
  84.   XtPopdown(popups.createFile);
  85.   fnexpand(popups.s);
  86.   if (chdir(popups.fw->directory))
  87.     sysError("System error:");
  88.   else if (create(popups.s, user.umask & 0666)) {
  89.     char s[0xff];
  90.     sprintf(s, "Error creating file %s:", popups.s);
  91.     sysError(s);
  92.   } else
  93.     intUpdate();
  94.   freeze = False;
  95. }
  96.  
  97. /*---------------------------------------------------------------------------*/
  98.  
  99. static void createFileCancelCb(Widget w, FileWindowRec *fw, 
  100.                XtPointer call_data)
  101. {
  102.   XtPopdown(popups.createFile);
  103.   freeze = False;
  104. }
  105.  
  106. /*---------------------------------------------------------------------------*/
  107.  
  108. static void goToOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  109. {
  110.   char path[MAXPATHLEN];
  111.  
  112.   XtPopdown(popups.goTo);
  113.   fnexpand(popups.s);
  114.   if (chdir(popups.fw->directory) || chdir(popups.s)) {
  115.     char s[0xff];
  116.     sprintf(s, "Can't open folder %s:", popups.s);
  117.     sysError(s);
  118.   } else if (!getwd(path))
  119.     sysError("System error:");
  120.   else {
  121.     strcpy(popups.fw->directory, path);
  122.     updateFileDisplay(popups.fw);
  123.   }
  124.   freeze = False;
  125. }
  126.  
  127. /*---------------------------------------------------------------------------*/
  128.  
  129. static void goToCancelCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  130. {
  131.   XtPopdown(popups.goTo);
  132.   freeze = False;
  133. }
  134.  
  135. /*---------------------------------------------------------------------------*/
  136.  
  137. static void moveOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  138. {
  139.   struct stat stats;
  140.   int i, toi, n_moved = 0;
  141.   char *from = NULL, to[MAXPATHLEN], todir[MAXPATHLEN];
  142.  
  143.   XtPopdown(popups.move);
  144.   strcpy(to, popups.s);
  145.   fnexpand(to);
  146.  
  147.   if (chdir(popups.fw->directory))
  148.  
  149.     sysError("System error:");
  150.  
  151.   else {
  152.  
  153.     /* if target exists and is a directory, move the source into that
  154.        directory */
  155.  
  156.     if (!stat(to, &stats) && S_ISDIR(stats.st_mode)) {
  157.  
  158.       if (chdir(to) || !getwd(to) || chdir(popups.fw->directory)) {
  159.     sysError("System error:");
  160.     goto out;
  161.       } else if (!strcmp(popups.fw->directory, to)) {
  162.     error("Move:", "Source and destination are identical");
  163.     goto out;
  164.       }
  165.  
  166.       strcpy(todir, to);
  167.  
  168.       toi = strlen(to);
  169.       if (to[toi-1] != '/') {
  170.     to[toi++] = '/';
  171.     to[toi] = '\0';
  172.       }
  173.  
  174.       for (i=0; i < popups.fw->n_files; i++)
  175.     if (popups.fw->files[i]->selected) {
  176.       if (!strcmp(popups.fw->files[i]->name, ".") ||
  177.           !strcmp(popups.fw->files[i]->name, "..")) {
  178.         error("Cannot move . or ..", "");
  179.         continue;
  180.       }
  181.       from = popups.fw->files[i]->name;
  182.       strcpy(to+toi, from);
  183.       if (exists(to) && resources.confirm_overwrite) {
  184.         char s[0xff];
  185.         sprintf(s, "Move: file %s already exists at destination", from);
  186.         if (!confirm(s, "Overwrite?", ""))
  187.           if (aborted)
  188.         break;
  189.           else
  190.         continue;
  191.       }
  192.       if (rename(from,to)) {
  193.         char s[0xff];
  194.         sprintf(s, "Error moving %s:", to);
  195.         sysError(s);
  196.       } else
  197.         n_moved++;
  198.     }
  199.     }
  200.  
  201.     /* otherwise only a single file may be selected; move it to the target
  202.        file */
  203.  
  204.     else if (popups.fw->n_selections > 1) {
  205.  
  206.       error("Move: target for multiple files", "must be a folder");
  207.       goto out;
  208.  
  209.     } else {
  210.  
  211.       struct stat stats1;
  212.  
  213.       for (i = 0; i < popups.fw->n_files; i++)
  214.     if (popups.fw->files[i]->selected) {
  215.       from = popups.fw->files[i]->name;
  216.       break;
  217.     }
  218.  
  219.       if (!strcmp(from, ".") || !strcmp(from, "..")) {
  220.     error("Cannot move . or ..", "");
  221.     goto out;
  222.       } else if (!lstat(to, &stats) && !lstat(from, &stats1) &&
  223.          stats.st_ino == stats1.st_ino) {
  224.     error("Move:", "Source and destination are identical");
  225.     goto out;
  226.       }
  227.  
  228.       if (exists(to) && resources.confirm_overwrite) {
  229.     char s[0xff];
  230.     sprintf(s, "Move: file %s already exists", to);
  231.     if (!confirm(s, "Overwrite?", ""))
  232.       goto out;
  233.       }
  234.  
  235.       if (rename(from, to)) {
  236.     char s[0xff];
  237.     sprintf(s, "Error moving %s:", from);
  238.     sysError(s);
  239.       } else {
  240.     n_moved = 1;
  241.     dir_prefix(todir, to);
  242.     if ((*todir?chdir(todir):0) || !getwd(todir))
  243.       sysError("System error:");
  244.       }
  245.     }
  246.  
  247.     if (n_moved) {
  248.       markForUpdate(popups.fw->directory); markForUpdate(todir);
  249.       intUpdate();
  250.     }
  251.  
  252.   }
  253.  
  254.  out:
  255.   freeze = False;
  256. }
  257.  
  258. /*---------------------------------------------------------------------------*/
  259.  
  260. static void moveCancelCb(Widget w, FileWindowRec *fw, 
  261.                XtPointer call_data)
  262. {
  263.   XtPopdown(popups.move);
  264.   freeze = False;
  265. }
  266.  
  267. /*---------------------------------------------------------------------------*/
  268.  
  269. static void copyOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  270. {
  271.   struct stat stats;
  272.   int i, toi, n_copied = 0;
  273.   char *from = NULL, to[MAXPATHLEN], todir[MAXPATHLEN];
  274.  
  275.   XtPopdown(popups.copy);
  276.   strcpy(to, popups.s);
  277.   fnexpand(to);
  278.  
  279.   if (chdir(popups.fw->directory))
  280.  
  281.     sysError("System error:");
  282.  
  283.   else {
  284.  
  285.     /* if target exists and is a directory, copy the source into that
  286.        directory */
  287.  
  288.     if (!stat(to, &stats) && S_ISDIR(stats.st_mode)) {
  289.  
  290.       if (chdir(to) || !getwd(to) || chdir(popups.fw->directory)) {
  291.     sysError("System error:");
  292.     goto out;
  293.       } else if (!strcmp(popups.fw->directory, to)) {
  294.     error("Copy:", "Source and destination are identical");
  295.     goto out;
  296.       }
  297.  
  298.       strcpy(todir, to);
  299.  
  300.       toi = strlen(to);
  301.       if (to[toi-1] != '/') {
  302.     to[toi++] = '/';
  303.     to[toi] = '\0';
  304.       }
  305.  
  306.       for (i=0; i < popups.fw->n_files; i++)
  307.     if (popups.fw->files[i]->selected) {
  308.       if (!strcmp(popups.fw->files[i]->name, ".") ||
  309.           !strcmp(popups.fw->files[i]->name, "..")) {
  310.         error("Cannot copy . or ..", "");
  311.         continue;
  312.       }
  313.       from = popups.fw->files[i]->name;
  314.       strcpy(to+toi, from);
  315.       if (exists(to) && resources.confirm_overwrite) {
  316.         char s[0xff];
  317.         sprintf(s, "Copy: file %s already exists at destination", from);
  318.         if (!confirm(s, "Overwrite?", ""))
  319.           if (aborted)
  320.         break;
  321.           else
  322.         continue;
  323.       }
  324.       if (rcopy(from,to)) {
  325.         char s[0xff];
  326.         sprintf(s, "Error moving %s:", to);
  327.         sysError(s);
  328.       } else
  329.         n_copied++;
  330.     }
  331.     }
  332.  
  333.     /* otherwise only a single file may be selected; copy it to the target
  334.        file */
  335.  
  336.     else if (popups.fw->n_selections > 1) {
  337.  
  338.       error("Copy: target for multiple files", "must be a folder");
  339.       goto out;
  340.  
  341.     } else {
  342.  
  343.       struct stat stats1;
  344.  
  345.       for (i = 0; i < popups.fw->n_files; i++)
  346.     if (popups.fw->files[i]->selected) {
  347.       from = popups.fw->files[i]->name;
  348.       break;
  349.     }
  350.  
  351.       if (!strcmp(from, ".") || !strcmp(from, "..")) {
  352.     error("Cannot copy . or ..", "");
  353.     goto out;
  354.       } else if (!lstat(to, &stats) && !lstat(from, &stats1) &&
  355.          stats.st_ino == stats1.st_ino) {
  356.     error("Copy:", "Source and destination are identical");
  357.     goto out;
  358.       }
  359.  
  360.       if (exists(to) && resources.confirm_overwrite) {
  361.     char s[0xff];
  362.     sprintf(s, "Copy: file %s already exists", to);
  363.     if (!confirm(s, "Overwrite?", ""))
  364.       goto out;
  365.       }
  366.  
  367.       if (rcopy(from, to)) {
  368.     char s[0xff];
  369.     sprintf(s, "Error moving %s:", from);
  370.     sysError(s);
  371.       } else {
  372.     n_copied = 1;
  373.     dir_prefix(todir, to);
  374.     if ((*todir?chdir(todir):0) || !getwd(todir))
  375.       sysError("System error:");
  376.       }
  377.     }
  378.  
  379.     if (n_copied) {
  380.       markForUpdate(todir);
  381.       intUpdate();
  382.     }
  383.  
  384.   }
  385.  
  386.  out:
  387.   freeze = False;
  388. }
  389.  
  390. /*---------------------------------------------------------------------------*/
  391.  
  392. static void copyCancelCb(Widget w, FileWindowRec *fw, 
  393.                XtPointer call_data)
  394. {
  395.   XtPopdown(popups.copy);
  396.   freeze = False;
  397. }
  398.  
  399. /*---------------------------------------------------------------------------*/
  400.  
  401. static void linkOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  402. {
  403.   XtPopdown(popups.link);
  404.   fnexpand(popups.s);
  405.   fnexpand(popups.t);
  406.   if (chdir(popups.fw->directory))
  407.     sysError("System error:");
  408.   else if (symlink(popups.t, popups.s)) {
  409.     char s[0xff];
  410.     sprintf(s, "Error creating link %s:", popups.s);
  411.     sysError(s);
  412.   } else {
  413.     char todir[MAXPATHLEN];
  414.     dir_prefix(todir, popups.s);
  415.     if (!chdir(*todir?todir:".") && getwd(todir))
  416.       markForUpdate(todir);
  417.     intUpdate();
  418.   }
  419.   freeze = False;
  420. }
  421.  
  422. /*---------------------------------------------------------------------------*/
  423.  
  424. static void linkCancelCb(Widget w, FileWindowRec *fw, 
  425.                XtPointer call_data)
  426. {
  427.   XtPopdown(popups.link);
  428.   freeze = False;
  429. }
  430.  
  431. /*---------------------------------------------------------------------------*/
  432.  
  433. /* The following variant of fnmatch matches the . and .. dirs only if
  434.    specified explicitly. */
  435.  
  436. #define fnmatchnodot(pattern,fn) (strcmp(fn,".")&&strcmp(fn,"..")? \
  437.                   fnmatch(pattern,fn):!strcmp(pattern,fn))
  438.  
  439. static void selectReplaceCb(Widget w, FileWindowRec *fw, 
  440.                 XtPointer call_data)
  441. {
  442.   int i;
  443.   Pixel pix;
  444.  
  445.   XtPopdown(popups.select);
  446.   popups.fw->n_selections = 0;
  447.   popups.fw->n_bytes_selected = 0;
  448.   for (i=0; i<popups.fw->n_files; i++) {
  449.     if (popups.fw->files[i]->icon.toggle) {
  450.       if (fnmatchnodot(popups.s, popups.fw->files[i]->name)) {
  451.     popups.fw->files[i]->selected = True;
  452.     popups.fw->n_selections++;
  453.     popups.fw->n_bytes_selected += popups.fw->files[i]->stats.st_size;
  454.       }
  455.       else
  456.     popups.fw->files[i]->selected = False;
  457.       XtVaGetValues(popups.fw->files[i]->icon.toggle,
  458.             popups.fw->files[i]->selected?XtNforeground:XtNbackground,
  459.             &pix, NULL);
  460.       XtVaSetValues(popups.fw->files[i]->icon.toggle, XtNborder,
  461.             (XtArgVal) pix, NULL);
  462.     }
  463.   }
  464.   updateStatus(popups.fw);
  465.   freeze = False;
  466. }
  467.  
  468. /*---------------------------------------------------------------------------*/
  469.  
  470. static void selectAddCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  471. {
  472.   int i;
  473.   Pixel pix;
  474.   
  475.   XtPopdown(popups.select);
  476.   for(i=0; i<popups.fw->n_files; i++)
  477.     if (popups.fw->files[i]->icon.toggle) {
  478.       if (!popups.fw->files[i]->selected && 
  479.       (fnmatchnodot(popups.s, popups.fw->files[i]->name))) {
  480.     popups.fw->files[i]->selected = True;
  481.     popups.fw->n_selections++;
  482.     popups.fw->n_bytes_selected += popups.fw->files[i]->stats.st_size;
  483.     XtVaGetValues(popups.fw->files[i]->icon.toggle, XtNforeground, &pix,
  484.               NULL);
  485.     XtVaSetValues(popups.fw->files[i]->icon.toggle, XtNborder,
  486.               (XtArgVal) pix, NULL);
  487.       }
  488.     }
  489.   updateStatus(popups.fw);
  490.   freeze = False;
  491. }
  492.  
  493. /*---------------------------------------------------------------------------*/
  494.  
  495. static void selectRemoveCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  496. {
  497.   int i;
  498.   Pixel pix;
  499.   
  500.   XtPopdown(popups.select);
  501.   for(i=0; i<popups.fw->n_files; i++)
  502.     if (popups.fw->files[i]->icon.toggle) {
  503.       if (popups.fw->files[i]->selected && 
  504.       (fnmatch(popups.s, popups.fw->files[i]->name))) {
  505.     popups.fw->files[i]->selected = False;
  506.     popups.fw->n_selections--;
  507.     popups.fw->n_bytes_selected -= popups.fw->files[i]->stats.st_size;
  508.     XtVaGetValues(popups.fw->files[i]->icon.toggle, XtNbackground, &pix,
  509.               NULL);
  510.     XtVaSetValues(popups.fw->files[i]->icon.toggle, XtNborder,
  511.               (XtArgVal) pix, NULL);
  512.       }
  513.     }
  514.   updateStatus(popups.fw);
  515.   freeze = False;
  516. }
  517.  
  518. /*---------------------------------------------------------------------------*/
  519.  
  520. static void selectCancelCb(Widget w, FileWindowRec *fw, 
  521.                XtPointer call_data)
  522. {
  523.   XtPopdown(popups.select);
  524.   freeze = False;
  525. }
  526.  
  527. /*---------------------------------------------------------------------------
  528.   Button information for popups
  529. ---------------------------------------------------------------------------*/
  530.  
  531. static ButtonRec mkdir_buttons[] = {
  532.   { "ok", "Ok", mkdirOkCb },
  533.   { "cancel", "Cancel", mkdirCancelCb }
  534. };
  535.  
  536. static ButtonRec createFile_buttons[] = {
  537.   { "ok", "Ok", createFileOkCb },
  538.   { "cancel", "Cancel", createFileCancelCb }
  539. };
  540.  
  541. static ButtonRec goTo_buttons[] = {
  542.   { "ok", "Ok", goToOkCb },
  543.   { "cancel", "Cancel", goToCancelCb }
  544. };
  545.  
  546. static ButtonRec move_buttons[] = {
  547.   { "ok", "Ok", moveOkCb },
  548.   { "cancel", "Cancel", moveCancelCb }
  549. };
  550.  
  551. static ButtonRec copy_buttons[] = {
  552.   { "ok", "Ok", copyOkCb },
  553.   { "cancel", "Cancel", copyCancelCb }
  554. };
  555.  
  556. static ButtonRec link_buttons[] = {
  557.   { "ok", "Ok", linkOkCb },
  558.   { "cancel", "Cancel", linkCancelCb }
  559. };
  560.  
  561. static ButtonRec select_buttons[] = {
  562.   { "replace", "Replace", selectReplaceCb },
  563.   { "add", "Add", selectAddCb },
  564.   { "remove", "Remove", selectRemoveCb },
  565.   { "cancel", "Cancel", selectCancelCb }
  566. };
  567.  
  568. /*---------------------------------------------------------------------------
  569.   Question information for popups
  570. ---------------------------------------------------------------------------*/
  571.  
  572. static QuestionRec mkdir_questions[] = {
  573.   { "Create folder:", popups.s, MAXPATHLEN, NULL }
  574. };
  575.  
  576. static QuestionRec createFile_questions[] = {
  577.   { "Create file:", popups.s, MAXPATHLEN, NULL }
  578. };
  579.  
  580. static QuestionRec goTo_questions[] = {
  581.   { "Go to folder:", popups.s, MAXPATHLEN, NULL }
  582. };
  583.  
  584. static QuestionRec move_questions[] = {
  585.   { "Move to:", popups.s, MAXPATHLEN, NULL }
  586. };
  587.  
  588. static QuestionRec copy_questions[] = {
  589.   { "Copy to:", popups.s, MAXPATHLEN, NULL }
  590. };
  591.  
  592. static QuestionRec link_questions[] = {
  593.   { "Link to:", popups.t, MAXPATHLEN, NULL },
  594.   { "Link name:", popups.s, MAXPATHLEN, NULL }
  595. };
  596.  
  597. static QuestionRec select_questions[] = {
  598.   { "Filename pattern:", popups.s, MAXPATHLEN, NULL }
  599. };
  600.  
  601. /*---------------------------------------------------------------------------
  602.   PUBLIC FUNCTIONS
  603. ---------------------------------------------------------------------------*/
  604.  
  605. void createMainPopups()
  606. {
  607.   /* New Folder */
  608.   popups.mkdir = createPopupQuestions("mkdir", "New Folder", bm[DIR_BM], 
  609.                    mkdir_questions, XtNumber(mkdir_questions),
  610.                    mkdir_buttons, XtNumber(mkdir_buttons) );
  611.  
  612.   /* New File */
  613.   popups.createFile = createPopupQuestions("create", "New File", bm[FILE_BM],
  614.                    createFile_questions,
  615.                    XtNumber(createFile_questions),
  616.                    createFile_buttons,
  617.                    XtNumber(createFile_buttons) );
  618.  
  619.   /* Change current folder */
  620.   popups.goTo = createPopupQuestions("goto", "Go To", bm[DIR_BM],
  621.                    goTo_questions, XtNumber(goTo_questions),
  622.                    goTo_buttons, XtNumber(goTo_buttons) );
  623.  
  624.   /* Move file */
  625.   popups.move = createPopupQuestions("move", "Move", bm[FILES_BM], 
  626.                    move_questions, XtNumber(move_questions),
  627.                    move_buttons, XtNumber(move_buttons) );
  628.  
  629.   /* Copy file */
  630.   popups.copy = createPopupQuestions("copy", "Copy", bm[FILES_BM],
  631.                    copy_questions, XtNumber(copy_questions),
  632.                    copy_buttons, XtNumber(copy_buttons) );
  633.  
  634.   /* Create link */
  635.   popups.link = createPopupQuestions("link", "Link", bm[SYMLNK_BM],
  636.                    link_questions, XtNumber(link_questions),
  637.                    link_buttons, XtNumber(link_buttons) );
  638.  
  639.   /* Select */
  640.   popups.select = createPopupQuestions("select", "Select", bm[FILES_BM],
  641.                    select_questions, XtNumber(select_questions),
  642.                    select_buttons, XtNumber(select_buttons) );
  643.  
  644.   /* Change Access Mode */
  645.   createChmodPopup();
  646.  
  647.   /* Info */
  648.   createInfoPopup();
  649.  
  650.   /* Errors */
  651.   createErrorPopup();
  652.  
  653.   /* Deletions */
  654.   createConfirmPopup();
  655. }
  656.  
  657. /*---------------------------------------------------------------------------*/ 
  658.  
  659. void selectPopup(Widget w, FileWindowRec *fw, XtPointer call_data)
  660. {
  661.   popups.fw = fw;
  662.   popups.s[0] = '\0';
  663.   XtVaSetValues(select_questions[0].widget, XtNstring, 
  664.         (XtArgVal) popups.s, NULL);
  665.   freeze = True;
  666.   popupByCursor(popups.select, XtGrabExclusive);
  667. }
  668.  
  669. /*---------------------------------------------------------------------------*/
  670.  
  671. void mkdirPopup(Widget w, FileWindowRec *fw, XtPointer call_data)
  672. {
  673.   popups.fw = fw;
  674.   popups.s[0] = '\0';
  675.   XtVaSetValues(mkdir_questions[0].widget, XtNstring, 
  676.         (XtArgVal) popups.s, NULL);
  677.   freeze = True;
  678.   popupByCursor(popups.mkdir, XtGrabExclusive);
  679. }
  680.  
  681. /*---------------------------------------------------------------------------*/
  682.  
  683. void createFilePopup(Widget w, FileWindowRec *fw, XtPointer call_data)
  684. {
  685.   popups.fw = fw;
  686.   popups.s[0] = '\0';
  687.   XtVaSetValues(createFile_questions[0].widget, XtNstring, 
  688.         (XtArgVal) popups.s, NULL);
  689.   freeze = True;
  690.   popupByCursor(popups.createFile, XtGrabExclusive);
  691. }
  692.  
  693. /*---------------------------------------------------------------------------*/
  694.  
  695. void goToPopup(Widget w, FileWindowRec *fw, XtPointer call_data)
  696. {
  697.   popups.fw = fw;
  698.   popups.s[0] = '\0';
  699.   XtVaSetValues(goTo_questions[0].widget, XtNstring, 
  700.         (XtArgVal) popups.s, NULL);
  701.   freeze = True;
  702.   popupByCursor(popups.goTo, XtGrabExclusive);
  703. }
  704.  
  705. /*---------------------------------------------------------------------------*/
  706.  
  707. void movePopup(Widget w, FileWindowRec *fw, XtPointer call_data)
  708. {
  709.   if (fw == NULL) fw = popup_fw;
  710.  
  711.   if (!fw->n_selections) return;
  712.  
  713.   popups.fw = fw;
  714.   popups.s[0] = '\0';
  715.   XtVaSetValues(move_questions[0].widget, XtNstring, 
  716.         (XtArgVal) popups.s, NULL);
  717.   freeze = True;
  718.   popupByCursor(popups.move, XtGrabExclusive);
  719. }
  720.  
  721. /*---------------------------------------------------------------------------*/
  722.  
  723. void copyPopup(Widget w, FileWindowRec *fw, XtPointer call_data)
  724. {
  725.   if (fw == NULL) fw = popup_fw;
  726.  
  727.   if (!fw->n_selections) return;
  728.  
  729.   popups.fw = fw;
  730.   popups.s[0] = '\0';
  731.   XtVaSetValues(copy_questions[0].widget, XtNstring, 
  732.         (XtArgVal) popups.s, NULL);
  733.   freeze = True;
  734.   popupByCursor(popups.copy, XtGrabExclusive);
  735. }
  736.  
  737. /*---------------------------------------------------------------------------*/
  738.  
  739. void linkPopup(Widget w, FileWindowRec *fw, XtPointer call_data)
  740. {
  741.   if (fw == NULL) fw = popup_fw;
  742.  
  743.   popups.fw = fw;
  744.   popups.s[0] = popups.t[0] = '\0';
  745.   XtVaSetValues(link_questions[0].widget, XtNstring, 
  746.         (XtArgVal) popups.t, NULL);
  747.   XtVaSetValues(link_questions[1].widget, XtNstring, 
  748.         (XtArgVal) popups.s, NULL);
  749.   freeze = True;
  750.   popupByCursor(popups.link, XtGrabExclusive);
  751. }
  752.