static void ami_file_set_type(const char *path, lwc_string *mime_type) { content_type type = content_factory_type_from_mime_type(mime_type); const char *default_type; switch(type) { case CONTENT_HTML: default_type = "html"; break; case CONTENT_CSS: default_type = "css"; break; default: default_type = NULL; break; } if (default_type != NULL) { struct DiskObject *dobj = NULL; dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,default_type, ICONGETA_GetDefaultType,WBPROJECT, TAG_DONE); PutIconTags(path, dobj, ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE); } }
void ami_drag_icon_show(struct Window *win, const char *type) { struct DiskObject *dobj = NULL; ULONG *icondata1; ULONG width, height; long format = 0; int err = 0; int deftype = WBPROJECT; drag_in_progress = TRUE; if(nsoption_bool(drag_save_icons) == false) { ami_update_pointer(win, AMI_GUI_POINTER_DRAG); return; } else { ami_update_pointer(win, GUI_POINTER_DEFAULT); } if(!strcmp(type, "drawer")) deftype = WBDRAWER; dobj = GetIconTags(NULL, ICONGETA_GetDefaultName, type, ICONGETA_GetDefaultType, deftype, TAG_DONE); err = IconControl(dobj, ICONCTRLA_GetWidth,&width, ICONCTRLA_GetHeight,&height, TAG_DONE); drag_icon_width = width; drag_icon_height = height; drag_icon = OpenWindowTags(NULL, WA_Left, scrn->MouseX - (width/2), WA_Top, scrn->MouseY - (height/2), WA_Width, width, WA_Height, height, WA_PubScreen, scrn, WA_Borderless, TRUE, WA_ToolBox, TRUE, WA_StayTop, TRUE, WA_Opaqueness, 128, WA_OverrideOpaqueness, TRUE, TAG_DONE); /* probably need layouticon and drawinfo stuff too */ DrawIconState(drag_icon->RPort, dobj, NULL, 0, 0, IDS_NORMAL, ICONDRAWA_Frameless, TRUE, ICONDRAWA_Borderless, TRUE, TAG_DONE); }
nserror gui_window_save_link(struct gui_window *g, nsurl *url, const char *title) { char fname[1024]; STRPTR openurlstring,linkname; struct DiskObject *dobj = NULL; linkname = ASPrintf("Link_to_%s",FilePart(nsurl_access(url))); if(AslRequestTags(savereq, ASLFR_Window, g->shared->win, ASLFR_SleepWindow, TRUE, ASLFR_TitleText,messages_get("NetSurf"), ASLFR_Screen,scrn, ASLFR_InitialFile,linkname, TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); AddPart(fname,savereq->fr_File,1024); ami_set_pointer(g->shared, GUI_POINTER_WAIT, false); if(ami_download_check_overwrite(fname, g->shared->win, 0)) { BPTR fh; if((fh = FOpen(fname,MODE_NEWFILE,0))) { /* \todo Should be URLOpen on OS4.1 */ openurlstring = ASPrintf("openurl \"%s\"\n",nsurl_access(url)); FWrite(fh,openurlstring,1,strlen(openurlstring)); FClose(fh); FreeVec(openurlstring); SetComment(fname, nsurl_access(url)); dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,"url", ICONGETA_GetDefaultType,WBPROJECT, TAG_DONE); dobj->do_DefaultTool = "IconX"; PutIconTags(fname,dobj, ICONPUTA_NotifyWorkbench,TRUE, TAG_DONE); FreeDiskObject(dobj); } FreeVec(linkname); } ami_reset_pointer(g->shared); } return NSERROR_OK; }
struct DiskObject *amiga_icon_from_bitmap(struct bitmap *bm) { struct DiskObject *dobj; struct BitMap *bitmap; if(bm) { bitmap = ami_bitmap_get_native(bm, THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, NULL); bm->icondata = AllocVecTagList(THUMBNAIL_WIDTH * 4 * THUMBNAIL_HEIGHT, NULL); BltBitMapTags(BLITA_Width, THUMBNAIL_WIDTH, BLITA_Height, THUMBNAIL_HEIGHT, BLITA_SrcType, BLITT_BITMAP, BLITA_Source, bitmap, BLITA_DestType, BLITT_ARGB32, BLITA_DestBytesPerRow, THUMBNAIL_WIDTH * 4, BLITA_Dest, bm->icondata, TAG_DONE); } dobj = GetIconTags(NULL, ICONGETA_GetDefaultType, WBPROJECT, ICONGETA_GetDefaultName, "iconify", TAG_DONE); if(bm) { IconControl(dobj, ICONCTRLA_SetImageDataFormat, IDFMT_DIRECTMAPPED, ICONCTRLA_SetWidth, THUMBNAIL_WIDTH, ICONCTRLA_SetHeight, THUMBNAIL_HEIGHT, ICONCTRLA_SetImageData1, bm->icondata, ICONCTRLA_SetImageData2, NULL, TAG_DONE); } dobj->do_Gadget.UserData = bm; LayoutIconA(dobj, (struct Screen *)~0UL, NULL); return dobj; }
int main(int argc, char **argv) { STRPTR newToolTypes[] = { "AROS=RULES", "Tooltypes are actually free-form text", "Ain't that neat?", NULL }; struct DiskObject *icon = GetIconTags ( "writetooltypes", ICONGETA_FailIfUnavailable, FALSE, TAG_DONE ); if (icon != NULL) { STRPTR *oldToolTypes = icon->do_ToolTypes; icon->do_ToolTypes = newToolTypes; if (!PutIconTags("writetooltypes", icon, TAG_DONE)) { printf("ERROR: Failed to write icon.\n"); } icon->do_ToolTypes = oldToolTypes; FreeDiskObject(icon); } else { printf("ERROR: Failed to open icon for file\n"); return 20; } return 0; }
void amiga_icon_superimpose_favicon(char *path, struct hlcache_handle *icon, char *type) { struct DiskObject *dobj = NULL; struct BitMap *bm = NULL; ULONG *icondata1, *icondata2; ULONG width, height; long format = 0; int err = 0; ULONG trans1, pals1; ULONG trans2, pals2; struct ColorRegister *pal1; struct ColorRegister *pal2; if(icon == NULL) return; if(!type) { dobj = GetIconTags(NULL, ICONGETA_GetDefaultType, WBDRAWER, TAG_DONE); } else { dobj = GetIconTags(NULL, ICONGETA_GetDefaultName, type, ICONGETA_GetDefaultType, WBPROJECT, TAG_DONE); } if(dobj == NULL) return; err = IconControl(dobj, ICONCTRLA_GetImageDataFormat,&format, ICONCTRLA_GetImageData1,&icondata1, ICONCTRLA_GetImageData2,&icondata2, ICONCTRLA_GetWidth,&width, ICONCTRLA_GetHeight,&height, TAG_DONE); /* If we have a palette-mapped icon, convert it to a 32-bit one */ if(format == IDFMT_PALETTEMAPPED) { IconControl(dobj, ICONCTRLA_GetTransparentColor1, &trans1, ICONCTRLA_GetPalette1, &pal1, ICONCTRLA_GetPaletteSize1, &pals1, ICONCTRLA_GetTransparentColor2, &trans2, ICONCTRLA_GetPalette2, &pal2, ICONCTRLA_GetPaletteSize2, &pals2, TAG_DONE); icondata1 = amiga_icon_convertcolouricon32((UBYTE *)icondata1, width, height, trans1, pals1, pal1, 0xff); icondata2 = amiga_icon_convertcolouricon32((UBYTE *)icondata2, width, height, trans2, pals2, pal2, 0xff); err = IconControl(dobj, ICONCTRLA_SetImageDataFormat, IDFMT_DIRECTMAPPED, ICONCTRLA_SetImageData1, icondata1, ICONCTRLA_SetImageData2, icondata2, TAG_DONE); } if((format == IDFMT_DIRECTMAPPED) || (format == IDFMT_PALETTEMAPPED)) amiga_icon_superimpose_favicon_internal(icon, dobj); PutIconTags(path, dobj, ICONPUTA_NotifyWorkbench, TRUE, TAG_DONE); FreeDiskObject(dobj); if(format == IDFMT_PALETTEMAPPED) { /* Free the 32-bit data we created */ FreeVec(icondata1); FreeVec(icondata2); } }
const char *fetch_filetype(const char *unix_path) { static char mimetype[50]; STRPTR ttype = NULL; struct DiskObject *dobj = NULL; BPTR lock = 0; struct DataTypeHeader *dth = NULL; struct DataType *dtn; BOOL found = FALSE; /* First try getting a tooltype "MIMETYPE" and use that as the MIME type. Will fail over to default icons if the file doesn't have a real icon. */ if(dobj = GetIconTags(unix_path,ICONGETA_FailIfUnavailable,FALSE, TAG_DONE)) { ttype = FindToolType(dobj->do_ToolTypes, "MIMETYPE"); if(ttype) { strcpy(mimetype,ttype); found = TRUE; } FreeDiskObject(dobj); } /* If that didn't work, have a go at guessing it using datatypes.library. This isn't accurate - the base names differ from those used by MIME and it relies on the user having a datatype installed which can handle the file. */ if(!found) { if (lock = Lock (unix_path, ACCESS_READ)) { if (dtn = ObtainDataTypeA (DTST_FILE, (APTR)lock, NULL)) { dth = dtn->dtn_Header; switch(dth->dth_GroupID) { case GID_SYSTEM: sprintf(mimetype,"application/%s",dth->dth_BaseName); break; case GID_TEXT: case GID_DOCUMENT: if(strcmp("ascii",dth->dth_BaseName)==0) { sprintf(mimetype,"text/plain",dth->dth_BaseName); } else if(strcmp("simplehtml",dth->dth_BaseName)==0) { sprintf(mimetype,"text/html",dth->dth_BaseName); } else { sprintf(mimetype,"text/%s",dth->dth_BaseName); } break; case GID_SOUND: case GID_INSTRUMENT: case GID_MUSIC: sprintf(mimetype,"audio/%s",dth->dth_BaseName); break; case GID_PICTURE: sprintf(mimetype,"image/%s",dth->dth_BaseName); break; case GID_ANIMATION: case GID_MOVIE: sprintf(mimetype,"video/%s",dth->dth_BaseName); break; } found = TRUE; ReleaseDataType(dtn); } UnLock(lock); } } if(!found) strcpy(mimetype,"text/html"); /* If all else fails */ //printf("%s: %s\n",unix_path,mimetype); return mimetype; }
void ami_init_mouse_pointers(void) { int i; struct RastPort mouseptr; struct DiskObject *dobj; uint32 format = IDFMT_BITMAPPED; int32 mousexpt=0,mouseypt=0; InitRastPort(&mouseptr); for(i=0;i<=AMI_LASTPOINTER;i++) { BPTR ptrfile = 0; mouseptrbm[i] = NULL; mouseptrobj[i] = NULL; char ptrfname[1024]; #ifdef __amigaos4__ if(nsoption_bool(truecolour_mouse_pointers)) { ami_get_theme_filename((char *)&ptrfname,ptrs32[i], false); if(dobj = GetIconTags(ptrfname,ICONGETA_UseFriendBitMap,TRUE,TAG_DONE)) { if(IconControl(dobj, ICONCTRLA_GetImageDataFormat, &format, TAG_DONE)) { if(IDFMT_DIRECTMAPPED == format) { int32 width = 0, height = 0; uint8* data = 0; IconControl(dobj, ICONCTRLA_GetWidth, &width, ICONCTRLA_GetHeight, &height, ICONCTRLA_GetImageData1, &data, TAG_DONE); if (width > 0 && width <= 64 && height > 0 && height <= 64 && data) { STRPTR tooltype; if(tooltype = FindToolType(dobj->do_ToolTypes, "XOFFSET")) mousexpt = atoi(tooltype); if(tooltype = FindToolType(dobj->do_ToolTypes, "YOFFSET")) mouseypt = atoi(tooltype); if (mousexpt < 0 || mousexpt >= width) mousexpt = 0; if (mouseypt < 0 || mouseypt >= height) mouseypt = 0; static uint8 dummyPlane[64 * 64 / 8]; static struct BitMap dummyBitMap = { 64 / 8, 64, 0, 2, 0, { dummyPlane, dummyPlane, 0, 0, 0, 0, 0, 0 }, }; mouseptrobj[i] = NewObject(NULL, "pointerclass", POINTERA_BitMap, &dummyBitMap, POINTERA_XOffset, -mousexpt, POINTERA_YOffset, -mouseypt, POINTERA_WordWidth, (width + 15) / 16, POINTERA_XResolution, POINTERXRESN_SCREENRES, POINTERA_YResolution, POINTERYRESN_SCREENRESASPECT, POINTERA_ImageData, data, POINTERA_Width, width, POINTERA_Height, height, TAG_DONE); } } } } } #endif if(!mouseptrobj[i]) { ami_get_theme_filename(ptrfname,ptrs[i], false); if(ptrfile = Open(ptrfname,MODE_OLDFILE)) { int mx,my; UBYTE *pprefsbuf = AllocVec(1061,MEMF_PRIVATE | MEMF_CLEAR); Read(ptrfile,pprefsbuf,1061); mouseptrbm[i]=AllocVec(sizeof(struct BitMap),MEMF_PRIVATE | MEMF_CLEAR); InitBitMap(mouseptrbm[i],2,32,32); mouseptrbm[i]->Planes[0] = AllocRaster(32,32); mouseptrbm[i]->Planes[1] = AllocRaster(32,32); mouseptr.BitMap = mouseptrbm[i]; for(my=0;my<32;my++) { for(mx=0;mx<32;mx++) { SetAPen(&mouseptr,pprefsbuf[(my*(33))+mx]-'0'); WritePixel(&mouseptr,mx,my); } } mousexpt = ((pprefsbuf[1056]-'0')*10)+(pprefsbuf[1057]-'0'); mouseypt = ((pprefsbuf[1059]-'0')*10)+(pprefsbuf[1060]-'0'); mouseptrobj[i] = NewObject(NULL,"pointerclass", POINTERA_BitMap,mouseptrbm[i], POINTERA_WordWidth,2, POINTERA_XOffset,-mousexpt, POINTERA_YOffset,-mouseypt, POINTERA_XResolution,POINTERXRESN_SCREENRES, POINTERA_YResolution,POINTERYRESN_SCREENRESASPECT, TAG_DONE); FreeVec(pprefsbuf); Close(ptrfile); } } } // for }