GtkTargetList  *targetList;
GtkTargetList  *targetList = NULL;
GtkTargetList *targetListFromTransArr(nsISupportsArray *inArray){  if (inArray == nsnull)    return NULL;  nsVoidArray targetArray;  GtkTargetEntry *targets;  GtkTargetList  *targetList;  PRUint32 targetCount = 0;  unsigned int numDragItems = 0;  inArray->Count(&numDragItems);  for (unsigned int itemIndex = 0; itemIndex < numDragItems; ++itemIndex) {    nsCOMPtr<nsISupports> genericItem;    inArray->GetElementAt(itemIndex, getter_AddRefs(genericItem));    nsCOMPtr<nsITransferable> currItem (do_QueryInterface(genericItem));    if (currItem) {      nsCOMPtr <nsISupportsArray> flavorList;      if ( NS_SUCCEEDED(currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList))) ) {        PRUint32 numFlavors;        flavorList->Count( &numFlavors );        for ( unsigned int flavorIndex = 0; flavorIndex < numFlavors ; ++flavorIndex ) {          nsCOMPtr<nsISupports> genericWrapper;          flavorList->GetElementAt (flavorIndex, getter_AddRefs(genericWrapper));          nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericWrapper) );          if (currentFlavor) {            nsXPIDLCString flavorStr;            currentFlavor->ToString ( getter_Copies(flavorStr) );            // get the atom            GdkAtom atom = gdk_atom_intern(flavorStr, FALSE);            GtkTargetEntry *target = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry));            target->target = g_strdup(flavorStr);            target->flags = 0;            target->info = atom;#ifdef DEBUG_DD            g_print("adding target %s with id %ld\n", target->target, atom);#endif            targetArray.AppendElement(target);          }        } // foreach flavor in item                    } // if valid flavor list    } // if item is a transferable  }  // get all the elements that we created.  targetCount = targetArray.Count();  if (targetCount) {    // allocate space to create the list of valid targets    targets = (GtkTargetEntry *)g_malloc(sizeof(GtkTargetEntry) * targetCount);    for (PRUint32 targetIndex = 0; targetIndex < targetCount; ++targetIndex) {      GtkTargetEntry *disEntry = (GtkTargetEntry *)targetArray.ElementAt(targetIndex);      // this is a string reference but it will be freed later.      targets[targetIndex].target = disEntry->target;      targets[targetIndex].flags = disEntry->flags;      targets[targetIndex].info = disEntry->info;    }    targetList = gtk_target_list_new(targets, targetCount);    // clean up the target list    for (PRUint32 cleanIndex = 0; cleanIndex < targetCount; ++cleanIndex) {      GtkTargetEntry *thisTarget = (GtkTargetEntry *)targetArray.ElementAt(cleanIndex);      g_free(thisTarget->target);      g_free(thisTarget);    }  }  return targetList;}