home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / dtr / dtrutils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  6.3 KB  |  211 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/DTR/RCS/dtrutils.c,v 1.10 92/01/09 12:41:47 drapeau Exp Locker: derek $ */
  25. /* $Log:    dtrutils.c,v $
  26.  * Revision 1.10  92/01/09  12:41:47  drapeau
  27.  * Slight modifications to the code to make it ANSI-compliant.
  28.  * 
  29.  * Revision 1.0  92/01/06  17:49:23  drapeau
  30.  * Deleted AlertStatus(), since it is no longer needed.
  31.  * Added functions UpdateHeader() and UpdateEditListHeader(), functions that
  32.  * are responsible for displaying the currently opened sound file or
  33.  * DTR edit list.
  34.  * Also, Made a number of cosmetic changes to make code easier to read and
  35.  * to conform to programming specifications.
  36.  * 
  37.  * Revision 0.18  91/09/30  16:13:10  derek
  38.  * DTR will now disconnect from the Port Manager when it quits.  Also,
  39.  * a number of printf statements are removed.
  40.  * 
  41.  * Revision 0.17  91/09/18  22:47:22  derek
  42.  * The following things are done:
  43.  * 1.    The Makefile is changed corresponding to the changes in collab/.
  44.  * 2.    Copyright messages included.
  45.  * 3.    Some minor bugs fixed.
  46.  * 
  47.  * Revision 0.16  91/08/21  11:34:14  derek
  48.  * The following changes are made:
  49.  * 1.    Now the duration and size of the recorded sound will be displayed
  50.  *     during recording.
  51.  * 2.    I have changed GetSelection() corresponding to the request of Tek joo
  52.  * 3.    Info Panel is added to the application.
  53.  * 4.    Fixed SizeToFitHandler() so that when no file or buffer is currently
  54.  *     loaded, it would not do anything (except giving a warning
  55.  *     notice_prompt).
  56.  * 5.    Inplemented the `Close' Menu option in the document menu.
  57.  * 6.    Fixed the bug in which after ClearAll and I press PreviewEdit,
  58.  *     the edit wont be played.
  59.  * 7.    I have made the changes corresponding to the change in OpenPanel's
  60.  *     name.  (from OpenPanel to Browse).
  61.  * 8.    Incorporated BrowseCheck to check command line arg.
  62.  * 9.    Changed most EditingStatusMessages to NoticePrompts.
  63.  * 10.    SoundFileSaveAsPopUp and EditListSaveAsPopUp are removed 
  64.  *     from the application.
  65.  * 
  66.  * Revision 0.15  91/08/07  16:24:09  derek
  67.  * The Edit list part of DTR is done.  OpenPanel is also incorporated.
  68.  * 
  69.  * Revision 0.14  91/07/31  14:50:58  derek
  70.  * I have changed the user interface so that text fields like size and
  71.  * duration will be displayed in normal (not bold) format.   I also fixed
  72.  * a network bug.  In addition, I have added a routine to check how
  73.  * much disk space is left in /usr/tmp.
  74.  * 
  75.  * Revision 0.13  91/06/26  15:56:17  derek
  76.  * I have reformatted the code to conform coding specs.
  77.  * 
  78.  * Revision 0.12  91/06/25  11:39:43  derek
  79.  * I have added the new protocol items.
  80.  * 
  81.  * Revision 0.11  91/06/05  14:59:50  derek
  82.  * checking in after porting the code to collab
  83.  * 
  84.  * Revision 0.10  1991/04/25  01:47:48  derek
  85.  * This version is checked in on 4/24/91
  86.  * */
  87. static char rcsid[] = "$Header: /Source/Media/collab/DTR/RCS/dtrutils.c,v 1.10 92/01/09 12:41:47 drapeau Exp Locker: derek $";
  88.  
  89. #include "dtr.h"
  90. #include "dtr_ui.h"
  91.  
  92. extern  dtr_mainWindow_objects *dtr_mainWindow;
  93.  
  94.  
  95. /*
  96.  * Alert:  takes an object and a message and calls xv_set
  97.  *         to set the corresponding text field.
  98.  */
  99. void
  100.   Alert(object, message)
  101. Xv_object object;
  102. char      *message;
  103. {
  104.   xv_set(object, PANEL_LABEL_STRING, message, NULL);
  105. }
  106.  
  107.  
  108. /*
  109.  * Give null messages to all the message fields: size, duration, 
  110.  * editing status.
  111.  */
  112. void
  113.   ClearMessageDisplay()
  114. {
  115.   sprintf(msg, "");
  116.   Alert(dtr_mainWindow->sizeMessage, msg);
  117.   Alert(dtr_mainWindow->selectionSizeMessage, msg);
  118.   Alert(dtr_mainWindow->durationMessage, msg);
  119.   Alert(dtr_mainWindow->selectionDurationMessage, msg);
  120. }
  121.  
  122.  
  123. /*
  124.  *  Check for Null filename.
  125.  */
  126. BOOL
  127.   NullFileName(name)
  128. char *name;
  129. {
  130.   return(strcmp(name, "\0") == 0
  131.      || strcmp(name, "") == 0);
  132. }
  133.  
  134.  
  135. void
  136.   AlertByNoticePrompt(control, message)
  137. Xv_Window    control;
  138. char        *message;
  139. {
  140.   notice_prompt(control, NULL,
  141.         NOTICE_MESSAGE_STRINGS, message, NULL,
  142.         NOTICE_BUTTON, "OK", 'O',
  143.         NULL);
  144. }
  145.  
  146.  
  147. Notify_value
  148.   DestroyMainWindow(client, status)
  149. Notify_client client;
  150. Destroy_status status;
  151. {
  152.   if (BufferSaved == FALSE)
  153.   {
  154.     int    reply;
  155.       
  156.     reply = notice_prompt(dtr_mainWindow->menuControlPanel, NULL,
  157.               NOTICE_MESSAGE_STRINGS,
  158.               "Buffer not saved yet.",
  159.               "Quit Anyway?",
  160.               NULL,
  161.               NOTICE_BUTTON, "Yes", 'Y',
  162.               NOTICE_BUTTON, "Cancel", 'C',
  163.               NULL);
  164.     if (reply == 'C')
  165.       return NOTIFY_DONE;
  166.   }
  167.  
  168.   AudioFlushClose();
  169.   RemoveSoundFileInTmp();
  170.   SenderDisconnectFromPortMgr(sender, &(receiver->receivePort));
  171.   exit(0);
  172. }
  173.  
  174.  
  175. void UpdateHeader(int modified)
  176. {
  177.   char                    label[100];
  178.   
  179.   if (modified == TRUE)
  180.   {
  181.     BufferSaved == FALSE;
  182.     sprintf(label, "Digital Tape Recorder : \"%s\" (modified)",
  183.         currentSoundFile);
  184.   }
  185.   
  186.   else
  187.   {
  188.     BufferSaved == TRUE;
  189.     sprintf(label, "Digital Tape Recorder : \"%s\"",
  190.         currentSoundFile);
  191.   }
  192.   xv_set(dtr_mainWindow->mainWindow, XV_LABEL, label, NULL);
  193.   return;
  194. }                                    /* end function UpdateHeader */
  195.  
  196.  
  197. void UpdateEditListHeader(int modified)
  198. {
  199.   extern dtr_editListPanelPopUp_objects*    dtr_editListPanelPopUp;
  200.   char                        label[100];
  201.   
  202.   if (modified == TRUE)
  203.     sprintf(label, "DTR Edit List : \"%s\" (modified)",
  204.         absoluteEditListName);
  205.   else
  206.     sprintf(label, "DTR Edit List : \"%s\"",
  207.         absoluteEditListName);
  208.   xv_set(dtr_editListPanelPopUp->editListPanelPopUp, XV_LABEL, label, NULL);
  209.   return;
  210. }                                    /* end function UpdateHeader */
  211.