/*========================================================================
   Utilmen.c - Utility menu functions are in this module.  Might want
   to break it up into two pieces later.   For now,  we keep just one
========================================================================*/
 
/*  The usual header files to be inserted later  */
#include <intuition/intuition.h>
#include <libraries/dosextens.h>
#include <graphics/gfxbase.h>
#include <graphics/gfx.h>
#include <graphics/display.h>
#include <exec/memory.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>
#include <devices/narrator.h>
#include <devices/audio.h>
#include <libraries/translator.h>
 
/* constants */
 
/* external functions */
 
/* external variables */
extern struct Gadget *gads[];
extern char *gadnames[];
extern int nextgad;
extern struct Window *w;
extern int link;    /* Do not add gadget unless told to */
 
/* global vars */
 
int nextlink = 0;      /* Next link */
 
/*----------------------------------------------------------------------
  Link Gadgets to the window.  Sets a global var "lastlinked", so it
  can keep track of what was already linked to the list.
-----------------------------------------------------------------------*/
 
linkgadgets()
{
    int i;
    if (nextgad != NULL || link == TRUE) {
      for (i= nextlink; i<nextgad; i++) {
 
         if (gads[i]->GadgetType > 0 ||
             gads[i]->GadgetType < 4 ) {
                   AddGadget(w, gads[i], -1L);
                   nextlink++;
         }
         else {
            kprintf("Enter gadget type first!!!\n");
            link = FALSE;
            return();
         }
      }
      if (link) {
        RefreshGadgets(gads[0], w, NULL);
      }
      link = FALSE;
   }
   else {
kprintf("Bad news!!! nextgad is %d\n", nextgad);
 
   }
}
                                                                                              