Example #1
0
BOOL WriteIcon(char *name) {
  struct DiskObject *dobj;
  char *olddeftool;
  char **oldtooltypes;
  BOOL success = FALSE;

  /* Use the already present icon */
  
  dobj=GetDiskObject(name);
  
  if( dobj != NULL ) {
    oldtooltypes = dobj->do_ToolTypes;
    olddeftool = dobj->do_DefaultTool;

    dobj->do_ToolTypes = toolTypes;
    dobj->do_DefaultTool = deftoolname;

    success = PutDiskObject(name,dobj);

    /* we must restore the original pointers before freeing */
    dobj->do_ToolTypes = oldtooltypes;
    dobj->do_DefaultTool = olddeftool;
    FreeDiskObject(dobj);
  }

  /* Try the user's default prefs icon */
  if((! success) && (dobj=GetDiskObject("ENV:Sys/def_Pref"))) {
    oldtooltypes = dobj->do_ToolTypes;
    olddeftool = dobj->do_DefaultTool;

    dobj->do_ToolTypes = toolTypes;
    dobj->do_DefaultTool = deftoolname;

    success = PutDiskObject(name,dobj);

    /* we must restore the original pointers before freeing */
    dobj->do_ToolTypes = oldtooltypes;
    dobj->do_DefaultTool = olddeftool;
    FreeDiskObject(dobj);
  }

  /* Else, put our default icon */
  if(! success) {
    success = PutDiskObject(name,&projIcon);
  }

  return success;
}
Example #2
0
VOID
CreateIcon( STRPTR fname )
{
    struct DiskObject    *dob;
    struct Gadget        *gad;

    if( ( dob = GetDiskObjectNew( NULL ) ) )
    {
        gad = &dob->do_Gadget;
        gad->Width        = 54;
        gad->Height        = 22;
        gad->Flags        = GFLG_GADGIMAGE | GFLG_GADGBACKFILL;
        gad->GadgetType        = GTYP_BOOLGADGET;
        gad->GadgetRender    = ( APTR ) &IconImage;
        gad->UserData        = ( APTR ) WB_DISKREVISION;
        dob->do_Magic        = WB_DISKMAGIC;
        dob->do_Version        = WB_DISKVERSION;
        dob->do_Type        = WBPROJECT;
        dob->do_DefaultTool    = "ReqTools";
        dob->do_ToolTypes    = ToolTypes;
        dob->do_CurrentX    = dob->do_CurrentY = NO_ICON_POSITION;
        PutDiskObject( fname, dob );
        FreeDiskObject( dob );
    }
}
Example #3
0
// Write an icon for a file
void LIBFUNC L_WriteFileIcon(
	REG(a0, char *source),
	REG(a1, char *dest),
	REG(a6, struct MyLibrary *libbase))
{
	char *buffer;
	BPTR lock;
	struct DiskObject *icon;

	#ifdef __amigaos4__
	libbase = dopuslibbase_global;
	#endif

	// Get temporary buffer
	if (!(buffer=AllocVec(strlen(dest)+6,0)))
		return;

	// Tack on .info
	strcpy(buffer,dest);
	strcat(buffer,".info");

	// If icon already exists, don't overwrite
	if ((lock=Lock(buffer,ACCESS_READ)))
	{
		// Unlock and return
		UnLock(lock);
		FreeVec(buffer);
		return;
	}

	// Free buffer, get icon
	FreeVec(buffer);
	if (!(icon=L_GetCachedDiskObjectNew(source,1,libbase)))
		return;

	// Write icon and free it
	PutDiskObject(dest,icon);
	L_FreeCachedDiskObject(icon,libbase);
}