home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / x / tcommands.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-04  |  3.2 KB  |  148 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  2.    No guarantees or restrictions.  See the readme file for the full standard
  3.    disclaimer.
  4.  
  5.    This is part of the X user-interface for the WAIS software.  Do with it
  6.    as you please.
  7.  
  8.    jonathan@Think.COM
  9. */
  10.  
  11. /* Copyright (c) CNIDR (see ../COPYRIGHT) */
  12.  
  13. /*
  14.  * $Log: tcommands.c,v $
  15.  * Revision 1.2  1994/08/05  07:27:06  pfeifer
  16.  * Release beta 04
  17.  *
  18.  * Revision 1.1  1993/02/16  15:10:18  freewais
  19.  * Initial revision
  20.  *
  21.  * Revision 1.6  92/04/28  15:31:18  jonathan
  22.  * Cleaned up use of scrollList.
  23.  * 
  24.  * Revision 1.5  92/03/17  14:17:18  jonathan
  25.  * Generally cleaned up.
  26.  * 
  27.  */
  28.  
  29. #ifndef lint
  30. static char *RCSid = "$Header: /usr/local/ls6/src+data/src/freeWAIS-sf/x/RCS/tcommands.c,v 1.2 1994/08/05 07:27:06 pfeifer Exp $";
  31. #endif
  32.  
  33. #define _C_TCOMMANDS
  34. #define XWAIS
  35. #include "xwais.h"
  36.  
  37. static Boolean editting_new_question;
  38. static int last_question = NO_ITEM_SELECTED;
  39. extern int last_source;
  40.  
  41. int get_selected_question()
  42. {
  43.   return(get_selected_item(questionwindow->ListWidget));
  44. }
  45.  
  46. /* ARGSUSED */
  47. void
  48. EditQuestion(w, closure, call_data)
  49. Widget w;
  50. XtPointer closure, call_data;
  51. {
  52.   char msg[STRINGSIZE];
  53.   int CurrentQuestion;
  54.  
  55.   double_click = FALSE;
  56.   LastClicked = w;
  57.  
  58.   if((CurrentQuestion = get_selected_question())
  59.      != NO_ITEM_SELECTED) {
  60. #ifdef MOTIF
  61.     last_question = CurrentQuestion;
  62. #endif
  63.     if (CurrentQuestion == last_question) {
  64.       sprintf(msg, "Opening question: %s\n", Question_items[CurrentQuestion]);
  65.       XwaisPrintf(msg);
  66.       sprintf(msg, "xwaisq \"%s\" &", Question_items[CurrentQuestion]);
  67.       system(msg);
  68.     }
  69.     else last_question = CurrentQuestion;
  70.   }
  71.   else {
  72.     last_question = -1;
  73.     if (NumQuestions > 0)
  74.       XwaisPrintf("No question selected.\nPlease select one and try again.\n");
  75.     else {
  76.       XwaisPrintf("Opening new question\n");
  77.       system("xwaisq &");
  78.     }
  79.   }
  80. }
  81.  
  82. /* ARGSUSED */
  83. void
  84. AddQuestion(w, closure, call_data)
  85. Widget w;
  86. XtPointer closure, call_data;
  87. {
  88.   Question new;
  89.  
  90.   double_click = FALSE;
  91.   LastClicked = w;
  92.  
  93.   XwaisPrintf("Opening new question\n");
  94.   system("xwaisq &");
  95. }
  96.  
  97. void
  98. DeleteQuestion(w, closure, call_data)
  99. Widget w;
  100. XtPointer closure, call_data;
  101. {
  102.   char msg[STRINGSIZE];
  103.   int CurrentQuestion;
  104.  
  105.   double_click = FALSE;
  106.   LastClicked = w;
  107.  
  108.   if((CurrentQuestion = get_selected_question())
  109.      != NO_ITEM_SELECTED) {
  110.     sprintf(msg, "%s%s",
  111.         app_resources.questionDirectory,
  112.         Question_items[CurrentQuestion]);
  113.     if(unlink(msg) != 0)
  114.       XwaisPrintf("Error delete Question.\n");
  115.  
  116.     last_question = NO_ITEM_SELECTED;
  117.     ScanDirs(NULL, NULL);
  118.   }
  119.   else
  120.     XwaisPrintf("No question selected.\nPlease select one and try again.\n");
  121. }
  122.  
  123. void
  124. DeleteSource(w, closure, call_data)
  125. Widget w;
  126. XtPointer closure, call_data;
  127. {
  128.   char msg[STRINGSIZE];
  129.  
  130.   double_click = FALSE;
  131.   LastClicked = w;
  132.  
  133.   if(get_selected_source() != NO_ITEM_SELECTED) {
  134.     sprintf(msg, "%s%s",
  135.         app_resources.userSourceDirectory,
  136.         Source_items[get_selected_source()]);
  137.  
  138.     if (unlink(msg) != 0)
  139.       XwaisPrintf("Error deleting source.\n");
  140.     else {
  141.       last_source = NO_ITEM_SELECTED;
  142.       XawListUnhighlight(sourcewindow->ListWidget);
  143.     }
  144.   }
  145.   else
  146.     XwaisPrintf("No source selected.\nPlease select one and try again.\n");
  147. }
  148.