home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / xap / xfm / xfm-1.000 / xfm-1 / xfm-1.3.2 / src / FmAwPopup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-25  |  5.7 KB  |  189 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_app_popup, install_group_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 installAppOkCb, installAppCancelCb,
  35. installGroupOkCb, installGroupCancelCb;
  36.  
  37. static void installAppOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  38. {
  39.   XtPopdown(install_app_popup);
  40.  
  41.   if (app_number != -1)
  42.     replaceApplication(aw.apps+app_number, app_name, app_directory, app_fname,
  43.                app_icon, app_push_action, app_drop_action);
  44.   else
  45.     installApplication(app_name, app_directory, app_fname, app_icon,
  46.                app_push_action, app_drop_action);
  47.  
  48.   updateApplicationDisplay();
  49.   writeApplicationData(resources.app_file);
  50. }
  51.  
  52. /*---------------------------------------------------------------------------*/
  53.  
  54. static void installAppCancelCb(Widget w, FileWindowRec *fw, 
  55.                    XtPointer call_data)
  56. {
  57.   XtPopdown(install_app_popup);
  58. }
  59.  
  60. /*---------------------------------------------------------------------------*/
  61.  
  62. static void installGroupOkCb(Widget w, FileWindowRec *fw, XtPointer call_data)
  63. {
  64.   XtPopdown(install_group_popup);
  65.  
  66.   installApplication(app_name, resources.app_dir, app_fname, app_icon,
  67.              "LOAD", "");
  68.  
  69.   updateApplicationDisplay();
  70.   writeApplicationData(resources.app_file);
  71. }
  72.  
  73. /*---------------------------------------------------------------------------*/
  74.  
  75. static void installGroupCancelCb(Widget w, FileWindowRec *fw, 
  76.                    XtPointer call_data)
  77. {
  78.   XtPopdown(install_group_popup);
  79. }
  80.  
  81. /*---------------------------------------------------------------------------
  82.   Question and button data
  83. ---------------------------------------------------------------------------*/
  84.  
  85. static QuestionRec install_app_questions[] = {
  86.   { "Name:", app_name, MAXAPPSTRINGLEN, NULL },
  87.   { "Directory:", app_directory, MAXAPPSTRINGLEN, NULL },
  88.   { "File name:", app_fname, MAXAPPSTRINGLEN, NULL },
  89.   { "Icon:", app_icon, MAXAPPSTRINGLEN, NULL },
  90.   { "Push action:", app_push_action, MAXAPPSTRINGLEN, NULL },
  91.   { "Drop action:", app_drop_action, MAXAPPSTRINGLEN, NULL }
  92. };
  93.  
  94. static ButtonRec install_app_buttons[] = {
  95.   { "install", "Install", installAppOkCb },
  96.   { "cancel", "Cancel", installAppCancelCb }
  97. };
  98.  
  99. static QuestionRec install_group_questions[] = {
  100.   { "Name:", app_name, MAXAPPSTRINGLEN, NULL },
  101.   { "File name:", app_fname, MAXAPPSTRINGLEN, NULL },
  102.   { "Icon:", app_icon, MAXAPPSTRINGLEN, NULL }
  103. };
  104.  
  105. static ButtonRec install_group_buttons[] = {
  106.   { "install", "Install", installGroupOkCb },
  107.   { "cancel", "Cancel", installGroupCancelCb }
  108. };
  109.  
  110. /*---------------------------------------------------------------------------
  111.   PUBLIC FUNCTIONS
  112. ---------------------------------------------------------------------------*/
  113.  
  114. void createInstallPopups()
  115. {
  116.   install_app_popup = createPopupQuestions("install app",
  117.                        "Install Application",
  118.                        None,
  119.                        install_app_questions,
  120.                        XtNumber(install_app_questions),
  121.                        install_app_buttons,
  122.                        XtNumber(install_app_buttons));
  123.   install_group_popup = createPopupQuestions("install group",
  124.                          "Install Group",
  125.                          None,
  126.                          install_group_questions,
  127.                          XtNumber(install_group_questions),
  128.                          install_group_buttons,
  129.                          XtNumber(install_group_buttons));
  130. }
  131.  
  132. /*----------------------------------------------------------------------------*/
  133.  
  134. void installNewAppPopup()
  135. {
  136.   register int i;
  137.  
  138.   for (i=0; i < XtNumber(install_app_questions); i++) {
  139.     install_app_questions[i].value[0] = '\0';
  140.     XtVaSetValues(install_app_questions[i].widget, XtNstring, 
  141.           install_app_questions[i].value, NULL);
  142.   }
  143.  
  144.   app_number = -1;
  145.  
  146.   popupByCursor(install_app_popup, XtGrabExclusive);
  147. }
  148.  
  149. /*----------------------------------------------------------------------------*/
  150.  
  151. void installExistingAppPopup()
  152. {
  153.   register int i;
  154.  
  155.   for (i=0; i<aw.n_apps; i++)
  156.     if (aw.apps[i].selected) {
  157.       app_number = i;
  158.       strcpy(install_app_questions[0].value, aw.apps[i].name);
  159.       strcpy(install_app_questions[1].value, aw.apps[i].directory);
  160.       strcpy(install_app_questions[2].value, aw.apps[i].fname);
  161.       strcpy(install_app_questions[3].value, aw.apps[i].icon);
  162.       strcpy(install_app_questions[4].value, aw.apps[i].push_action);
  163.       strcpy(install_app_questions[5].value, aw.apps[i].drop_action);
  164.       break;
  165.     }
  166.  
  167.   for (i=0; i < XtNumber(install_app_questions); i++) {
  168.     XtVaSetValues(install_app_questions[i].widget, XtNstring, 
  169.           install_app_questions[i].value, NULL);
  170.   }
  171.  
  172.   popupByCursor(install_app_popup, XtGrabExclusive);
  173. }
  174.  
  175. /*----------------------------------------------------------------------------*/
  176.  
  177. void installGroupPopup()
  178. {
  179.   register int i;
  180.  
  181.   for (i=0; i < XtNumber(install_group_questions); i++) {
  182.     install_group_questions[i].value[0] = '\0';
  183.     XtVaSetValues(install_group_questions[i].widget, XtNstring, 
  184.           install_group_questions[i].value, NULL);
  185.   }
  186.  
  187.   popupByCursor(install_group_popup, XtGrabExclusive);
  188. }
  189.