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 / FmAwPopup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-30  |  3.9 KB  |  129 lines

  1. /*---------------------------------------------------------------------------
  2.  Module FmAwPopup
  3.  
  4.  (c) Simon Marlow 1990-92
  5.  (c) Albert Graef 1994
  6.  
  7.  Functions & data for creating the popup 'install application' window
  8. ---------------------------------------------------------------------------*/
  9.  
  10. #include <string.h>
  11.  
  12. #include <X11/Intrinsic.h>
  13. #include <X11/StringDefs.h>
  14. #include <X11/Xmu/Drawing.h>
  15.  
  16. #include "Am.h"
  17.  
  18. /*---------------------------------------------------------------------------
  19.   STATIC DATA
  20. ---------------------------------------------------------------------------*/
  21.  
  22. static Widget install_popup;
  23.  
  24. static int app_number;
  25.  
  26. static char app_name[MAXAPPSTRINGLEN], app_directory[MAXAPPSTRINGLEN],
  27.   app_fname[MAXAPPSTRINGLEN], app_icon[MAXAPPSTRINGLEN],
  28.   app_push_action[MAXAPPSTRINGLEN], app_drop_action[MAXAPPSTRINGLEN];
  29.  
  30. /*---------------------------------------------------------------------------
  31.   PRIVATE FUNCTIONS
  32. ---------------------------------------------------------------------------*/
  33.  
  34. static FmCallbackProc installOkCb, installCancelCb;
  35.  
  36. static void installOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  37. {
  38.   XtPopdown(install_popup);
  39.  
  40.   if (app_number != -1)
  41.     replaceApplication(aw.apps+app_number, app_name, app_directory, app_fname,
  42.                app_icon, app_push_action, app_drop_action);
  43.   else
  44.     installApplication(app_name, app_directory, app_fname, app_icon,
  45.                app_push_action, app_drop_action);
  46.  
  47.   updateApplicationDisplay();
  48. }
  49.  
  50. /*---------------------------------------------------------------------------*/
  51.  
  52. static void installCancelCb(Widget w, FileWindowRec *fw, 
  53.                 XtPointer call_data)
  54. {
  55.   XtPopdown(install_popup);
  56. }
  57.  
  58. /*---------------------------------------------------------------------------
  59.   Question and button data
  60. ---------------------------------------------------------------------------*/
  61.  
  62. static QuestionRec install_questions[] = {
  63.   { "Name:", app_name, MAXAPPSTRINGLEN, NULL },
  64.   { "Directory:", app_directory, MAXAPPSTRINGLEN, NULL },
  65.   { "File name:", app_fname, MAXAPPSTRINGLEN, NULL },
  66.   { "Icon:", app_icon, MAXAPPSTRINGLEN, NULL },
  67.   { "Push action:", app_push_action, MAXAPPSTRINGLEN, NULL },
  68.   { "Drop action:", app_drop_action, MAXAPPSTRINGLEN, NULL }
  69. };
  70.  
  71. static ButtonRec install_buttons[] = {
  72.   { "install", "Install", installOkCb },
  73.   { "cancel", "Cancel", installCancelCb }
  74. };
  75.  
  76. /*---------------------------------------------------------------------------
  77.   PUBLIC FUNCTIONS
  78. ---------------------------------------------------------------------------*/
  79.  
  80. void createInstallPopup()
  81. {
  82.   install_popup = createPopupQuestions("install", "Install Application", None,
  83.                install_questions, XtNumber(install_questions),
  84.                install_buttons, XtNumber(install_buttons));
  85. }
  86.  
  87. /*----------------------------------------------------------------------------*/
  88.  
  89. void installNewPopup()
  90. {
  91.   register int i;
  92.  
  93.   for (i=0; i < XtNumber(install_questions); i++) {
  94.     install_questions[i].value[0] = '\0';
  95.     XtVaSetValues(install_questions[i].widget, XtNstring, 
  96.           install_questions[i].value, NULL);
  97.   }
  98.  
  99.   app_number = -1;
  100.  
  101.   popupByCursor(install_popup, XtGrabExclusive);
  102. }
  103.  
  104. /*----------------------------------------------------------------------------*/
  105.  
  106. void installExistingPopup()
  107. {
  108.   register int i;
  109.  
  110.   for (i=0; i<aw.n_apps; i++)
  111.     if (aw.apps[i].selected) {
  112.       app_number = i;
  113.       strcpy(install_questions[0].value, aw.apps[i].name);
  114.       strcpy(install_questions[1].value, aw.apps[i].directory);
  115.       strcpy(install_questions[2].value, aw.apps[i].fname);
  116.       strcpy(install_questions[3].value, aw.apps[i].icon);
  117.       strcpy(install_questions[4].value, aw.apps[i].push_action);
  118.       strcpy(install_questions[5].value, aw.apps[i].drop_action);
  119.       break;
  120.     }
  121.  
  122.   for (i=0; i < XtNumber(install_questions); i++) {
  123.     XtVaSetValues(install_questions[i].widget, XtNstring, 
  124.           install_questions[i].value, NULL);
  125.   }
  126.  
  127.   popupByCursor(install_popup, XtGrabExclusive);
  128. }
  129.