home *** CD-ROM | disk | FTP | other *** search
/ Audio Version 4.94 / audioversion4.94knowledgemediaresourcelibraryoctober1994.iso / amiga / utils / exp_iv / workbnch.c < prev   
C/C++ Source or Header  |  1991-05-09  |  1KB  |  76 lines

  1. /* workbench.c */
  2.  
  3. /* appwindow interface */
  4.  
  5. /*
  6.  * $Author: Espie $
  7.  * $Date: 91/05/10 00:03:16 $
  8.  * $Revision: 1.2 $
  9.  * $Log:    workbench.c,v $
  10.  * Revision 1.2  91/05/10  00:03:16  Espie
  11.  * Corrected a memory leak. We now close the appwindow correctly.
  12.  * 
  13.  * Revision 1.1  91/05/09  17:38:28  Espie
  14.  * Initial revision
  15.  * 
  16.  *
  17.  */
  18.  
  19. #include <exec/types.h>
  20. #include <workbench/workbench.h>
  21. #include <dos/dos.h>
  22. #include <proto/exec.h>
  23. #include <proto/wb.h>
  24. #include <custom/cleanup.h>
  25.  
  26. #include "player.h"
  27. #include "proto.h"
  28.  
  29. LOCAL struct MsgPort *port;
  30. LOCAL struct AppWindow *app;
  31.  
  32. LOCAL void doremovewindow(void)
  33.     {
  34.     struct AppMessage *msg;
  35.         while((msg = GetMsg(port)) || !RemoveAppWindow(app))
  36.             if (msg)
  37.                 ReplyMsg(msg);
  38.     }
  39.     
  40. ULONG init_appwindow(struct Window *w)
  41.     {
  42.         if (!wb_around())
  43.             return NULL;
  44.         port = CreatePort(NULL, 0);
  45.         if (port)
  46.             ToClean(DeletePort, port);
  47.         else
  48.             return 0;
  49.         app = AddAppWindow(1, 0, w, port, TAG_END);
  50.         if (app)
  51.             ToClean0(doremovewindow);
  52.         else
  53.             return 0;
  54.         return 1L <<port->mp_SigBit;
  55.     }
  56.     
  57.     
  58. void handle_app(void)
  59.     {
  60.     struct AppMessage *msg;
  61.         if (!port)
  62.             return;
  63.         while(msg = GetMsg(port))
  64.             {
  65.                 if (msg->am_Type != MTYPE_APPWINDOW)
  66.                     {
  67.                         ReplyMsg(msg);
  68.                         continue;
  69.                     }
  70.                 add_some_songs(msg);
  71.             }
  72.             /* kludge to get song to start... */
  73.         handle_interface();
  74.     }    
  75.     
  76.